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::Scale< ScaleComponentType > Class Template Reference

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

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

Inheritance diagram for utility::graphic::Scale< ScaleComponentType >:
Collaboration diagram for utility::graphic::Scale< ScaleComponentType >:

Public Member Functions

 Scale (void)
 Default constructor initializing scale to (1, 1, 1).
 
 Scale (ScaleComponentType value)
 Construct by filling all components with the same ScaleComponentType value.
 
 Scale (const utility::math::Vector< ScaleComponentType, 3 > &vector)
 Construct from a vector.
 
 Scale (ScaleComponentType x, ScaleComponentType y, ScaleComponentType z)
 Construct from three ScaleComponentType values (x, y, z).
 
 Scale (std::initializer_list< ScaleComponentType > values)
 Construct from initializer list of three ScaleComponentType values.
 
 Scale (const std::initializer_list< ScaleComponentType > &value)
 Construct from a GLM vector.
 
 Scale (const Scale &other)=default
 Copy constructor.
 
 Scale (Scale &&other) noexcept=default
 Move constructor.
 
Scaleoperator= (const Scale &other)=default
 Copy assignment operator.
 
Scaleoperator= (Scale &&other) noexcept=default
 Move assignment operator.
 
 ~Scale (void)=default
 Default destructor for Scale.
 
ScalesetX (const ScaleComponentType value) noexcept
 Set the X component of the scale.
 
ScaleComponentType getX (void) const noexcept
 Get the X component of the scale.
 
ScalesetY (const ScaleComponentType value) noexcept
 Set the Y component of the scale.
 
ScaleComponentType getY (void) const noexcept
 Get the Y component of the scale.
 
ScalesetZ (const ScaleComponentType value) noexcept
 Set the Z component of the scale.
 
ScaleComponentType getZ (void) const noexcept
 Get the Z component of the scale.
 
ScalescaleBy (const Scale &factor) noexcept
 Scale this object by another scale (component-wise multiplication).
 
Scale scaled (const Scale &factor) const noexcept
 Return a scaled copy of this object (component-wise multiplication).
 
ScalesetUniform (ScaleComponentType value) noexcept
 Set all scale components to the same value.
 
bool isUniform (ScaleComponentType epsilon=ScaleComponentType { 1e-6 }) const noexcept
 Check whether all scale components are approximately equal.
 
bool hasNegativeComponent (void) const noexcept
 Check whether any component is negative.
 
bool operator== (const Scale &other) const noexcept
 Equality comparison.
 
bool operator!= (const Scale &other) const noexcept
 Inequality comparison.
 
bool operator< (const Scale &other) const noexcept
 Less-than comparison for ordering.
 
- Public Member Functions inherited from utility::math::Vector< ScaleComponentType, 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<CanBeScaleComponent ScaleComponentType>
class utility::graphic::Scale< ScaleComponentType >

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

This class provides a 3D scale vector, typically used for scaling objects in 3D graphic. It supports construction from initializer lists, GLM vectors, and provides methods for component access and scaling operations.

Template Parameters
ScaleComponentTypeThe type of the scale components (e.g., float, double).

Definition at line 54 of file scale.hpp.

Constructor & Destructor Documentation

◆ Scale() [1/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( void  )
inline

Default constructor initializing scale to (1, 1, 1).

Definition at line 61 of file scale.hpp.

◆ Scale() [2/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( ScaleComponentType  value)
inlineexplicit

Construct by filling all components with the same ScaleComponentType value.

Parameters
valueThe ScaleComponentType value to fill all components with.

Definition at line 74 of file scale.hpp.

◆ Scale() [3/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( const utility::math::Vector< ScaleComponentType, 3 > &  vector)
inlineexplicit

Construct from a vector.

Parameters
vectorVector to use for scale.

Definition at line 83 of file scale.hpp.

◆ Scale() [4/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( ScaleComponentType  x,
ScaleComponentType  y,
ScaleComponentType  z 
)
inline

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

Parameters
xX component.
yY component.
zZ component.

Definition at line 95 of file scale.hpp.

◆ Scale() [5/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( std::initializer_list< ScaleComponentType >  values)
inline

Construct from initializer list of three ScaleComponentType values.

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

Definition at line 106 of file scale.hpp.

◆ Scale() [6/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( const std::initializer_list< ScaleComponentType > &  value)
inline

Construct from a GLM vector.

Parameters
valueSource vector.

Definition at line 125 of file scale.hpp.

◆ Scale() [7/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( const Scale< ScaleComponentType > &  other)
default

Copy constructor.

Parameters
otherThe Scale object to copy from.

◆ Scale() [8/8]

template<CanBeScaleComponent ScaleComponentType>
utility::graphic::Scale< ScaleComponentType >::Scale ( Scale< ScaleComponentType > &&  other)
defaultnoexcept

Move constructor.

Parameters
otherThe Scale object to move from.

Member Function Documentation

◆ getX()

template<CanBeScaleComponent ScaleComponentType>
ScaleComponentType utility::graphic::Scale< ScaleComponentType >::getX ( void  ) const
inlinenoexcept

Get the X component of the scale.

Returns
The X value.

Definition at line 176 of file scale.hpp.

◆ getY()

template<CanBeScaleComponent ScaleComponentType>
ScaleComponentType utility::graphic::Scale< ScaleComponentType >::getY ( void  ) const
inlinenoexcept

Get the Y component of the scale.

Returns
The Y value.

Definition at line 196 of file scale.hpp.

◆ getZ()

template<CanBeScaleComponent ScaleComponentType>
ScaleComponentType utility::graphic::Scale< ScaleComponentType >::getZ ( void  ) const
inlinenoexcept

Get the Z component of the scale.

Returns
The Z value.

Definition at line 216 of file scale.hpp.

◆ hasNegativeComponent()

template<CanBeScaleComponent ScaleComponentType>
bool utility::graphic::Scale< ScaleComponentType >::hasNegativeComponent ( void  ) const
inlinenoexcept

Check whether any component is negative.

Returns
True if at least one component is below zero.

Definition at line 277 of file scale.hpp.

◆ isUniform()

template<CanBeScaleComponent ScaleComponentType>
bool utility::graphic::Scale< ScaleComponentType >::isUniform ( ScaleComponentType  epsilon = ScaleComponentType { 1e-6 }) const
inlinenoexcept

Check whether all scale components are approximately equal.

Parameters
epsilonAbsolute tolerance.
Returns
True if x~=y and y~=z.

Definition at line 266 of file scale.hpp.

◆ operator!=()

template<CanBeScaleComponent ScaleComponentType>
bool utility::graphic::Scale< ScaleComponentType >::operator!= ( const Scale< ScaleComponentType > &  other) const
inlinenoexcept

Inequality comparison.

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

Definition at line 308 of file scale.hpp.

◆ operator<()

template<CanBeScaleComponent ScaleComponentType>
bool utility::graphic::Scale< ScaleComponentType >::operator< ( const Scale< ScaleComponentType > &  other) const
inlinenoexcept

Less-than comparison for ordering.

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

Definition at line 318 of file scale.hpp.

◆ operator=() [1/2]

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::operator= ( const Scale< ScaleComponentType > &  other)
default

Copy assignment operator.

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

◆ operator=() [2/2]

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::operator= ( Scale< ScaleComponentType > &&  other)
defaultnoexcept

Move assignment operator.

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

◆ operator==()

template<CanBeScaleComponent ScaleComponentType>
bool utility::graphic::Scale< ScaleComponentType >::operator== ( const Scale< ScaleComponentType > &  other) const
inlinenoexcept

Equality comparison.

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

Definition at line 289 of file scale.hpp.

◆ scaleBy()

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::scaleBy ( const Scale< ScaleComponentType > &  factor)
inlinenoexcept

Scale this object by another scale (component-wise multiplication).

Parameters
factorScale factor to multiply by.
Returns
A reference to this Scale object for method chaining.

Definition at line 227 of file scale.hpp.

Here is the caller graph for this function:

◆ scaled()

template<CanBeScaleComponent ScaleComponentType>
Scale utility::graphic::Scale< ScaleComponentType >::scaled ( const Scale< ScaleComponentType > &  factor) const
inlinenoexcept

Return a scaled copy of this object (component-wise multiplication).

Parameters
factorScale factor to multiply by.
Returns
A new scaled Scale object.

Definition at line 241 of file scale.hpp.

Here is the call graph for this function:

◆ setUniform()

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::setUniform ( ScaleComponentType  value)
inlinenoexcept

Set all scale components to the same value.

Parameters
valueUniform scale value.
Returns
A reference to this Scale object for method chaining.

Definition at line 253 of file scale.hpp.

◆ setX()

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::setX ( const ScaleComponentType  value)
inlinenoexcept

Set the X component of the scale.

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

Definition at line 166 of file scale.hpp.

◆ setY()

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::setY ( const ScaleComponentType  value)
inlinenoexcept

Set the Y component of the scale.

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

Definition at line 186 of file scale.hpp.

◆ setZ()

template<CanBeScaleComponent ScaleComponentType>
Scale & utility::graphic::Scale< ScaleComponentType >::setZ ( const ScaleComponentType  value)
inlinenoexcept

Set the Z component of the scale.

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

Definition at line 206 of file scale.hpp.


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