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.
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.
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.

get_
inout(vt) get_()
isFinite
bool isFinite()

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

length
real length()

Returns the magnitude of the vector.

lengthSquared
real lengthSquared()

Returns the squared magnitude of the vector.

normalize
void normalize()

Normalizes the vector.

normalized
Vector normalized()

Returns a normalized copy of the current 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
Vector 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.
opCmp
int opCmp(Vector vec)
Undocumented in source. Be warned that the author may not have intended to support it.
opDispatch
Vector!(vt, s.length) opDispatch()

Implements dynamic swizzling.

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.
ptr
auto ptr()

Returns a pointer to the coordinates.

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.
toHash
size_t toHash()

Gets a hash of this item

toString
const(string) toString()

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

update
void update(Vector!(vt, dimension) other)

Updates the vector with the values from other.

Static functions

back
auto back()

Back vector (0, 0, -1)

down
auto down()

Down vector (0, 1) OR (0, -1, 0)

forward
auto forward()

Forward vector (0, 0, 1)

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.
left
auto left()

Left vector (-1, 0, 0)

one
auto one()

A vector with all ones

right
auto right()

Right vector (1, 0, 0)

up
auto up()

Up vector (0, -1) OR (0, 1, 0)

zero
auto zero()

A vector with all zeroes

Static variables

dimension
int dimension;

Holds the dimension of the vector.

Templates

coordToIndex
template coordToIndex(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