|
constexpr | Point () noexcept |
| Default constructor. Initializes the point at the origin.
|
constexpr | Point (const Vector< T, N > &vec) noexcept |
| Constructs a point from a coordinate vector.
|
template<std::convertible_to< T >... Args>
requires (sizeof...(Args) == N) |
constexpr | Point (Args &&... args) noexcept |
| Constructs a point from a list of individual coordinate values.
|
constexpr T & | x () noexcept |
| Accesses the first coordinate (x-axis).
|
constexpr T & | y () noexcept |
| Accesses the second coordinate (y-axis).
|
constexpr T & | z () noexcept |
| Accesses the third coordinate (z-axis).
|
constexpr T & | w () noexcept |
| Accesses the fourth coordinate (w-axis).
|
constexpr T | x () const noexcept |
| Const access to the first coordinate (x-axis).
|
constexpr T | y () const noexcept |
| Const access to the second coordinate (y-axis).
|
constexpr T | z () const noexcept |
| Const access to the third coordinate (z-axis).
|
constexpr T | w () const noexcept |
| Const access to the fourth coordinate (w-axis).
|
constexpr int | dims () const noexcept |
| Returns the number of dimensions of the point.
|
constexpr const T & | operator[] (int index) const |
| Provides const access to the point's coordinates by index.
|
constexpr T & | operator[] (int index) |
| Provides mutable access to the point's coordinates by index.
|
constexpr const T & | at (int index) const |
| Provides safe const access to the point's coordinates by index.
|
constexpr Vector< T, N > | to_vector () const noexcept |
| Explicitly converts the point to its underlying coordinate vector.
|
constexpr Point & | operator+= (const Vector< T, N > &rhs) noexcept |
| Translates the point by adding a vector.
|
constexpr bool | operator< (const Point &rhs) const |
constexpr bool | operator<= (const Point &rhs) const |
constexpr bool | operator> (const Point &rhs) const |
| greater than
|
constexpr bool | operator>= (const Point &rhs) const |
| greater than or equal
|
constexpr bool | operator== (const Point &rhs) const |
| equal
|
constexpr Point & | operator-= (const Vector< T, N > &rhs) noexcept |
| Translates the point by subtracting a vector.
|
constexpr Vector< T, N > | operator- (const Point &rhs) const noexcept |
| Rule 1: Calculates the displacement vector between two points (Point - Point = Vector).
|
constexpr Point | operator+ (const Vector< T, N > &rhs) const noexcept |
| Rule 2: Translates a point by a vector, resulting in a new point (Point + Vector = Point).
|
constexpr Point | operator- (const Vector< T, N > &rhs) const noexcept |
| Rule 3: Translates a point by the negative of a vector (Point - Vector = Point).
|
constexpr Point | mid (const Point< T, N > &rhs) const noexcept |
| Calculates the midpoint between two points.
|
template<typename T, int N>
class pbpt::math::Point< T, N >
A template class for an N-dimensional point in space.
Represents a specific location in an N-dimensional affine space. Unlike a Vec, which represents direction and magnitude (a displacement), a Point represents a coordinate.
The class's interface enforces these geometric distinctions through its operator overloads:
- You can subtract two points to get the vector between them (Point - Point = Vec).
- You can add or subtract a vector to a point to get a new, translated point (Point +/- Vec = Point).
- Operations like adding two points are deliberately not defined, as they are geometrically meaningless in most contexts.
- Template Parameters
-
T | The underlying floating-point type of the point's coordinates. |
N | The number of dimensions. |
- See also
- Vec
template<typename T, int N>
template<std::convertible_to< T >... Args>
requires (sizeof...(Args) == N)
|
inlineexplicitconstexprnoexcept |
Constructs a point from a list of individual coordinate values.
The number of arguments must exactly match the point's dimension N.
- Template Parameters
-
Args | A parameter pack of types convertible to T. |
- Parameters
-
args | The coordinate values. |
- Note
- The number of arguments sizeof...(args) must be equal to N.