vec3 Struct Template
Represents a 3-dimensional vector of the generic type <T>. More...
Declaration
Public Constructors Index
template <helios::math::concepts::IsNumeric T> | |
| constexpr | vec3 () noexcept |
|
Creates a new vec3 with its values initialized to (0, 0, 0) More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr | vec3 (const T x, const T y, const T z) noexcept |
|
Constructs a new vec3 with the specified x, y, z components. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr | vec3 (const T v) noexcept |
|
Constructs a new vec3 with the specified value as the x,y,z components. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr | vec3 (const helios::math::vec2< T > v) noexcept |
|
Constructs a new vec3 with x,y components initialized to those of the vec2 and vec3 set to 0. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr | vec3 (const helios::math::vec2< T > v, T f) noexcept |
|
Constructs a new vec3 with x,y components initialized to those of the vec2 and the z component set to the specified value. More... | |
Public Operators Index
template <helios::math::concepts::IsNumeric T> | |
| constexpr const T & | operator[] (const size_t i) const noexcept |
|
Provides read only access to the vector components. Bounds checking is performed via assert in debug builds. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr T & | operator[] (const size_t i) noexcept |
|
Provides read-write access to the vector components. Bounds checking is performed via assert in debug builds. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr bool | operator== (const vec3< T > &rgt) const |
|
Strictly compares the elements of this vector with the elements of the rgt vector. More... | |
Public Member Functions Index
template <helios::math::concepts::IsNumeric T> | |
| auto | length () const noexcept -> FloatingPointType< T > |
|
Computes the Euclidean norm (magnitude) of this vector and returns it. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | cross (const helios::math::vec3< T > &v2) const noexcept -> vec3< T > |
|
Computes the cross product of this vector and v2. More... | |
template <helios::math::concepts::IsNumeric T> | |
| T | dot (const helios::math::vec3< T > &v2) const noexcept |
|
Computes the dot product of this vector and v2. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | toVec4 () const noexcept -> vec4< T > |
|
Converts this 3D vector to a 4D homogeneous vector. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | toVec2 () const noexcept -> vec2< T > |
|
Converts this 3D vector to a 2D vector by discarding the z-component. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | toVec4 (T w) const noexcept -> vec4< T > |
|
Converts this 3D vector to a 4D homogeneous vector. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | normalize () const noexcept -> vec3< FloatingPointType< T > > |
|
Returns a normalized version of this vector. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr bool | same (const vec3< T > &rgt, T epsilon=0.0001) const |
|
Compares this vector's elements with the rgt vector considering an epsilon value. Returns true if for all elements the equation |a-b| <= epsilon holds. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | flipY () const noexcept -> constexpr helios::math::vec3< T > |
|
Returns a new vector with the y-component negated. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | withY (T y) const noexcept -> constexpr helios::math::vec3< T > |
|
Returns a new vector with the y-component replaced by the given value. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | flipX () const noexcept -> constexpr helios::math::vec3< T > |
|
Returns a new vector with the x-component negated. More... | |
template <helios::math::concepts::IsNumeric T> | |
| auto | withX (T x) const noexcept -> constexpr helios::math::vec3< T > |
|
Returns a new vector with the x-component replaced by the given value. More... | |
template <helios::math::concepts::IsNumeric T> | |
| constexpr bool | isNormalized () const noexcept |
|
Checks if this vector is normalized (unit length). More... | |
Private Member Attributes Index
template <helios::math::concepts::IsNumeric T> | |
| T | v[3] |
|
Internal array storing the vector components. More... | |
Description
Represents a 3-dimensional vector of the generic type <T>.
The vec3 struct provides a lightweight and efficient way to handle 3D vector mathematics for the numeric types float, int, double. For convenient access, the shorthands vec3f, vec3d and vec3i are available.
- Template Parameters
-
T The numeric type of the vector components.
Definition at line 34 of file vec3.ixx.
Public Constructors
vec3()
| inline constexpr noexcept |
vec3()
vec3()
| inline explicit constexpr noexcept |
vec3()
| inline explicit constexpr noexcept |
vec3()
| inline explicit constexpr noexcept |
Public Operators
operator[]()
| inline constexpr noexcept |
Provides read only access to the vector components. Bounds checking is performed via assert in debug builds.
- Parameters
-
i The index to query
- Returns
A const ref to the requested component.
operator[]()
| inline constexpr noexcept |
Provides read-write access to the vector components. Bounds checking is performed via assert in debug builds.
- Parameters
-
i The index to query
- Returns
A const ref to the requested component.
operator==()
| inline constexpr |
Strictly compares the elements of this vector with the elements of the rgt vector.
- Parameters
-
rgt The right vector to compare for equal values.
- Returns
True if all elements are equal (==), false otherwise.
Public Member Functions
cross()
| inline noexcept |
Computes the cross product of this vector and v2.
- Parameters
-
v2 The second vec3<T> vector.
- Returns
The cross product as a value of type vec3<T>.
dot()
| inline noexcept |
flipX()
| inline constexpr noexcept |
Returns a new vector with the x-component negated.
- Returns
A new vec3<T> with (-x, y, z).
Definition at line 245 of file vec3.ixx.
flipY()
| inline constexpr noexcept |
Returns a new vector with the y-component negated.
- Returns
A new vec3<T> with (x, -y, z).
Definition at line 226 of file vec3.ixx.
isNormalized()
| inline constexpr noexcept |
Checks if this vector is normalized (unit length).
A vector is considered normalized if its squared length equals 1 within the tolerance defined by EPSILON_LENGTH.
- Returns
true if the vector is approximately unit length, false otherwise.
Definition at line 267 of file vec3.ixx.
Reference helios::math::EPSILON_LENGTH.
length()
| inline noexcept |
Computes the Euclidean norm (magnitude) of this vector and returns it.
- Returns
The norm (magnitude) of this vector as a value of type FloatingPointType<T>.
Definition at line 121 of file vec3.ixx.
normalize()
| inline noexcept |
Returns a normalized version of this vector.
- Returns
A new vec3<FloatingPointType<T>> instance representing the normalized vector.
Definition at line 183 of file vec3.ixx.
same()
| inline constexpr |
Compares this vector's elements with the rgt vector considering an epsilon value. Returns true if for all elements the equation |a-b| <= epsilon holds.
- Parameters
-
rgt The other vector to compare with this vector for equality.
epsilon The epsilon value to use for comparison. If omitted, the default epsilon (0.0001) is used.
- Returns
True if the elements of the vectors are considered equal, otherwise false.
toVec2()
| inline noexcept |
toVec4()
| inline noexcept |
Converts this 3D vector to a 4D homogeneous vector.
Creates a vec4 with the x, y, z components from this vector and sets the w component to 0, representing a direction in homogeneous coordinates.
- Returns
A new vec4<T> instance with components (x, y, z, 0).
toVec4()
| inline noexcept |
Converts this 3D vector to a 4D homogeneous vector.
Creates a vec4 with the x, y, z components from this vector and sets the w component accordingly, representing a direction in homogeneous coordinates.
- Parameters
-
w The value of the w component.
- Returns
A new vec4<T> instance with components (x, y, z, w).
withX()
| inline constexpr noexcept |
Returns a new vector with the x-component replaced by the given value.
- Parameters
-
x The new x value.
- Returns
A new vec3<T> with (x, y, z).
Definition at line 255 of file vec3.ixx.
withY()
| inline constexpr noexcept |
Returns a new vector with the y-component replaced by the given value.
- Parameters
-
y The new y value.
- Returns
A new vec3<T> with (x, y, z).
Definition at line 236 of file vec3.ixx.
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.