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

Represents a 4-D vector. More...

#include <TVector4.h>

Inheritance diagram for ph::math::TVector4< T >:
ph::math::TVectorNBase< TVector4< T >, T, 4 > ph::math::TArithmeticArrayBase< TVector4< T >, T, N >

Public Member Functions

 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TVector4)
 
 TVector4 (T vx, T vy, T vz, T vw)
 
template<typename U >
 TVector4 (const TVector4< U > &other)
 
T & x ()
 
T & y ()
 
T & z ()
 
T & w ()
 
const T & x () const
 
const T & y () const
 
const T & z () const
 
const T & w () const
 
T & r ()
 
T & g ()
 
T & b ()
 
T & a ()
 
const T & r () const
 
const T & g () const
 
const T & b () const
 
const T & a () const
 
- Public Member Functions inherited from ph::math::TVectorNBase< TVector4< T >, T, 4 >
dot (const TVector4< T > &rhs) const
 
dot (T rhs) const
 
absDot (const TVector4< T > &rhs) const
 
absDot (T rhs) const
 
length () const
 
lengthSquared () const
 
TVector4< T > safeNormalize (const TVector4< T > &fallback=TVector4< 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.
 
TVector4< T > add (const TVector4< T > &rhs) const
 
TVector4< T > add (T rhs) const
 
TVector4< T > & addLocal (const TVector4< T > &rhs)
 
TVector4< T > & addLocal (T rhs)
 
TVector4< T > sub (const TVector4< T > &rhs) const
 
TVector4< T > sub (T rhs) const
 
TVector4< T > & subLocal (const TVector4< T > &rhs)
 
TVector4< T > & subLocal (T rhs)
 
TVector4< T > mul (const TVector4< T > &rhs) const
 
TVector4< T > mul (T rhs) const
 
TVector4< T > & mulLocal (const TVector4< T > &rhs)
 
TVector4< T > & mulLocal (T rhs)
 
TVector4< T > div (const TVector4< T > &rhs) const
 
TVector4< T > div (T rhs) const
 
TVector4< T > & divLocal (const TVector4< T > &rhs)
 
TVector4< T > & divLocal (T rhs)
 
TVector4< T > pow (U exponent) const
 
TVector4< T > pow (const TVector4< T > &exponent) const
 
TVector4< T > & powLocal (U exponent)
 
TVector4< T > & powLocal (const TVector4< T > &exponent)
 
TVector4< T > exp (U exponent) const
 Sets the array to \( e^exponent \).
 
TVector4< T > exp (const TVector4< T > &exponent) const
 Sets the array to \( e^{exponent_i} \).
 
TVector4< T > & expLocal (U exponent)
 
TVector4< T > & expLocal (const TVector4< T > &exponent)
 
TVector4< T > sqrt () const
 
TVector4< T > & sqrtLocal ()
 
TVector4< 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.
 
TVector4< T > clamp (const TVector4< T > &lowerBound, const TVector4< T > &upperBound) const
 
TVector4< T > & clampLocal (T lowerBound, T upperBound)
 
TVector4< T > & clampLocal (const TVector4< T > &lowerBound, const TVector4< T > &upperBound)
 
TVector4< 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.
 
TVector4< T > safeClamp (const TVector4< T > &lowerBound, const TVector4< T > &upperBound) const
 
TVector4< T > & safeClampLocal (T lowerBound, T upperBound)
 
TVector4< T > & safeClampLocal (const TVector4< T > &lowerBound, const TVector4< T > &upperBound)
 
TVector4< T > abs () const
 
TVector4< T > & absLocal ()
 
TVector4< T > rcp () const
 
TVector4< T > & rcpLocal ()
 
TVector4< T > complement () const
 Complements the array's elements. Effectively performing 1 - (*this)[i] for each element.
 
TVector4< T > & complementLocal ()
 
TVector4< T > negate () const
 Applies a negative sign to the array's elements. These methods is only defined for signed element types.
 
TVector4< T > & negateLocal ()
 
sum () const
 
avg () const
 
product () const
 
min () const
 
TVector4< T > min (const TVector4< T > &other) const
 
std::size_t minIndex () const
 
max () const
 
TVector4< T > max (const TVector4< T > &other) const
 
std::size_t maxIndex () const
 
TVector4< T > ceil () const
 
TVector4< T > floor () const
 
TVector4< T > lerp (const TVector4< T > &rhs, U factor) const
 
bool isZero () const
 
bool isNonNegative () const
 
bool isFinite () const
 
TVector4< T > & set (T value)
 
TVector4< T > & set (std::size_t index, T value)
 
TVector4< 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 TVector4< T > &other) const
 
bool isNear (const TVector4< 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
 
TVector4< T > normalize () const
 Normalize the vector. Notice that normalizing a integer typed vector will result in 0-vector most of the time.
 
TVector4< T > & normalizeLocal ()
 
- Public Member Functions inherited from ph::math::TArithmeticArrayBase< TVector4< T >, T, N >
 TArithmeticArrayBase (T value)
 
 TArithmeticArrayBase (Elements values)
 
auto pow (const U exponent) const -> TVector4< T >
 
auto powLocal (const U exponent) -> TVector4< T > &
 
auto exp (const U exponent) const -> TVector4< T >
 
auto expLocal (const U exponent) -> TVector4< T > &
 
auto lerp (const TVector4< T > &rhs, const U factor) const -> TVector4< T >
 

Additional Inherited Members

- Public Types inherited from ph::math::TArithmeticArrayBase< TVector4< T >, T, N >
using Elements
 
- Static Public Attributes inherited from ph::math::TVectorNBase< TVector4< T >, T, 4 >
static constexpr auto NUM_ELEMENTS
 
- Protected Member Functions inherited from ph::math::TVectorNBase< TVector4< T >, T, 4 >
 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TVectorNBase)
 
- Protected Member Functions inherited from ph::math::TArithmeticArrayBase< TVector4< T >, T, N >
 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TArithmeticArrayBase)
 
constexpr std::size_t size () const noexcept
 Number of elements of the array.
 
TVector4< T > add (const TVector4< T > &rhs) const
 
TVector4< T > add (T rhs) const
 
TVector4< T > & addLocal (const TVector4< T > &rhs)
 
TVector4< T > & addLocal (T rhs)
 
TVector4< T > sub (const TVector4< T > &rhs) const
 
TVector4< T > sub (T rhs) const
 
TVector4< T > & subLocal (const TVector4< T > &rhs)
 
TVector4< T > & subLocal (T rhs)
 
TVector4< T > mul (const TVector4< T > &rhs) const
 
TVector4< T > mul (T rhs) const
 
TVector4< T > & mulLocal (const TVector4< T > &rhs)
 
TVector4< T > & mulLocal (T rhs)
 
TVector4< T > div (const TVector4< T > &rhs) const
 
TVector4< T > div (T rhs) const
 
TVector4< T > & divLocal (const TVector4< T > &rhs)
 
TVector4< T > & divLocal (T rhs)
 
TVector4< T > pow (U exponent) const
 
TVector4< T > pow (const TVector4< T > &exponent) const
 
TVector4< T > & powLocal (U exponent)
 
TVector4< T > & powLocal (const TVector4< T > &exponent)
 
TVector4< T > sqrt () const
 
TVector4< T > & sqrtLocal ()
 
TVector4< T > abs () const
 
TVector4< T > & absLocal ()
 
TVector4< T > rcp () const
 
TVector4< T > & rcpLocal ()
 
sum () const
 
avg () const
 
product () const
 
min () const
 
TVector4< T > min (const TVector4< T > &other) const
 
std::size_t minIndex () const
 
max () const
 
TVector4< T > max (const TVector4< T > &other) const
 
std::size_t maxIndex () const
 
TVector4< T > ceil () const
 
TVector4< T > floor () const
 
TVector4< T > lerp (const TVector4< T > &rhs, U factor) const
 
bool isZero () const
 
bool isNonNegative () const
 
bool isFinite () const
 
TVector4< T > & set (T value)
 
TVector4< T > & set (std::size_t index, T value)
 
TVector4< 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 TVector4< T > &other) const
 
bool isNear (const TVector4< T > &other, T margin) const
 
bool operator== (const TVector4< T > &other) const
 
bool operator!= (const TVector4< T > &other) const
 
TVector4< T > operator+ (const TVector4< T > &rhs) const
 
TVector4< T > operator+ (T rhs) const
 
TVector4< T > operator- (const TVector4< T > &rhs) const
 
TVector4< T > operator- (T rhs) const
 
TVector4< T > operator- () const
 
TVector4< T > operator* (const TVector4< T > &rhs) const
 
TVector4< T > operator* (T rhs) const
 
TVector4< T > operator/ (const TVector4< T > &rhs) const
 
TVector4< T > operator/ (T rhs) const
 
TVector4< T > & operator+= (const TVector4< T > &rhs)
 
TVector4< T > & operator+= (T rhs)
 
TVector4< T > & operator-= (const TVector4< T > &rhs)
 
TVector4< T > & operator-= (T rhs)
 
TVector4< T > & operator*= (const TVector4< T > &rhs)
 
TVector4< T > & operator*= (T rhs)
 
TVector4< T > & operator/= (const TVector4< T > &rhs)
 
TVector4< 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
 
TVector4< T > exp (U exponent) const
 Sets the array to \( e^exponent \).
 
TVector4< T > & expLocal (U exponent)
 
TVector4< T > exp (const TVector4< T > &exponent) const
 Sets the array to \( e^{exponent_i} \).
 
TVector4< T > & expLocal (const TVector4< T > &exponent)
 
TVector4< 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.
 
TVector4< T > clamp (const TVector4< T > &lowerBound, const TVector4< T > &upperBound) const
 
TVector4< T > & clampLocal (T lowerBound, T upperBound)
 
TVector4< T > & clampLocal (const TVector4< T > &lowerBound, const TVector4< T > &upperBound)
 
TVector4< 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.
 
TVector4< T > safeClamp (const TVector4< T > &lowerBound, const TVector4< T > &upperBound) const
 
TVector4< T > & safeClampLocal (T lowerBound, T upperBound)
 
TVector4< T > & safeClampLocal (const TVector4< T > &lowerBound, const TVector4< T > &upperBound)
 
TVector4< T > complement () const
 Complements the array's elements. Effectively performing 1 - (*this)[i] for each element.
 
TVector4< T > & complementLocal ()
 
TVector4< T > negate () const
 Applies a negative sign to the array's elements. These methods is only defined for signed element types.
 
TVector4< T > & negateLocal ()
 
- Protected Attributes inherited from ph::math::TVectorNBase< TVector4< T >, T, 4 >
std::array< T, N > m
 
- Protected Attributes inherited from ph::math::TArithmeticArrayBase< TVector4< T >, T, N >
std::array< T, N > m
 
- Static Protected Attributes inherited from ph::math::TArithmeticArrayBase< TVector4< T >, T, N >
static constexpr auto NUM_ELEMENTS
 

Detailed Description

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

Represents a 4-D vector.

Constructor & Destructor Documentation

◆ TVector4() [1/2]

template<typename T >
ph::math::TVector4< T >::TVector4 ( T vx,
T vy,
T vz,
T vw )
inline

◆ TVector4() [2/2]

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

Member Function Documentation

◆ a() [1/2]

template<typename T >
T & ph::math::TVector4< T >::a ( )
inline

◆ a() [2/2]

template<typename T >
const T & ph::math::TVector4< T >::a ( ) const
inline

◆ b() [1/2]

template<typename T >
T & ph::math::TVector4< T >::b ( )
inline

◆ b() [2/2]

template<typename T >
const T & ph::math::TVector4< T >::b ( ) const
inline

◆ g() [1/2]

template<typename T >
T & ph::math::TVector4< T >::g ( )
inline

◆ g() [2/2]

template<typename T >
const T & ph::math::TVector4< T >::g ( ) const
inline

◆ PH_DEFINE_INLINE_RULE_OF_5_MEMBERS()

template<typename T >
ph::math::TVector4< T >::PH_DEFINE_INLINE_RULE_OF_5_MEMBERS ( TVector4< T > )

◆ r() [1/2]

template<typename T >
T & ph::math::TVector4< T >::r ( )
inline

◆ r() [2/2]

template<typename T >
const T & ph::math::TVector4< T >::r ( ) const
inline

◆ w() [1/2]

template<typename T >
T & ph::math::TVector4< T >::w ( )
inline

◆ w() [2/2]

template<typename T >
const T & ph::math::TVector4< T >::w ( ) const
inline

◆ x() [1/2]

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

◆ x() [2/2]

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

◆ y() [1/2]

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

◆ y() [2/2]

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

◆ z() [1/2]

template<typename T >
T & ph::math::TVector4< T >::z ( )
inline

◆ z() [2/2]

template<typename T >
const T & ph::math::TVector4< T >::z ( ) const
inline

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