|
constexpr | Homogeneous () noexcept |
| Default constructor.
|
constexpr | Homogeneous (const Point< T, N > &p) noexcept |
| Constructs a homogeneous coordinate from a Point.
|
constexpr | Homogeneous (const Vector< T, N > &v) noexcept |
| Constructs a homogeneous coordinate from a Vec (vector).
|
template<std::convertible_to< T >... Vals>
requires (sizeof...(Vals) == N + 1) |
constexpr | Homogeneous (Vals... vals) noexcept |
| Constructs a homogeneous coordinate from a list of values.
|
constexpr | Homogeneous (const Vector< T, N+1 > &data) noexcept |
| Explicitly constructs from a raw (N+1)-dimensional vector.
|
constexpr const T & | w () const |
| Returns the w-component of the homogeneous coordinate.
|
constexpr T & | w () |
| Returns a reference to the w-component of the homogeneous coordinate.
|
constexpr const T & | operator[] (int index) const |
| Returns the value of the homogeneous coordinate at the specified index.
|
constexpr T & | operator[] (int index) |
| Returns the value of the homogeneous coordinate at the specified index.
|
constexpr const T & | at (int index) const |
| Returns the value of the homogeneous coordinate at the specified index.
|
constexpr bool | is_point () const noexcept |
| Checks if this homogeneous coordinate represents a point.
|
constexpr bool | is_vector () const noexcept |
| Checks if this homogeneous coordinate represents a vector.
|
constexpr Point< T, N > | to_point () const |
| Converts the homogeneous coordinate back to a Point.
|
constexpr Vector< T, N > | to_vector () const |
| Converts the homogeneous coordinate back to a Vec.
|
constexpr const Vector< T, N+1 > & | raw () const noexcept |
| Provides read-only access to the underlying raw (N+1)-dimensional vector.
|
constexpr Vector< T, N+1 > & | raw () noexcept |
| Provides mutable access to the underlying raw (N+1)-dimensional vector.
|
template<typename T, int N>
class pbpt::math::Homogeneous< T, N >
A template class for an N-dimensional homogeneous coordinate.
This class unifies the mathematical treatment of points and vectors for use in projective geometry, particularly for 3D transformations. It internally stores an (N+1)-dimensional vector.
The distinction between a point and a vector is encoded in the last component, w:
- A Point (x, y, z) is represented in homogeneous coordinates as (x, y, z, 1).
- A Vector (vx, vy, vz) is represented as (vx, vy, vz, 0).
This class provides a type-safe way to create these coordinates from Point and Vec objects, and to convert them back, including performing the necessary perspective divide for points.
- Template Parameters
-
T | The underlying floating-point type of the coordinate's components. |
N | The original number of dimensions (e.g., 3 for 3D space). The internal storage will have N+1 dimensions. |
- See also
- Point
-
Vec
-
Matrix
template<typename T, int N>
template<std::convertible_to< T >... Vals>
requires (sizeof...(Vals) == N + 1)
|
inlineexplicitconstexprnoexcept |
Constructs a homogeneous coordinate from a list of values.
The number of values must match the number of dimensions (N + 1).
- Template Parameters
-
Vals | The types of the values, must be convertible to T. |
- Parameters
-
vals | The values to initialize the homogeneous coordinate. |