vec4 Struct Template
Represents a 4-dimensional vector of the generic type <T>. More...
Declaration
Public Constructors Index
template <helios::math::Numeric T> | |
| constexpr | vec4 () noexcept |
|
Creates a new vec4 with its values initialized to (0, 0, 0, 0). More... | |
template <helios::math::Numeric T> | |
| constexpr | vec4 (const T x, const T y, const T z, const T w) noexcept |
|
Constructs a new vec4 with the specified x, y, z, w components. More... | |
template <helios::math::Numeric T> | |
| constexpr | vec4 (const T v) noexcept |
|
Constructs a new vec4 with v used for the x, y, z, w components. More... | |
template <helios::math::Numeric T> | |
| constexpr | vec4 (const vec3< T > &vec, const T w) noexcept |
|
Constructs a new vec4 from the vec3 vector and the w value. More... | |
template <helios::math::Numeric T> | |
| constexpr | vec4 (const vec3< T > &vec) noexcept |
|
Constructs a new vec4 from the vec3 vector and sets w to 1. More... | |
Public Operators Index
template <helios::math::Numeric 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::Numeric 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... | |
Public Member Functions Index
template <helios::math::Numeric T> | |
| constexpr auto | withW (T w) const noexcept -> vec4< T > |
|
Creates a new vec4 with the same x, y, z components but a modified w component. More... | |
template <helios::math::Numeric T> | |
| auto | toVec3 () const noexcept -> vec3< T > |
|
Converts this 4D vector to a 3D vector. More... | |
template <helios::math::Numeric T> | |
| auto | toVec2 () const noexcept -> vec2< T > |
|
Converts this 4D vector to a 2D vector. More... | |
Private Member Attributes Index
template <helios::math::Numeric T> | |
| T | v[4] |
|
Internal array storing the vector components. More... | |
Description
Represents a 4-dimensional vector of the generic type <T>.
The `vec4` struct provides a lightweight and efficient way to handle 4D vector mathematics for the numeric types float, int, double. For convenient access, the shorthands `vec4f`, `vec4d` and `vec4i` are available.
- Template Parameters
-
T The numeric type of the vector components.
Definition at line 33 of file vec4.ixx.
Public Constructors
vec4()
| inline constexpr noexcept |
vec4()
| inline constexpr noexcept |
Constructs a new vec4 with the specified x, y, z, w components.
- Parameters
-
x The value for the x component.
y The value for the y component.
z The value for the z component.
w The value for the w component.
vec4()
| inline constexpr noexcept |
vec4()
| inline constexpr noexcept |
vec4()
| 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.
Definition at line 105 of file vec4.ixx.
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 ref to the requested component.
Definition at line 119 of file vec4.ixx.
Public Member Functions
toVec2()
| inline nodiscard noexcept |
toVec3()
| inline nodiscard noexcept |
Converts this 4D vector to a 3D vector.
Extracts the x, y, z components from this vec4, discarding the w component. This is useful when converting from homogeneous coordinates back to 3D space.
- Returns
A new vec3<T> instance with components (x, y, z).
Definition at line 132 of file vec4.ixx.
References helios::math::vec4< T >::toVec3 and helios::math::vec4< T >::vec4.
Referenced by helios::math::vec4< T >::toVec3 and helios::engine::mechanics::bounds::systems::LevelBoundsBehaviorSystem::update.
withW()
| inline nodiscard constexpr noexcept |
Creates a new vec4 with the same x, y, z components but a modified w component.
This method returns a new vec4 instance where the x, y, and z components remain unchanged, and the w component is set to the specified value.
- Parameters
-
w The new value for the w component.
- Returns
A new vec4<T> instance with the updated w component.
Definition at line 93 of file vec4.ixx.
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.