|
CGVIS Utils
|
#include <Vec4.h>
Public Member Functions | |
| Vec4t () | |
| Default-construct to (0,0,0,0). | |
| Vec4t (T x, T y, T z, T w) | |
| Construct from four component values. | |
| Vec4t (const Vec4t &other) | |
| Copy-construct from the same type. | |
| Vec4t (const Vec3t< T > &other, T w) | |
| Construct from a 3D vector and a w value. | |
| Vec4t (const Vec2t< T > &other, T z, T w) | |
| Construct from a 2D vector and z, w values. | |
| template<typename U> | |
| Vec4t (const Vec4t< U > &other) | |
Explicitly convert from another Vec4t with different component type. | |
| template<typename U> | |
| Vec4t (const Vec3t< U > &other, T w) | |
| Explicitly convert from a 3D vector of a different type and a w value. | |
| template<typename U> | |
| Vec4t (const Vec2t< U > &other, T z, T w) | |
| Explicitly convert from a 2D vector of a different type and z, w values. | |
| const std::string | toString () const |
| String representation "[x, y, z, w]". | |
| Vec4t | operator+ (const Vec4t &val) const |
| Component-wise addition. | |
| Vec4t | operator- (const Vec4t &val) const |
| Component-wise subtraction. | |
| Vec4t | operator* (const Vec4t &val) const |
| Component-wise multiplication. | |
| Vec4t | operator/ (const Vec4t &val) const |
| Component-wise division. | |
| Vec4t | operator* (const T &val) const |
| Scalar multiplication. | |
| Vec4t | operator/ (const T &val) const |
| Scalar division. | |
| Vec4t | operator+ (const T &val) const |
| Add scalar to all components. | |
| Vec4t | operator- (const T &val) const |
| Subtract scalar from all components. | |
| bool | operator== (const Vec4t &other) const |
| Equality comparison (component-wise equality). | |
| bool | operator!= (const Vec4t &other) const |
| Inequality comparison (component-wise inequality). | |
| T | length () const |
| Euclidean length (magnitude). | |
| T | sqlength () const |
| Squared length (avoids sqrt). | |
| Vec3t< T > | vec3 () const |
| Drop the last component and return a 3D vector (x,y,z). | |
| operator T* (void) | |
| Implicit pointer conversion to raw component storage. | |
| operator const T * (void) const | |
| Implicit pointer conversion to raw component storage (const). | |
Static Public Member Functions | |
| static T | dot (const Vec4t &a, const Vec4t &b) |
| Dot product of two 4D vectors. | |
| static Vec4t | normalize (const Vec4t &a) |
| Return the normalized (unit-length) version of a vector. | |
| static Vec4t< float > | random () |
| Create a vector with components sampled from [0,1). | |
| static Vec4t< float > | clamp (const Vec4t &val, float minVal, float maxVal) |
| Clamp each component to [minVal, maxVal]. | |
Public Attributes | |
| std::array< T, 4 > | e |
| Component storage and named aliases. | |
| struct { | |
| T x | |
| T y | |
| T z | |
| T w | |
| }; | |
| Cartesian aliases for components. | |
| struct { | |
| T r | |
| T g | |
| T b | |
| T a | |
| }; | |
| Color aliases for components. | |
| Vec2t< T > | xy |
| 2D view of the first two components. | |
| Vec3t< T > | xyz |
| 3D view of the first three components. | |
Construct from four component values.
| x | First component. |
| y | Second component. |
| z | Third component. |
| w | Fourth component. |
Copy-construct from the same type.
| other | Source vector to copy. |
Construct from a 3D vector and a w value.
| other | Source 3D vector for x, y, z. |
| w | Fourth component. |
Construct from a 2D vector and z, w values.
| other | Source 2D vector for x and y. |
| z | Third component. |
| w | Fourth component. |
|
inlineexplicit |
Explicitly convert from another Vec4t with different component type.
| U | Source component type. |
| other | Source vector to convert from. |
|
inlineexplicit |
Explicitly convert from a 3D vector of a different type and a w value.
| U | Source component type. |
| other | Source 3D vector for x, y, z. |
| w | Fourth component. |
|
inlineexplicit |
Explicitly convert from a 2D vector of a different type and z, w values.
| U | Source component type. |
| other | Source 2D vector for x and y. |
| z | Third component. |
| w | Fourth component. |
|
inlinestatic |
Clamp each component to [minVal, maxVal].
| val | Input vector. |
| minVal | Lower bound. |
| maxVal | Upper bound. |
Dot product of two 4D vectors.
| a | First vector. |
| b | Second vector. |
|
inline |
Euclidean length (magnitude).
Return the normalized (unit-length) version of a vector.
| a | Input vector. |
|
inline |
Implicit pointer conversion to raw component storage (const).
|
inline |
Implicit pointer conversion to raw component storage.
Inequality comparison (component-wise inequality).
| other | Vector to compare against. |
Scalar multiplication.
| val | Scalar factor. |
Component-wise multiplication.
| val | Vector to multiply component-wise. |
Add scalar to all components.
| val | Scalar to add. |
Component-wise addition.
| val | Vector to add. |
Subtract scalar from all components.
| val | Scalar to subtract. |
Component-wise subtraction.
| val | Vector to subtract. |
Scalar division.
| val | Scalar divisor. |
Component-wise division.
| val | Vector to divide by component-wise. |
Equality comparison (component-wise equality).
| other | Vector to compare against. |
|
inline |
Squared length (avoids sqrt).
|
inline |
String representation "[x, y, z, w]".
Drop the last component and return a 3D vector (x,y,z).
| struct { ... } Vec4t< T > |
Cartesian aliases for components.
| struct { ... } Vec4t< T > |
Color aliases for components.
| T Vec4t< T >::a |
| T Vec4t< T >::b |
| std::array<T, 4> Vec4t< T >::e |
Component storage and named aliases.
Indexed access: e[0], e[1], e[2], e[3].
| T Vec4t< T >::g |
| T Vec4t< T >::r |
| T Vec4t< T >::w |
| T Vec4t< T >::x |
| T Vec4t< T >::y |
| T Vec4t< T >::z |