Vec

Undocumented in source.
pure @safe nothrow @nogc
struct Vec (
T
size_t N
) if (
N > 0 &&
isNumeric!T
) {}

Constructors

this
this(Comps comps)

Build a vector from its components Can be called with any combination of scalar or vectors, as long as the total number of scalar fit with length

this
this(Arr arr)

Build a vector from an array.

this
this(T comp)

Build a vector with all components assigned to one value

Members

Aliases

CompSeq
alias CompSeq = Repeat!(N, T)

Alias to a type sequence holding all components

Component
alias Component = T

The type of a vector component

Functions

opApply
int opApply(int delegate(size_t i, ref T) dg)

Foreach support.

opApply
int opApply(int delegate(ref T) dg)

Foreach support.

opApply
int opApply(int delegate(size_t i, ref T) @(safe) dg)

Foreach support.

opApply
int opApply(int delegate(ref T) @(safe) dg)

Foreach support.

opBinary
Vec!(T, N) opBinary(Vec!(U, N) oth)

Perform a term by term operation on the vector.

opBinary
Vec!(T, N) opBinary(U val)

Perform a scalar operation on the vector.

opBinaryRight
Vec!(T, N) opBinaryRight(U val)

Perform a scalar operation on the vector.

opCast
auto opCast()

Cast the vector to another type of component

opDollar
size_t opDollar()

End of the vector.

opIndex
T opIndex(size_t index)

Index a vector component.

opIndex
inout(T)[] opIndex(size_t[2] slice)
inout(T)[] opIndex()

Slicing support

opIndexAssign
void opIndexAssign(T val, size_t index)

Assign a vector component.

opIndexAssign
void opIndexAssign(U val, size_t[2] slice)
void opIndexAssign(U[] val, size_t[2] slice)
void opIndexAssign(U[] val)

Slicing support

opIndexOpAssign
void opIndexOpAssign(T val, size_t index)

Assign a vector component.

opIndexOpAssign
void opIndexOpAssign(U val, size_t[2] slice)

Slicing support

opIndexOpAssign
void opIndexOpAssign(U val, size_t[2] slice)

Term by term sliced assignement operation.

opOpAssign
Vec!(T, N) opOpAssign(Vec!(U, N) oth)

Perform a term by term assignment operation on the vector.

opOpAssign
Vec!(T, N) opOpAssign(U val)

Perform a scalar assignment operation on the vector.

opSlice
size_t[2] opSlice(size_t start, size_t end)

Slicing support

opUnary
Vec!(T, N) opUnary()

Unary "+" operation.

opUnary
Vec!(T, N) opUnary()

Unary "-" operation.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

length
enum length;

The number of components in the vector

nan
enum nan;

A vector with each component set as NaN (not a number)

Properties

array
T[length] array [@property getter]

All components in a static array

data
inout(T)[] data [@property getter]

Return the data of the array

opDispatch
T opDispatch [@property getter]

Access the component by name.

opDispatch
T opDispatch [@property setter]

Assign the component by name.

opDispatch
auto opDispatch [@property getter]

Access the components by swizzling.

opDispatch
Vec!(U, num) opDispatch [@property setter]

Assign the components by swizzling.

tup
Tuple!(CompSeq) tup [@property getter]

All components in a tuple

Variables

_rep
T[N] _rep;
Undocumented in source.

Examples

DVec3 v;

assert(v._rep[0] == 0);
assert(v._rep[1] == 0);
assert(v._rep[2] == 0);

v = DVec3(4, 5, 6);

assert(v._rep[0] == 4);
assert(v._rep[1] == 5);
assert(v._rep[2] == 6);
assert(v[1] == 5);
assert(v.z == 6);
assert(v[$ - 1] == 6);

assert(-v == DVec3(-4, -5, -6));

v.z = 2;
v[1] = 1;
assert(v[1] == 1);
assert(v.z == 2);

auto c = DVec4(0.2, 1, 0.6, 0.9);
assert(c.r == 0.2);
assert(c.g == 1);
assert(c.b == 0.6);
assert(c.a == 0.9);

assert(c.rrwuzy == DVec!6(0.2, 0.2, 0.9, 0.2, 0.6, 1));
c.bgra = DVec4(0.3, 0.4, 0.5, 0.6);
assert(c.data == [0.5, 0.4, 0.3, 0.6]);

Meta