vec4
4D vector of floats (homogeneous coordinates, RGBA).
Fields and methods
Members of the struct numarray_stack<T,4>. Most of what you do with a CGP type goes through the free functions listed below.
Fields
T x | First coordinate of the vector. |
T y | Second coordinate of the vector. |
T z | Third coordinate of the vector. |
T w | Fourth coordinate of the vector. |
Methods
numarray_stack() | Builds a vector of size 2, 3 or 4 with all coordinates value-initialized (zero for numbers).8 overloads src |
numarray_stack(T const& x, T const& y, T const& z, T const& w) | Builds a 4D vector from its coordinates x, y, z and w. src |
numarray_stack(T const& x, T const& y, numarray_stack<T,2> const& zw) | Builds a 4D vector from x, y and a 2D vector giving (z, w). src |
numarray_stack(T const& x, numarray_stack<T,2> const& yz, T const& w) | Builds a 4D vector from x, a 2D vector giving (y, z), and w. src |
numarray_stack(T const& x, numarray_stack<T,3> const& yzw) | Builds a 4D vector from x and a 3D vector giving (y, z, w). src |
numarray_stack(numarray_stack<T,2> const& xy, T const& z, T const& w) | Builds a 4D vector from a 2D vector giving (x, y), then z and w. src |
numarray_stack(numarray_stack<T,2> const& xy, numarray_stack<T,2> const& zw) | Builds a 4D vector from two 2D vectors giving (x, y) and (z, w). src |
numarray_stack(numarray_stack<T,3> const& xyz, T const& w) | Builds a 4D vector from a 3D vector giving (x, y, z) and w, e.g. vec4(p, 1.0f) for a homogeneous position. src |
| Number of components N, fixed at compile time. src | |
| Sets the N components to the given value and returns the vector. src | |
| Returns the element at index, bound-checked unless CGP_NO_DEBUG is defined. src | |
| Returns a const reference to the element at the given index, with bound checking unless CGP_NO_DEBUG is defined. src | |
| Returns a const reference to the element at the given index; bound-checked for sizes 2, 3 and 4 (vec2, vec3, vec4) unless CGP_NO_DEBUG is defined, but not checked for the other sizes N. src | |
| Returns a const iterator to the first element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const iterator one past the last element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const iterator to the first element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const iterator one past the last element (a plain pointer for sizes 2, 3 and 4). src | |
| Returns a const reference to the element at the given index, without bound checking. src | |
| Returns a copy of the first three coordinates (x, y, z) as a vec3. src | |
| Returns a copy of the coordinates (x, y) as a 2D vector (for vec3 and vec4). src | |
| Returns a copy of the coordinates (y, z) as a 2D vector (for vec3 and vec4). src | |
| Returns a copy of the coordinates (x, z) as a 2D vector (for vec3 and vec4). src |
Functions taking a vec4
Construct 1
Documented on another page
tensor_productOuter product a * transpose(b), as a 4x4 matrix.onmat4
Convert 2
Access 2
template <typename T, int N, typename INDEX_TYPE>
void check_index_bounds(INDEX_TYPE index, numarray_stack<T,4> const& data)Raises an error if the index is outside [0, 3]; no-op when CGP_NO_DEBUG is defined.
Other 1
Documented on another page
opengl_uniformSend a vec4 uniform to the shader; warns if the uniform is not found and expected is true.onopengl_shader_structure
Functions returning a vec4
Access 1
Documented on another page
getRow idx1 as a vector, with the index checked at compile time (static_assert).onmatN
Operators
Show the 4 operators (+, -, *, ==, ...)
Documented on another page
operator*Apply the affine transform to a homogeneous vector, the translation being weighted by w: a direction (w=0) is not translated.onaffineoperator*Apply the rigid transform to a homogeneous vector, the translation being weighted by w.onaffine_rtoperator*Apply the transform to a homogeneous vector, the translation being weighted by w.onaffine_rtsoperator*Homogeneous vector whose xyz part is rotated, w being kept.onrotation_transform