Vector

Base template for all vector-types.

struct Vector (
type
int dimension_
) {}

Constructors

this
this(Args args)
this(T vec)
this(vt value)

Constructs the vector. If a single value is passed the vector, the vector will be cleared with this value. If a vector with a higher dimension is passed the vector will hold the first values up to its dimension. If mixed types are passed they will be joined together (allowed types: vector, static array, vt).

Members

Aliases

a
alias a = w
Undocumented in source.
b
alias b = z
Undocumented in source.
g
alias g = y
Undocumented in source.
length
alias length = magnitude
Undocumented in source.
length_squared
alias length_squared = magnitude_squared
Undocumented in source.
ok
deprecated alias ok = isFinite
Undocumented in source.
p
alias p = z
Undocumented in source.
q
alias q = w
Undocumented in source.
r
alias r = x
Undocumented in source.
s
alias s = x
Undocumented in source.
t
alias t = y
Undocumented in source.
toString
alias toString = as_string
Undocumented in source.
u
alias u = x
Undocumented in source.
v
alias v = y
Undocumented in source.
vt
alias vt = type
Undocumented in source.
w
alias w = get_!'w'
Undocumented in source.
x
alias x = get_!'x'
Undocumented in source.
y
alias y = get_!'y'
Undocumented in source.
z
alias z = get_!'z'
Undocumented in source.

Functions

clear
void clear(vt value)

Sets all values of the vector to value.

normalize
void normalize()

Normalizes the vector.

opBinary
Vector opBinary(vt r)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Vector opBinary(vt r)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Vector opBinary(Vector r)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
vt opBinary(Vector r)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Vector!(vt, T.cols) opBinary(T inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
auto opBinaryRight(T inp)
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(Vector vec)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(T vec)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(const(T)[] array)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(vt r)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(vt r)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(Vector r)
Undocumented in source. Be warned that the author may not have intended to support it.
opUnary
Vector opUnary()
Undocumented in source. Be warned that the author may not have intended to support it.
set
void set(vt x, vt y)
Undocumented in source. Be warned that the author may not have intended to support it.
set
void set(vt x, vt y, vt z)
Undocumented in source. Be warned that the author may not have intended to support it.
set
void set(vt x, vt y, vt z, vt w)
Undocumented in source. Be warned that the author may not have intended to support it.
update
void update(Vector!(vt, dimension) other)

Updates the vector with the values from other.

Properties

as_string
string as_string [@property getter]

Returns the current vector formatted as string, useful for printing the vector.

get_
inout(vt) get_ [@property getter]
isFinite
bool isFinite [@property getter]

Returns true if all values are not nan and finite, otherwise false.

magnitude
real magnitude [@property getter]

Returns the magnitude of the vector.

magnitude_squared
real magnitude_squared [@property getter]

Returns the squared magnitude of the vector.

normalized
Vector normalized [@property getter]

Returns a normalized copy of the current vector.

opDispatch
Vector!(vt, s.length) opDispatch [@property getter]

Implements dynamic swizzling.

value_ptr
auto value_ptr [@property getter]

Returns a pointer to the coordinates.

Static functions

isCompatibleMatrixImpl
void isCompatibleMatrixImpl(Matrix!(vt, r, c) m)
Undocumented in source. Be warned that the author may not have intended to support it.
isCompatibleVectorImpl
void isCompatibleVectorImpl(Vector!(vt, d) vec)
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

dimension
int dimension;

Holds the dimension of the vector.

Templates

coord_to_index
template coord_to_index(char c)
Undocumented in source.
isCompatibleMatrix
template isCompatibleMatrix(T)
Undocumented in source.
isCompatibleVector
template isCompatibleVector(T)
Undocumented in source.

Variables

e1
enum Vector e1;

canonical basis for Euclidian space

e1
enum Vector e1;

canonical basis for Euclidian space

e1
enum Vector e1;
e2
enum Vector e2;
e3
enum Vector e3;
e4
enum Vector e4;

canonical basis for Euclidian space

vector
vt[dimension] vector;

Holds all coordinates, length conforms dimension.

Parameters

type

all values get stored as this type

Examples

alias Vector!(int, 3) vec3i;
alias Vector!(float, 4) vec4;
alias Vector!(real, 2) vec2r;

Meta