std.math.vector

Module entries: angle(), cross(), length(), length(), normal()

angle(a, b)

float angle(vec3f a, vec3f b)

Return the angle between two vectors in radians.

cross(a, b)

vec3f cross(vec3f a, vec3f b)

Compute the cross product of two vectors.

length(v)

float length(vec3f v)

Return the length of the vector.

length(v)

float length(vec2f v)

Return the length of the vector.

normal(v)

vec3f normal(vec3f v)

Return a normalized vector; that is, a vector with length 1.

Example:

assert(vec3f(2, 0, 0).normal == vec3f(1, 0, 0));