Col3< T, STRIDE > Struct Template Reference

#include <vector.h>

Detailed Description

template<typename T, Int STRIDE = 1>
struct maxon::Col3< T, STRIDE >

A color consisting of three components R, G and B.

Public Types

template<typename U >
using Rebind = Col3< U, STRIDE >
 
using VectorStrideType = std::integral_constant< Int, STRIDE >
 
using ValueType = T
 
using ValueTypeParam = typename ByValueParam< T >::type
 
using Unstrided = Col3< T, 1 >
 
using BoolType = decltype(T()==T())
 

Public Member Functions

 Col3 ()
 
 Col3 (ValueTypeParam in)
 
 Col3 (ValueTypeParam ix, ValueTypeParam iy, ValueTypeParam iz)
 
template<typename T2 , Int S2>
 Col3 (const Col3< T2, S2 > &v)
 
template<typename T2 , Int S2>
 Col3 (const Vec3< T2, S2 > &v)
 
template<typename T2 , Int S2>
 Col3 (const Col4< T2, S2 > &v)
 
template<Int S2>
 Col3 (const Col3< T, S2 > &v)
 
 Col3 (ENUM_DONT_INITIALIZE v)
 
MAXON_IMPLICIT Col3 (const typename std::conditional< STRIDE==1, DummyParamType, Col3 >::type &src)
 
Col3operator= (const typename std::conditional< STRIDE==1, DummyParamType, Col3 >::type &src)
 
T & operator[] (Int l)
 
ValueTypeParam operator[] (Int l) const
 
template<typename T2 , Int S2>
Col3operator+= (const Col3< T2, S2 > &v)
 
Col3operator+= (const Col3 &v)
 
template<typename T2 , Int S2>
Col3operator-= (const Col3< T2, S2 > &v)
 
Col3operator-= (const Col3 &v)
 
template<typename T2 , Int S2>
Col3operator*= (const Col3< T2, S2 > &v)
 
Col3operator*= (const Col3 &v)
 
Col3operator*= (ValueTypeParam s)
 
Col3operator/= (ValueTypeParam s)
 
Unstrided operator* (ValueTypeParam s) const
 
template<typename S >
Col3< typename MultiplicativePromotion< T, S, std::is_scalar< S >::value >::type, 1 > operator* (S s) const
 
Unstrided operator/ (ValueTypeParam s) const
 
Unstrided operator* (const Col3 &v) const
 
Unstrided operator+ (const Col3 &v) const
 
Unstrided operator- (const Col3 &v) const
 
Unstrided operator- () const
 
template<typename T2 , Int S2>
BoolType operator== (const Col3< T2, S2 > &v) const
 
BoolType operator== (const Col3 &v) const
 
template<typename T2 , Int S2>
BoolType operator!= (const Col3< T2, S2 > &v) const
 
BoolType operator!= (const Col3 &v) const
 
UInt GetHashCode () const
 
BoolType IsEqual (const Col3 &other, ValueTypeParam epsilon) const
 
BoolType IsZero () const
 
void SetZero ()
 
GetAverage () const
 
GetSum () const
 
void ClampMin (const Col3 &other=Col3())
 
void ClampMax (const Col3 &other)
 
Unstrided Clamp01 () const
 
String ToString (const FormatStatement *formatStatement) const
 
const Vec3< T, STRIDE > & GetVector () const
 
Vec3< T, STRIDE > & GetVector ()
 
GetMin () const
 
GetMax () const
 
Unstrided GetRightRotated (Int rots) const
 
template<typename T2 >
Col3operator*= (const Mat3< T2 > &m)
 

Static Public Member Functions

static const Col3NullValue ()
 

Public Attributes

union {
   T   r
 
   T   _xpadding [STRIDE]
 
}; 
 
union {
   T   g
 
   T   _ypadding [STRIDE]
 
}; 
 
union {
   T   b
 
   T   _zpadding [STRIDE]
 
}; 
 

Friends

Unstrided operator* (ValueTypeParam s, const Col3 &v)
 
Unstrided Abs (const Col3 &v1)
 
Unstrided Min (const Col3 &a, const Col3 &other)
 
Unstrided Max (const Col3 &a, const Col3 &other)
 
void SetMin (Col3 &a, const Col3 &other)
 
void SetMax (Col3 &a, const Col3 &other)
 

Member Typedef Documentation

◆ Rebind

using Rebind = Col3<U, STRIDE>

◆ VectorStrideType

using VectorStrideType = std::integral_constant<Int, STRIDE>

◆ ValueType

using ValueType = T

◆ ValueTypeParam

using ValueTypeParam = typename ByValueParam<T>::type

◆ Unstrided

using Unstrided = Col3<T, 1>

◆ BoolType

using BoolType = decltype(T() == T())

The type returned by comparisons. If the template argument for T is a SIMD type, this will be a SIMD type, too, which contains the per-element results.

Constructor & Destructor Documentation

◆ Col3() [1/9]

Col3 ( )

Initializes all vector components with 0.0.

◆ Col3() [2/9]

Col3 ( ValueTypeParam  in)
explicit

Initializes all vector components with a scalar.

◆ Col3() [3/9]

Col3 ( ValueTypeParam  ix,
ValueTypeParam  iy,
ValueTypeParam  iz 
)
explicit

Initializes all vector components individually.

◆ Col3() [4/9]

Col3 ( const Col3< T2, S2 > &  v)
explicit

Initializes components from another 3d vector.

◆ Col3() [5/9]

Col3 ( const Vec3< T2, S2 > &  v)
explicit

◆ Col3() [6/9]

Col3 ( const Col4< T2, S2 > &  v)
explicit

◆ Col3() [7/9]

Col3 ( const Col3< T, S2 > &  v)

◆ Col3() [8/9]

Col3 ( ENUM_DONT_INITIALIZE  v)
explicit

Skips initialization of vector (for better speed)

◆ Col3() [9/9]

MAXON_IMPLICIT Col3 ( const typename std::conditional< STRIDE==1, DummyParamType, Col3< T, STRIDE > >::type &  src)

Member Function Documentation

◆ operator=()

Col3& operator= ( const typename std::conditional< STRIDE==1, DummyParamType, Col3< T, STRIDE > >::type &  src)

◆ operator[]() [1/2]

T& operator[] ( Int  l)

Accesses vector component: index 0 is 'r', index 1 is 'g', index 2 is 'b'. All other values must not be used and will crash.

◆ operator[]() [2/2]

ValueTypeParam operator[] ( Int  l) const

Accesses vector component: index 0 is 'r', index 1 is 'g', index 2 is 'b'. All other values must not be used and will crash.

◆ operator+=() [1/2]

Col3& operator+= ( const Col3< T2, S2 > &  v)

Adds two vectors.

◆ operator+=() [2/2]

Col3& operator+= ( const Col3< T, STRIDE > &  v)

◆ operator-=() [1/2]

Col3& operator-= ( const Col3< T2, S2 > &  v)

Subtracts two vectors.

◆ operator-=() [2/2]

Col3& operator-= ( const Col3< T, STRIDE > &  v)

◆ operator*=() [1/4]

Col3& operator*= ( const Col3< T2, S2 > &  v)

Multiplies two vectors component-wise.

◆ operator*=() [2/4]

Col3& operator*= ( const Col3< T, STRIDE > &  v)

◆ operator*=() [3/4]

Col3& operator*= ( ValueTypeParam  s)

Multiplies each vector component by a scalar.

◆ operator/=()

Col3& operator/= ( ValueTypeParam  s)

Divides each vector component by a scalar. The passed argument is checked for 0.0.

◆ operator*() [1/3]

Unstrided operator* ( ValueTypeParam  s) const

Multiplies each vector component by a scalar.

◆ operator*() [2/3]

Col3<typename MultiplicativePromotion<T, S, std::is_scalar<S>::value>::type, 1> operator* ( s) const

Multiplies each vector component by a scalar.

◆ operator/()

Unstrided operator/ ( ValueTypeParam  s) const

Divides each vector component by a scalar. The scalar value is tested for 0.0.

◆ operator*() [3/3]

Unstrided operator* ( const Col3< T, STRIDE > &  v) const

Multiplies two vectors component-wise.

◆ operator+()

Unstrided operator+ ( const Col3< T, STRIDE > &  v) const

Adds two vectors.

◆ operator-() [1/2]

Unstrided operator- ( const Col3< T, STRIDE > &  v) const

Subtracts vector v2 from v1.

◆ operator-() [2/2]

Unstrided operator- ( ) const

Negates vector v.

◆ operator==() [1/2]

BoolType operator== ( const Col3< T2, S2 > &  v) const

◆ operator==() [2/2]

BoolType operator== ( const Col3< T, STRIDE > &  v) const

◆ operator!=() [1/2]

BoolType operator!= ( const Col3< T2, S2 > &  v) const

◆ operator!=() [2/2]

BoolType operator!= ( const Col3< T, STRIDE > &  v) const

◆ GetHashCode()

UInt GetHashCode ( ) const

◆ IsEqual()

BoolType IsEqual ( const Col3< T, STRIDE > &  other,
ValueTypeParam  epsilon 
) const

Tests component-wise if the difference is no bigger than 'epsilon'.

◆ IsZero()

BoolType IsZero ( ) const

Checks if each component is zero.

◆ SetZero()

void SetZero ( )

Sets all components to zero.

◆ GetAverage()

T GetAverage ( ) const

Calculates the average value of 'r', 'g' and 'b'.

◆ GetSum()

T GetSum ( ) const

Calculates the sum of 'r', 'g' and 'b'.

◆ ClampMin()

void ClampMin ( const Col3< T, STRIDE > &  other = Col3< T, STRIDE >())

Set the minimum of each component.

◆ ClampMax()

void ClampMax ( const Col3< T, STRIDE > &  other)

Set the maximum of each component.

◆ Clamp01()

Unstrided Clamp01 ( ) const

Returns a vector that is clamped to the range [0.0 .. 1.0].

◆ ToString()

String ToString ( const FormatStatement formatStatement) const

Returns a readable string of the content.

Parameters
[in]formatStatementNullptr or additional formatting instruction. See also format_float.
Returns
The converted result.

◆ GetVector() [1/2]

const Vec3<T, STRIDE>& GetVector ( void  ) const

Reinterprets the color as vector.

◆ GetVector() [2/2]

Vec3<T, STRIDE>& GetVector ( void  )

◆ GetMin()

T GetMin ( void  ) const

Returns the minimum of 'r', 'g' and 'b'.

◆ GetMax()

T GetMax ( void  ) const

Returns the maximum of 'r', 'g' and 'b'.

◆ GetRightRotated()

Unstrided GetRightRotated ( Int  rots) const

Returns a vector where the components have been rotated to the right (in the usual (r, g, b)-representation). E.g., with a value of 1 for rots, the result will be (b, r, g).

Parameters
[in]rotsNumber of rotations, may be negative. The result depends only on the number modulo 3.
Returns
Vector with rotated components.

◆ operator*=() [4/4]

Col3& operator*= ( const Mat3< T2 > &  m)

Transforms color by a matrix.

◆ NullValue()

static const Col3& NullValue ( )
static

Friends And Related Function Documentation

◆ operator*

Unstrided operator* ( ValueTypeParam  s,
const Col3< T, STRIDE > &  v 
)
friend

Multiplies each vector component by a scalar.

◆ Abs

Unstrided Abs ( const Col3< T, STRIDE > &  v1)
friend

returns the vector with absolute value for each entry

Parameters
[in]v1input vector to work on
Returns
component wise absolute value vector of input vector

◆ Min

Unstrided Min ( const Col3< T, STRIDE > &  a,
const Col3< T, STRIDE > &  other 
)
friend

Calculates the minimum of each component.

◆ Max

Unstrided Max ( const Col3< T, STRIDE > &  a,
const Col3< T, STRIDE > &  other 
)
friend

Calculates the maximum of each component.

◆ SetMin

void SetMin ( Col3< T, STRIDE > &  a,
const Col3< T, STRIDE > &  other 
)
friend

Set the minimum of each component.

◆ SetMax

void SetMax ( Col3< T, STRIDE > &  a,
const Col3< T, STRIDE > &  other 
)
friend

Set the maximum of each component.

Member Data Documentation

◆ r

T r

◆ _xpadding

T _xpadding[STRIDE]

◆ @1057

union { ... }

◆ g

T g

◆ _ypadding

T _ypadding[STRIDE]

◆ @1059

union { ... }

◆ b

T b

◆ _zpadding

T _zpadding[STRIDE]

◆ @1061

union { ... }