utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::graphic::Position< PositionComponentType > Class Template Reference

Position in 3D space represented as a vector of three PositionComponentType components (x, y, z). More...

#include <headers/utility/graphic/position.hpp>

Inheritance diagram for utility::graphic::Position< PositionComponentType >:
Collaboration diagram for utility::graphic::Position< PositionComponentType >:

Public Member Functions

 Position (void)
 Default constructor initializing position to (0, 0, 0).
 
 Position (PositionComponentType value)
 Construct by filling all components with the same PositionComponentType value.
 
 Position (const utility::math::Vector< PositionComponentType, 3 > &vector)
 Construct from a vector.
 
 Position (PositionComponentType x, PositionComponentType y, PositionComponentType z)
 Construct from three PositionComponentType values (x, y, z).
 
 Position (std::initializer_list< PositionComponentType > values)
 Construct from initializer list of three PositionComponentType values.
 
 Position (const std::initializer_list< PositionComponentType > &value)
 Construct from a GLM vector.
 
 Position (const Position &other)=default
 Copy constructor.
 
 Position (Position &&other) noexcept=default
 Move constructor.
 
Positionoperator= (const Position &other)=default
 Copy assignment operator.
 
Positionoperator= (Position &&other) noexcept=default
 Move assignment operator.
 
 ~Position (void)=default
 Default destructor for Position.
 
PositionsetX (const PositionComponentType value) noexcept
 Set the X component of the position.
 
PositionComponentType getX (void) const noexcept
 Get the X component of the position.
 
PositionsetY (const PositionComponentType value) noexcept
 Set the Y component of the position.
 
PositionComponentType getY (void) const noexcept
 Get the Y component of the position.
 
PositionsetZ (const PositionComponentType value) noexcept
 Set the Z component of the position.
 
PositionComponentType getZ (void) const noexcept
 Get the Z component of the position.
 
Positiontranslate (const Position &offset) noexcept
 Translate this position by an offset.
 
Position translated (const Position &offset) const noexcept
 Return a translated copy of this position.
 
PositionComponentType distanceSquaredTo (const Position &other) const
 Compute squared Euclidean distance to another position.
 
PositionComponentType distanceTo (const Position &other) const
 Compute Euclidean distance to another position.
 
bool isOrigin (PositionComponentType epsilon=PositionComponentType { 1e-6 }) const noexcept
 Check whether this position is at (or near) the origin.
 
Position midpoint (const Position &other) const noexcept
 Compute midpoint between this position and another.
 
bool operator== (const Position &other) const noexcept
 Equality comparison.
 
bool operator!= (const Position &other) const noexcept
 Inequality comparison.
 
bool operator< (const Position &other) const noexcept
 Less-than comparison for ordering.
 
- Public Member Functions inherited from utility::math::Vector< PositionComponentType, 3 >
 Vector (void)
 Default constructor initializing vector values to zero.
 
 Vector (const glm::vec< VectorDimension, VectorComponentType > &v)
 Construct from a GLM vector.
 
 Vector (std::initializer_list< VectorComponentType > values)
 Construct from initializer list of float values.
 
 Vector (VectorComponentType value)
 Construct by filling all components with the same float value.
 
 Vector (const Vector &other)=default
 Copy constructor.
 
 Vector (Vector &&other) noexcept=default
 Move constructor.
 
 ~Vector (void)=default
 Default destructor for Vector.
 
Vectoroperator= (const Vector &other)=default
 Copy assignment operator.
 
Vectoroperator= (Vector &&other) noexcept=default
 Move assignment operator.
 
Vector operator+ (const Vector &rhs) const noexcept
 Vector addition.
 
Vectoroperator+= (const Vector &rhs) noexcept
 Vector addition assignment.
 
Vector operator- (const Vector &rhs) const noexcept
 Vector subtraction.
 
Vector operator- () const noexcept
 Unary negation.
 
Vectoroperator-= (const Vector &rhs) noexcept
 Vector subtraction assignment.
 
Vector operator* (VectorComponentType scalar) const noexcept
 Scalar multiplication.
 
Vector operator* (const Vector &rhs) const noexcept
 Element-wise multiplication.
 
Vectoroperator*= (VectorComponentType scalar) noexcept
 Scalar multiplication assignment.
 
Vectoroperator*= (const Vector &rhs) noexcept
 Element-wise multiplication assignment.
 
Vector operator/ (VectorComponentType scalar) const
 Scalar division.
 
Vector operator/ (const Vector &rhs) const
 Element-wise division.
 
Vectoroperator/= (VectorComponentType scalar)
 Scalar division assignment.
 
Vectoroperator/= (const Vector &rhs)
 Element-wise division assignment.
 
bool operator== (const Vector &rhs) const noexcept
 Equality comparison.
 
bool equalsEpsilon (const Vector &rhs, VectorComponentType epsilon=VectorComponentType { 1e-5 }) const
 Approximate equality using an epsilon threshold.
 
bool operator!= (const Vector &rhs) const noexcept
 Inequality comparison.
 

Detailed Description

template<CanBePositionComponent PositionComponentType>
class utility::graphic::Position< PositionComponentType >

Position in 3D space represented as a vector of three PositionComponentType components (x, y, z).

Template Parameters
PositionComponentTypeThe type of the position components (e.g., float, double).

Definition at line 51 of file position.hpp.

Constructor & Destructor Documentation

◆ Position() [1/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( void  )
inline

Default constructor initializing position to (0, 0, 0).

Definition at line 58 of file position.hpp.

Here is the caller graph for this function:

◆ Position() [2/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( PositionComponentType  value)
inlineexplicit

Construct by filling all components with the same PositionComponentType value.

Parameters
valueThe PositionComponentType value to fill all components with.

Definition at line 70 of file position.hpp.

◆ Position() [3/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( const utility::math::Vector< PositionComponentType, 3 > &  vector)
inlineexplicit

Construct from a vector.

Parameters
vectorVector to use for position.

Definition at line 79 of file position.hpp.

◆ Position() [4/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( PositionComponentType  x,
PositionComponentType  y,
PositionComponentType  z 
)
inline

Construct from three PositionComponentType values (x, y, z).

Parameters
xX component.
yY component.
zZ component.

Definition at line 91 of file position.hpp.

◆ Position() [5/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( std::initializer_list< PositionComponentType >  values)
inline

Construct from initializer list of three PositionComponentType values.

Parameters
valuesThe initializer list containing x, y, z components.
Exceptions
std::invalid_argumentif the list size is not 3.

Definition at line 103 of file position.hpp.

◆ Position() [6/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( const std::initializer_list< PositionComponentType > &  value)
inline

Construct from a GLM vector.

Parameters
valueSource vector.

Definition at line 122 of file position.hpp.

◆ Position() [7/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( const Position< PositionComponentType > &  other)
default

Copy constructor.

Parameters
otherThe Position object to copy from.

◆ Position() [8/8]

template<CanBePositionComponent PositionComponentType>
utility::graphic::Position< PositionComponentType >::Position ( Position< PositionComponentType > &&  other)
defaultnoexcept

Move constructor.

Parameters
otherThe Position object to move from.

Member Function Documentation

◆ distanceSquaredTo()

template<CanBePositionComponent PositionComponentType>
PositionComponentType utility::graphic::Position< PositionComponentType >::distanceSquaredTo ( const Position< PositionComponentType > &  other) const
inline

Compute squared Euclidean distance to another position.

Parameters
otherPosition to measure distance to.
Returns
Squared distance between the two positions.

Definition at line 246 of file position.hpp.

Here is the caller graph for this function:

◆ distanceTo()

template<CanBePositionComponent PositionComponentType>
PositionComponentType utility::graphic::Position< PositionComponentType >::distanceTo ( const Position< PositionComponentType > &  other) const
inline

Compute Euclidean distance to another position.

Parameters
otherPosition to measure distance to.
Returns
Distance between the two positions.

Definition at line 259 of file position.hpp.

Here is the call graph for this function:

◆ getX()

template<CanBePositionComponent PositionComponentType>
PositionComponentType utility::graphic::Position< PositionComponentType >::getX ( void  ) const
inlinenoexcept

Get the X component of the position.

Returns
The X value.

Definition at line 173 of file position.hpp.

◆ getY()

template<CanBePositionComponent PositionComponentType>
PositionComponentType utility::graphic::Position< PositionComponentType >::getY ( void  ) const
inlinenoexcept

Get the Y component of the position.

Returns
The Y value.

Definition at line 193 of file position.hpp.

◆ getZ()

template<CanBePositionComponent PositionComponentType>
PositionComponentType utility::graphic::Position< PositionComponentType >::getZ ( void  ) const
inlinenoexcept

Get the Z component of the position.

Returns
The Z value.

Definition at line 213 of file position.hpp.

◆ isOrigin()

template<CanBePositionComponent PositionComponentType>
bool utility::graphic::Position< PositionComponentType >::isOrigin ( PositionComponentType  epsilon = PositionComponentType { 1e-6 }) const
inlinenoexcept

Check whether this position is at (or near) the origin.

Parameters
epsilonAbsolute tolerance.
Returns
True when every component is within epsilon of zero.

Definition at line 269 of file position.hpp.

◆ midpoint()

template<CanBePositionComponent PositionComponentType>
Position utility::graphic::Position< PositionComponentType >::midpoint ( const Position< PositionComponentType > &  other) const
inlinenoexcept

Compute midpoint between this position and another.

Parameters
otherOther position.
Returns
Midpoint position.

Definition at line 281 of file position.hpp.

Here is the call graph for this function:

◆ operator!=()

template<CanBePositionComponent PositionComponentType>
bool utility::graphic::Position< PositionComponentType >::operator!= ( const Position< PositionComponentType > &  other) const
inlinenoexcept

Inequality comparison.

Parameters
otherThe position to compare with.
Returns
True if any component is not equal, false otherwise.

Definition at line 312 of file position.hpp.

◆ operator<()

template<CanBePositionComponent PositionComponentType>
bool utility::graphic::Position< PositionComponentType >::operator< ( const Position< PositionComponentType > &  other) const
inlinenoexcept

Less-than comparison for ordering.

Parameters
otherThe position to compare with.
Returns
True if this position is less than the other position.

Definition at line 322 of file position.hpp.

◆ operator=() [1/2]

template<CanBePositionComponent PositionComponentType>
Position & utility::graphic::Position< PositionComponentType >::operator= ( const Position< PositionComponentType > &  other)
default

Copy assignment operator.

Parameters
otherThe Position object to copy from.
Returns
A reference to this Position object.

◆ operator=() [2/2]

template<CanBePositionComponent PositionComponentType>
Position & utility::graphic::Position< PositionComponentType >::operator= ( Position< PositionComponentType > &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherThe Position object to move from.
Returns
A reference to this Position object.

◆ operator==()

template<CanBePositionComponent PositionComponentType>
bool utility::graphic::Position< PositionComponentType >::operator== ( const Position< PositionComponentType > &  other) const
inlinenoexcept

Equality comparison.

Parameters
otherThe position to compare with.
Returns
True if all components are equal, false otherwise.

Definition at line 293 of file position.hpp.

◆ setX()

template<CanBePositionComponent PositionComponentType>
Position & utility::graphic::Position< PositionComponentType >::setX ( const PositionComponentType  value)
inlinenoexcept

Set the X component of the position.

Parameters
valueThe new X value.
Returns
A reference to this Position object for method chaining.

Definition at line 163 of file position.hpp.

◆ setY()

template<CanBePositionComponent PositionComponentType>
Position & utility::graphic::Position< PositionComponentType >::setY ( const PositionComponentType  value)
inlinenoexcept

Set the Y component of the position.

Parameters
valueThe new Y value.
Returns
A reference to this Position object for method chaining.

Definition at line 183 of file position.hpp.

◆ setZ()

template<CanBePositionComponent PositionComponentType>
Position & utility::graphic::Position< PositionComponentType >::setZ ( const PositionComponentType  value)
inlinenoexcept

Set the Z component of the position.

Parameters
valueThe new Z value.
Returns
A reference to this Position object for method chaining.

Definition at line 203 of file position.hpp.

◆ translate()

template<CanBePositionComponent PositionComponentType>
Position & utility::graphic::Position< PositionComponentType >::translate ( const Position< PositionComponentType > &  offset)
inlinenoexcept

Translate this position by an offset.

Parameters
offsetPosition offset to add.
Returns
A reference to this Position object for method chaining.

Definition at line 223 of file position.hpp.

Here is the caller graph for this function:

◆ translated()

template<CanBePositionComponent PositionComponentType>
Position utility::graphic::Position< PositionComponentType >::translated ( const Position< PositionComponentType > &  offset) const
inlinenoexcept

Return a translated copy of this position.

Parameters
offsetPosition offset to add.
Returns
A new translated Position object.

Definition at line 234 of file position.hpp.


The documentation for this class was generated from the following file: