|
CGVIS Utils
|
#include <Vec3.h>
Public Member Functions | |
| Vec3t () | |
| Default-construct to (0,0,0). | |
| Vec3t (T x, T y, T z) | |
| Construct from three component values. | |
| Vec3t (const Vec3t &other) | |
| Copy-construct from the same type. | |
| Vec3t (const Vec2t< T > &other, T z) | |
| Construct from a 2D vector and a z value. | |
| template<typename U> | |
| Vec3t (const Vec3t< U > &other) | |
Explicitly convert from another Vec3t with different component type. | |
| template<typename U> | |
| Vec3t (const Vec2t< U > &other, T z) | |
| Explicitly convert from a 2D vector of a different type and a z value. | |
| const std::string | toString () const |
| String representation "[x, y, z]". | |
| Vec3t | operator+ (const Vec3t &val) const |
| Component-wise addition. | |
| Vec3t | operator- (const Vec3t &val) const |
| Component-wise subtraction. | |
| Vec3t | operator* (const Vec3t &val) const |
| Component-wise multiplication. | |
| Vec3t | operator/ (const Vec3t &val) const |
| Component-wise division. | |
| Vec3t | operator* (const T &val) const |
| Scalar multiplication. | |
| Vec3t | operator/ (const T &val) const |
| Scalar division. | |
| Vec3t | operator+ (const T &val) const |
| Add scalar to all components. | |
| Vec3t | operator- (const T &val) const |
| Subtract scalar from all components. | |
| bool | operator== (const Vec3t &other) const |
| Equality comparison (component-wise equality). | |
| bool | operator!= (const Vec3t &other) const |
| Inequality comparison (component-wise inequality). | |
| T | length () const |
| Euclidean length (magnitude). | |
| T | sqlength () const |
| Squared length (avoids sqrt). | |
| 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 float | dot (const Vec3t &a, const Vec3t &b) |
| Dot product of two vectors. | |
| static Vec3t | cross (const Vec3t &a, const Vec3t &b) |
| Cross product of two vectors. | |
| static Vec3t | normalize (const Vec3t &a) |
| Return the normalized (unit-length) version of a vector. | |
| static Vec3t | reflect (const Vec3t &a, const Vec3t &n) |
| Reflect a vector about a unit normal. | |
| static std::optional< Vec3t > | refract (const Vec3t &a, const Vec3t &normal, const T IOR) |
| Refract a vector through a surface with index-of-refraction ratio. | |
| static Vec3t | minV (const Vec3t &a, const Vec3t &b) |
| Component-wise minimum of two vectors. | |
| static Vec3t | maxV (const Vec3t &a, const Vec3t &b) |
| Component-wise maximum of two vectors. | |
| static Vec3t< float > | random () |
| Create a vector with components sampled from [0,1). | |
| static Vec3t< float > | randomPointInSphere () |
| Uniform random point inside the unit sphere. | |
| static Vec3t< float > | randomPointInHemisphere () |
| Uniform random point inside the upper unit hemisphere (z>=0). | |
| static Vec3t< float > | randomPointInDisc () |
| Uniform random point inside the unit disc on the xy-plane. | |
| static Vec3t< float > | randomUnitVector () |
| Uniform random unit vector on the sphere. | |
| static Vec3t< float > | clamp (const Vec3t &val, float minVal, float maxVal) |
| Clamp each component to [minVal, maxVal]. | |
Public Attributes | |
| std::array< T, 3 > | e |
| Component storage and named aliases. | |
| struct { | |
| T x | |
| T y | |
| T z | |
| }; | |
| Cartesian aliases for components. | |
| struct { | |
| T r | |
| T g | |
| T b | |
| }; | |
| Color aliases for components. | |
| Vec2t< T > | xy |
| 2D view of the first two components. | |
Construct from three component values.
| x | First component. |
| y | Second component. |
| z | Third component. |
Copy-construct from the same type.
| other | Source vector to copy. |
Construct from a 2D vector and a z value.
| other | Source 2D vector for x and y. |
| z | Third component. |
|
inlineexplicit |
Explicitly convert from another Vec3t with different component type.
| U | Source component type. |
| other | Source vector to convert from. |
|
inlineexplicit |
Explicitly convert from a 2D vector of a different type and a z value.
| U | Source component type. |
| other | Source 2D vector for x and y. |
| z | Third component. |
|
inlinestatic |
Clamp each component to [minVal, maxVal].
| val | Input vector. |
| minVal | Lower bound. |
| maxVal | Upper bound. |
|
inlinestatic |
Cross product of two vectors.
| a | First vector. |
| b | Second vector. |
|
inlinestatic |
Dot product of two vectors.
| a | First vector. |
| b | Second vector. |
|
inline |
Euclidean length (magnitude).
|
inlinestatic |
Component-wise maximum of two vectors.
| a | First vector. |
| b | Second vector. |
|
inlinestatic |
Component-wise minimum of two vectors.
| a | First vector. |
| b | Second vector. |
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. |
Uniform random point inside the unit disc on the xy-plane.
Uniform random point inside the upper unit hemisphere (z>=0).
Uniform random point inside the unit sphere.
Uniform random unit vector on the sphere.
|
inlinestatic |
Reflect a vector about a unit normal.
| a | Incident vector. |
| n | Unit surface normal (assumed normalized). |
|
inlinestatic |
Refract a vector through a surface with index-of-refraction ratio.
Computes the transmitted direction using Snell's law. If total internal reflection occurs, returns an empty optional.
| a | Incident vector (assumed pointing towards the surface). |
| normal | Surface normal (assumed normalized, pointing away from surface). |
| IOR | Index-of-refraction of the material (n_material / n_outside). |
|
inline |
Squared length (avoids sqrt).
|
inline |
String representation "[x, y, z]".
| struct { ... } Vec3t< T > |
Cartesian aliases for components.
| struct { ... } Vec3t< T > |
Color aliases for components.
| T Vec3t< T >::b |
| std::array<T, 3> Vec3t< T >::e |
Component storage and named aliases.
Indexed access: e[0], e[1], e[2].
| T Vec3t< T >::g |
| T Vec3t< T >::r |
| T Vec3t< T >::x |
| T Vec3t< T >::y |
| T Vec3t< T >::z |