Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::math::TVector2< T > Class Template Referencefinal

Represents a 2-D vector. More...

#include <TVector2.h>

Inheritance diagram for ph::math::TVector2< T >:
ph::math::TVectorNBase< TVector2< T >, T, 2 > ph::math::TArithmeticArrayBase< TVector2< T >, T, N >

Public Member Functions

 TVector2 ()=default
 
 TVector2 (const TVector2 &other)=default
 
 TVector2 (TVector2 &&other)=default
 
TVector2operator= (const TVector2 &rhs)=default
 
TVector2operator= (TVector2 &&rhs)=default
 
 ~TVector2 ()=default
 
 TVector2 (T vx, T vy)
 
template<typename U >
 TVector2 (const TVector2< U > &other)
 
template<typename U >
TVector2< U > losslessCast () const
 
T & x ()
 
T & y ()
 
const T & x () const
 
const T & y () const
 
T & u ()
 
T & v ()
 
const T & u () const
 
const T & v () const
 
- Public Member Functions inherited from ph::math::TVectorNBase< TVector2< T >, T, 2 >
dot (const TVector2< T > &rhs) const
 
dot (T rhs) const
 
absDot (const TVector2< T > &rhs) const
 
absDot (T rhs) const
 
length () const
 
lengthSquared () const
 
TVector2< T > safeNormalize (const TVector2< T > &fallback=TVector2< T >{}) const
 
std::size_t minDimension () const
 
std::size_t maxDimension () const
 
constexpr std::size_t size () const noexcept
 Number of elements of the array.
 
TVector2< T > add (const TVector2< T > &rhs) const
 
TVector2< T > add (T rhs) const
 
TVector2< T > & addLocal (const TVector2< T > &rhs)
 
TVector2< T > & addLocal (T rhs)
 
TVector2< T > sub (const TVector2< T > &rhs) const
 
TVector2< T > sub (T rhs) const
 
TVector2< T > & subLocal (const TVector2< T > &rhs)
 
TVector2< T > & subLocal (T rhs)
 
TVector2< T > mul (const TVector2< T > &rhs) const
 
TVector2< T > mul (T rhs) const
 
TVector2< T > & mulLocal (const TVector2< T > &rhs)
 
TVector2< T > & mulLocal (T rhs)
 
TVector2< T > div (const TVector2< T > &rhs) const
 
TVector2< T > div (T rhs) const
 
TVector2< T > & divLocal (const TVector2< T > &rhs)
 
TVector2< T > & divLocal (T rhs)
 
TVector2< T > pow (U exponent) const
 
TVector2< T > pow (const TVector2< T > &exponent) const
 
TVector2< T > & powLocal (U exponent)
 
TVector2< T > & powLocal (const TVector2< T > &exponent)
 
TVector2< T > exp (U exponent) const
 Sets the array to \( e^exponent \).
 
TVector2< T > exp (const TVector2< T > &exponent) const
 Sets the array to \( e^{exponent_i} \).
 
TVector2< T > & expLocal (U exponent)
 
TVector2< T > & expLocal (const TVector2< T > &exponent)
 
TVector2< T > sqrt () const
 
TVector2< T > & sqrtLocal ()
 
TVector2< T > clamp (T lowerBound, T upperBound) const
 Clamps current array's elements to specific range. None of value, lowerBound and upperBound can be NaN, or the method's behavior is undefined.
 
TVector2< T > clamp (const TVector2< T > &lowerBound, const TVector2< T > &upperBound) const
 
TVector2< T > & clampLocal (T lowerBound, T upperBound)
 
TVector2< T > & clampLocal (const TVector2< T > &lowerBound, const TVector2< T > &upperBound)
 
TVector2< T > safeClamp (T lowerBound, T upperBound) const
 Clamps current array's elements to specific range. If a floating-point value is non-finite (e.g., being Inf, NaN), its value is clamped to lowerBound. Neither lowerBound nor upperBound can be NaN, or the method's behavior is undefined.
 
TVector2< T > safeClamp (const TVector2< T > &lowerBound, const TVector2< T > &upperBound) const
 
TVector2< T > & safeClampLocal (T lowerBound, T upperBound)
 
TVector2< T > & safeClampLocal (const TVector2< T > &lowerBound, const TVector2< T > &upperBound)
 
TVector2< T > abs () const
 
TVector2< T > & absLocal ()
 
TVector2< T > rcp () const
 
TVector2< T > & rcpLocal ()
 
TVector2< T > complement () const
 Complements the array's elements. Effectively performing 1 - (*this)[i] for each element.
 
TVector2< T > & complementLocal ()
 
TVector2< T > negate () const
 Applies a negative sign to the array's elements. These methods is only defined for signed element types.
 
TVector2< T > & negateLocal ()
 
sum () const
 
avg () const
 
product () const
 
min () const
 
TVector2< T > min (const TVector2< T > &other) const
 
std::size_t minIndex () const
 
max () const
 
TVector2< T > max (const TVector2< T > &other) const
 
std::size_t maxIndex () const
 
TVector2< T > ceil () const
 
TVector2< T > floor () const
 
TVector2< T > lerp (const TVector2< T > &rhs, U factor) const
 
bool isZero () const
 
bool isNonNegative () const
 
bool isFinite () const
 
TVector2< T > & set (T value)
 
TVector2< T > & set (std::size_t index, T value)
 
TVector2< T > & set (const std::array< T, N > &values)
 
auto begin () noexcept -> typename std::array< T, N >::iterator
 
auto begin () const noexcept -> typename std::array< T, N >::const_iterator
 
auto end () noexcept -> typename std::array< T, N >::iterator
 
auto end () const noexcept -> typename std::array< T, N >::const_iterator
 
bool isEqual (const TVector2< T > &other) const
 
bool isNear (const TVector2< T > &other, T margin) const
 
std::string toString () const
 
std::vector< T > toVector () const
 
std::array< T, N > toArray () const
 
TSpan< T, N > toSpan ()
 
TSpanView< T, N > toView () const
 
TVector2< T > normalize () const
 Normalize the vector. Notice that normalizing a integer typed vector will result in 0-vector most of the time.
 
TVector2< T > & normalizeLocal ()
 
- Public Member Functions inherited from ph::math::TArithmeticArrayBase< TVector2< T >, T, N >
 TArithmeticArrayBase (T value)
 
 TArithmeticArrayBase (Elements values)
 
auto pow (const U exponent) const -> TVector2< T >
 
auto powLocal (const U exponent) -> TVector2< T > &
 
auto exp (const U exponent) const -> TVector2< T >
 
auto expLocal (const U exponent) -> TVector2< T > &
 
auto lerp (const TVector2< T > &rhs, const U factor) const -> TVector2< T >
 

Additional Inherited Members

- Public Types inherited from ph::math::TArithmeticArrayBase< TVector2< T >, T, N >
using Elements
 
- Static Public Attributes inherited from ph::math::TVectorNBase< TVector2< T >, T, 2 >
static constexpr auto NUM_ELEMENTS
 
- Protected Member Functions inherited from ph::math::TVectorNBase< TVector2< T >, T, 2 >
 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TVectorNBase)
 
- Protected Member Functions inherited from ph::math::TArithmeticArrayBase< TVector2< T >, T, N >
 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TArithmeticArrayBase)
 
constexpr std::size_t size () const noexcept
 Number of elements of the array.
 
TVector2< T > add (const TVector2< T > &rhs) const
 
TVector2< T > add (T rhs) const
 
TVector2< T > & addLocal (const TVector2< T > &rhs)
 
TVector2< T > & addLocal (T rhs)
 
TVector2< T > sub (const TVector2< T > &rhs) const
 
TVector2< T > sub (T rhs) const
 
TVector2< T > & subLocal (const TVector2< T > &rhs)
 
TVector2< T > & subLocal (T rhs)
 
TVector2< T > mul (const TVector2< T > &rhs) const
 
TVector2< T > mul (T rhs) const
 
TVector2< T > & mulLocal (const TVector2< T > &rhs)
 
TVector2< T > & mulLocal (T rhs)
 
TVector2< T > div (const TVector2< T > &rhs) const
 
TVector2< T > div (T rhs) const
 
TVector2< T > & divLocal (const TVector2< T > &rhs)
 
TVector2< T > & divLocal (T rhs)
 
TVector2< T > pow (U exponent) const
 
TVector2< T > pow (const TVector2< T > &exponent) const
 
TVector2< T > & powLocal (U exponent)
 
TVector2< T > & powLocal (const TVector2< T > &exponent)
 
TVector2< T > sqrt () const
 
TVector2< T > & sqrtLocal ()
 
TVector2< T > abs () const
 
TVector2< T > & absLocal ()
 
TVector2< T > rcp () const
 
TVector2< T > & rcpLocal ()
 
sum () const
 
avg () const
 
product () const
 
min () const
 
TVector2< T > min (const TVector2< T > &other) const
 
std::size_t minIndex () const
 
max () const
 
TVector2< T > max (const TVector2< T > &other) const
 
std::size_t maxIndex () const
 
TVector2< T > ceil () const
 
TVector2< T > floor () const
 
TVector2< T > lerp (const TVector2< T > &rhs, U factor) const
 
bool isZero () const
 
bool isNonNegative () const
 
bool isFinite () const
 
TVector2< T > & set (T value)
 
TVector2< T > & set (std::size_t index, T value)
 
TVector2< T > & set (const std::array< T, N > &values)
 
T & operator[] (std::size_t index)
 
const T & operator[] (std::size_t index) const
 
bool isEqual (const TVector2< T > &other) const
 
bool isNear (const TVector2< T > &other, T margin) const
 
bool operator== (const TVector2< T > &other) const
 
bool operator!= (const TVector2< T > &other) const
 
TVector2< T > operator+ (const TVector2< T > &rhs) const
 
TVector2< T > operator+ (T rhs) const
 
TVector2< T > operator- (const TVector2< T > &rhs) const
 
TVector2< T > operator- (T rhs) const
 
TVector2< T > operator- () const
 
TVector2< T > operator* (const TVector2< T > &rhs) const
 
TVector2< T > operator* (T rhs) const
 
TVector2< T > operator/ (const TVector2< T > &rhs) const
 
TVector2< T > operator/ (T rhs) const
 
TVector2< T > & operator+= (const TVector2< T > &rhs)
 
TVector2< T > & operator+= (T rhs)
 
TVector2< T > & operator-= (const TVector2< T > &rhs)
 
TVector2< T > & operator-= (T rhs)
 
TVector2< T > & operator*= (const TVector2< T > &rhs)
 
TVector2< T > & operator*= (T rhs)
 
TVector2< T > & operator/= (const TVector2< T > &rhs)
 
TVector2< T > & operator/= (T rhs)
 
auto begin () noexcept -> typename std::array< T, N >::iterator
 
auto begin () const noexcept -> typename std::array< T, N >::const_iterator
 
auto end () noexcept -> typename std::array< T, N >::iterator
 
auto end () const noexcept -> typename std::array< T, N >::const_iterator
 
std::string toString () const
 
std::vector< T > toVector () const
 
std::array< T, N > toArray () const
 
TSpan< T, N > toSpan ()
 
TSpanView< T, N > toView () const
 
TVector2< T > exp (U exponent) const
 Sets the array to \( e^exponent \).
 
TVector2< T > & expLocal (U exponent)
 
TVector2< T > exp (const TVector2< T > &exponent) const
 Sets the array to \( e^{exponent_i} \).
 
TVector2< T > & expLocal (const TVector2< T > &exponent)
 
TVector2< T > clamp (T lowerBound, T upperBound) const
 Clamps current array's elements to specific range. None of value, lowerBound and upperBound can be NaN, or the method's behavior is undefined.
 
TVector2< T > clamp (const TVector2< T > &lowerBound, const TVector2< T > &upperBound) const
 
TVector2< T > & clampLocal (T lowerBound, T upperBound)
 
TVector2< T > & clampLocal (const TVector2< T > &lowerBound, const TVector2< T > &upperBound)
 
TVector2< T > safeClamp (T lowerBound, T upperBound) const
 Clamps current array's elements to specific range. If a floating-point value is non-finite (e.g., being Inf, NaN), its value is clamped to lowerBound. Neither lowerBound nor upperBound can be NaN, or the method's behavior is undefined.
 
TVector2< T > safeClamp (const TVector2< T > &lowerBound, const TVector2< T > &upperBound) const
 
TVector2< T > & safeClampLocal (T lowerBound, T upperBound)
 
TVector2< T > & safeClampLocal (const TVector2< T > &lowerBound, const TVector2< T > &upperBound)
 
TVector2< T > complement () const
 Complements the array's elements. Effectively performing 1 - (*this)[i] for each element.
 
TVector2< T > & complementLocal ()
 
TVector2< T > negate () const
 Applies a negative sign to the array's elements. These methods is only defined for signed element types.
 
TVector2< T > & negateLocal ()
 
- Protected Attributes inherited from ph::math::TVectorNBase< TVector2< T >, T, 2 >
std::array< T, N > m
 
- Protected Attributes inherited from ph::math::TArithmeticArrayBase< TVector2< T >, T, N >
std::array< T, N > m
 
- Static Protected Attributes inherited from ph::math::TArithmeticArrayBase< TVector2< T >, T, N >
static constexpr auto NUM_ELEMENTS
 

Detailed Description

template<typename T>
class ph::math::TVector2< T >

Represents a 2-D vector.

Constructor & Destructor Documentation

◆ TVector2() [1/5]

template<typename T >
ph::math::TVector2< T >::TVector2 ( )
inlinedefault

◆ TVector2() [2/5]

template<typename T >
ph::math::TVector2< T >::TVector2 ( const TVector2< T > & other)
inlinedefault

◆ TVector2() [3/5]

template<typename T >
ph::math::TVector2< T >::TVector2 ( TVector2< T > && other)
inlinedefault

◆ ~TVector2()

template<typename T >
ph::math::TVector2< T >::~TVector2 ( )
inlinedefault

◆ TVector2() [4/5]

template<typename T >
ph::math::TVector2< T >::TVector2 ( T vx,
T vy )
inline

◆ TVector2() [5/5]

template<typename T >
template<typename U >
ph::math::TVector2< T >::TVector2 ( const TVector2< U > & other)
inlineexplicit

Member Function Documentation

◆ losslessCast()

template<typename T >
template<typename U >
TVector2< U > ph::math::TVector2< T >::losslessCast ( ) const
inline

◆ operator=() [1/2]

template<typename T >
TVector2 & ph::math::TVector2< T >::operator= ( const TVector2< T > & rhs)
inlinedefault

◆ operator=() [2/2]

template<typename T >
TVector2 & ph::math::TVector2< T >::operator= ( TVector2< T > && rhs)
inlinedefault

◆ u() [1/2]

template<typename T >
T & ph::math::TVector2< T >::u ( )
inline

◆ u() [2/2]

template<typename T >
const T & ph::math::TVector2< T >::u ( ) const
inline

◆ v() [1/2]

template<typename T >
T & ph::math::TVector2< T >::v ( )
inline

◆ v() [2/2]

template<typename T >
const T & ph::math::TVector2< T >::v ( ) const
inline

◆ x() [1/2]

template<typename T >
T & ph::math::TVector2< T >::x ( )
inline

◆ x() [2/2]

template<typename T >
const T & ph::math::TVector2< T >::x ( ) const
inline

◆ y() [1/2]

template<typename T >
T & ph::math::TVector2< T >::y ( )
inline

◆ y() [2/2]

template<typename T >
const T & ph::math::TVector2< T >::y ( ) const
inline

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