fennec
Loading...
Searching...
No Matches
Vectors

The fennec Vector Math Module.

the Vectors

Types

Type Corresponding Type Brief
Floats
vec2 fennec::vec2 A two-component single-precision floating-point vector.
vec3 fennec::vec3 A three-component single-precision floating-point vector.
vec4 fennec::vec4 A four-component single-precision floating-point vector.
Doubles
dvec2fennec::dvec2 A two-component double-precision floating-point vector.
dvec3fennec::dvec3 A three-component double-precision floating-point vector.
dvec4fennec::dvec4 A four-component double-precision floating-point vector.
Booleans
bvec2 fennec::bvec2 " \iline 1 A two-component boolean \ref fennec_math_vector "vector".
bvec3 fennec::bvec3 A three-component boolean vector.
bvec4 fennec::bvec4 A four-component boolean vector.
Integers
ivec2 fennec::ivec2 A two-component signed integer vector.
ivec3 fennec::ivec3 A three-component signed integer vector.
ivec4 fennec::ivec4 A four-component signed integer vector.
Unsigned Integers
uvec2 fennec::uvec2 A two-component unsigned integer vector.
uvec3 fennec::uvec3 A three-component unsigned integer vector.
uvec4 fennec::uvec4 A four-component unsigned integer vector.

Components

Vectors are usually made up of one to four components, named x, y, z, and w. Each component also has aliases for usage in colors rgba, and texture coordinates stpq. Accessing a component outside the vector will cause an error at compile time, for example:

vec2 pos;
float height;
pos.x; // is legal
pos.z; // is illegal
height.x; // is legal in glsl, but illegal in c++
height.y; // is illegal

Components can also be accessed with indices using the array access operator vector::operator[](size_t).

Swizzling

The fennec Vectors allows for the "swizzling" of vectors. Each component in the vector can be used in any combination, with up to 4 components, to create another vector. For example,

let \(V = (0, 1, 2)\) then \(V.xy = (0, 1)\) and \(V.zy = (2, 1)\)

More Info