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

Represents a 3-D vector. More...

#include <TVector3.h>

Inheritance diagram for ph::math::TVector3< T >:
ph::math::TVectorNBase< TVector3< T >, T, 3 > ph::math::TArithmeticArrayBase< TVector3< T >, T, N >

Public Member Functions

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

Static Public Member Functions

static TVector3 weightedSum (const TVector3 &vA, T wA, const TVector3 &vB, T wB, const TVector3 &vC, T wC)
 
static TVector3 lerp (const TVector3 &vA, const TVector3 &vB, T parametricT)
 

Additional Inherited Members

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

Detailed Description

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

Represents a 3-D vector.

Constructor & Destructor Documentation

◆ TVector3() [1/2]

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

◆ TVector3() [2/2]

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

Member Function Documentation

◆ b() [1/2]

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

◆ b() [2/2]

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

◆ cross() [1/2]

template<typename T >
TVector3< T > ph::math::TVector3< T >::cross ( const TVector3< T > & rhs) const
inline

◆ cross() [2/2]

template<typename T >
void ph::math::TVector3< T >::cross ( const TVector3< T > & rhs,
TVector3< T > * out_result ) const
inline

◆ g() [1/2]

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

◆ g() [2/2]

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

◆ lerp()

template<typename T >
TVector3< T > ph::math::TVector3< T >::lerp ( const TVector3< T > & vA,
const TVector3< T > & vB,
T parametricT )
inlinestatic

◆ maddLocal()

template<typename T >
TVector3< T > & ph::math::TVector3< T >::maddLocal ( T multiplier,
const TVector3< T > & adder )
inline

◆ PH_DEFINE_INLINE_RULE_OF_5_MEMBERS()

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

◆ r() [1/2]

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

◆ r() [2/2]

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

◆ reflect()

template<typename T >
TVector3< T > ph::math::TVector3< T >::reflect ( const TVector3< T > & normal) const
inline

◆ reflectLocal()

template<typename T >
TVector3< T > & ph::math::TVector3< T >::reflectLocal ( const TVector3< T > & normal)
inline

◆ rotate() [1/2]

template<typename T >
TVector3< T > ph::math::TVector3< T >::rotate ( const TQuaternion< T > & rotation) const
inline

◆ rotate() [2/2]

template<typename T >
void ph::math::TVector3< T >::rotate ( const TQuaternion< T > & rotation,
TVector3< T > * out_result ) const
inline

◆ sort()

template<typename T >
void ph::math::TVector3< T >::sort ( TVector3< T > * out_result) const
inline
Parameters
out_resultThe sorted values, (x, y, z) = (min, mid, max).

◆ weightedSum()

template<typename T >
TVector3< T > ph::math::TVector3< T >::weightedSum ( const TVector3< T > & vA,
T wA,
const TVector3< T > & vB,
T wB,
const TVector3< T > & vC,
T wC )
inlinestatic

◆ x() [1/2]

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

◆ x() [2/2]

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

◆ y() [1/2]

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

◆ y() [2/2]

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

◆ z() [1/2]

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

◆ z() [2/2]

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

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