Vector

T = type of elements. N = number of elements (2, 3, 4).

struct Vector (
T
ubyte N
) if (
N >= 2 &&
N <= 4
) {}

Constructors

this
this(U values)
this
this(Vector2!T xy, T z)
Undocumented in source.
this
this(Vector2!T xy, Vector2!T zw)
Undocumented in source.
this
this(Vector3!T xyz, T w)
Undocumented in source.

Members

Aliases

size
alias size = N
type
alias type = T

Functions

distanceTo
T distanceTo(Vector other)

Returns Euclidean distance between this and other.

fastInverseMagnitude
T fastInverseMagnitude()

Faster but less accurate inverse of Euclidean length. Returns inverse of Euclidean length.

fastNormalize
void fastNormalize()

Faster but less accurate in-place normalization.

fastNormalized
Vector fastNormalized()

Faster but less accurate vector normalization. Returns normalized vector.

getOrthogonalVector
Vector getOrthogonalVector()

Gets an orthogonal vector from a 3D vector.

inverseMagnitude
T inverseMagnitude()

Returns inverse of Euclidean length.

magnitude
T magnitude()

Returns Euclidean length.

normalize
void normalize()

In-place normalization.

normalized
Vector normalized()

Returns normalized vector.

opAssign
Vector opAssign(U rhs)

Assign a Vector from a compatible type.

opBinary
Vector opBinary(U rhs)
opBinaryRight
Vector opBinaryRight(U lhs)
opCast
U opCast()
opDollar
int opDollar()
opEquals
bool opEquals(U rhs)
opIndex
T opIndex(size_t i)
opIndex
const(T) opIndex(size_t i)
opIndexAssign
T opIndexAssign(U x, size_t i)
opOpAssign
Vector opOpAssign(U rhs)
opSlice
T[] opSlice()
opSlice
T[] opSlice(int a, int b)
opUnary
Vector opUnary()
ptr
inout(T)* ptr()

Returns a pointer to content.

rotate
Vector!(T, 3) rotate(float angle, Vector!(T, 3) axis)

*

squaredDistanceTo
T squaredDistanceTo(Vector v)
squaredMagnitude
T squaredMagnitude()
toString
string toString()

Converts current vector to a string.

Static variables

backward
Vector!(T, 3) backward;

Vector3 pointing backward.

down
Vector!(T, 2) down;

Vector2 pointing down.

down
Vector!(T, 3) down;

Vector3 pointing down.

forward
Vector!(T, 3) forward;

Vector3 pointing forward.

left
Vector!(T, 2) left;

Vector2 pointing left.

left
Vector!(T, 3) left;

Vector3 pointing left.

one
Vector!(T, 2) one;

Vector2 with values of 1.

one
Vector!(T, 3) one;

Vector3 with values of 1.

right
Vector!(T, 2) right;

Vector2 pointing right.

right
Vector!(T, 3) right;

Vector3 pointing right.

up
Vector!(T, 2) up;

Vector2 pointing up.

up
Vector!(T, 3) up;

Vector3 pointing up.

zero
Vector!(T, 2) zero;

Vector2 with values of 0.

zero
Vector!(T, 3) zero;

Vector3 with values of 0.

Unions

__anonymous
union __anonymous

Fields definition.

Meta