-
首页
-
C4D R23.110 C++ SDK
#include <vector.h>
详细描述
template<typename T, Int STRIDE = 1>
struct maxon::Vec4< T, STRIDE >
A vector consisting of four components X, Y, Z and W.
公共成员函数
|
constexpr
|
Vec4
()
|
constexpr
|
Vec4
(
ValueTypeParam
in)
|
constexpr
|
Vec4
(
ValueTypeParam
ix,
ValueTypeParam
iy,
ValueTypeParam
iz,
ValueTypeParam
iw)
|
template<typename T2 , Int S2>
|
constexpr
|
Vec4
(const
Vec4
< T2, S2 > &v)
|
template<typename T2 , Int S2>
|
constexpr
|
Vec4
(const
Col4
< T2, S2 > &v)
|
template<Int S2>
|
constexpr
|
Vec4
(const
Vec4
< T, S2 > &v)
|
template<typename T2 , Int S2>
|
constexpr
|
Vec4
(const
Vec3
< T2, S2 > &v, T iw=T(1))
|
constexpr
|
Vec4
(
ENUM_DONT_INITIALIZE
v)
|
constexpr const
Col4
< T,
STRIDE
> &
|
GetColor
() const
|
constexpr
Col4
< T,
STRIDE
> &
|
GetColor
()
|
constexpr const
Vec3
< T,
STRIDE
> &
|
GetVector3
() const
|
constexpr
MAXON_IMPLICIT
|
Vec4
(const typename std::conditional<
STRIDE
==1, DummyParamType,
Vec4
>::type &
src
)
|
constexpr
Vec4
&
|
operator=
(const typename std::conditional<
STRIDE
==1, DummyParamType,
Vec4
>::type &
src
)
|
T &
|
operator[]
(
Int
l)
|
ValueTypeParam
|
operator[]
(
Int
l) const
|
template<typename T2 , Int S2>
|
constexpr
Vec4
&
|
operator+=
(const
Vec4
< T2, S2 > &v)
|
constexpr
Vec4
&
|
operator+=
(const
Vec4
&v)
|
template<typename T2 , Int S2>
|
constexpr
Vec4
&
|
operator-=
(const
Vec4
< T2, S2 > &v)
|
constexpr
Vec4
&
|
operator-=
(const
Vec4
&v)
|
template<typename T2 , Int S2>
|
constexpr
Vec4
&
|
operator*=
(const
Vec4
< T2, S2 > &v)
|
constexpr
Vec4
&
|
operator*=
(const
Vec4
&v)
|
constexpr
Vec4
&
|
operator*=
(
ValueTypeParam
s)
|
constexpr
Vec4
&
|
operator/=
(
ValueTypeParam
s)
|
constexpr
Unstrided
|
operator*
(
ValueTypeParam
s) const
|
template<typename S >
|
constexpr
Vec4
< typename
MultiplicativePromotion
< T, S,
STD_IS_REPLACEMENT
(scalar, S)>::type, 1 >
|
operator*
(S s) const
|
constexpr
Unstrided
|
operator/
(
ValueTypeParam
s) const
|
constexpr
Unstrided
|
operator*
(const
Vec4
&v) const
|
constexpr
Unstrided
|
operator+
(const
Vec4
&v) const
|
constexpr
Unstrided
|
operator-
(const
Vec4
&v) const
|
constexpr
Unstrided
|
operator-
() const
|
template<typename T2 , Int S2>
|
constexpr
BoolType
|
operator==
(const
Vec4
< T2, S2 > &v) const
|
constexpr
BoolType
|
operator==
(const
Vec4
&v) const
|
template<typename T2 , Int S2>
|
constexpr
BoolType
|
operator!=
(const
Vec4
< T2, S2 > &v) const
|
constexpr
BoolType
|
operator!=
(const
Vec4
&v) const
|
constexpr
BoolType
|
LessThanOrEqual
(const
Vec4
&v) const
|
constexpr
HashInt
|
GetHashCode
() const
|
constexpr
BoolType
|
IsEqual
(const
Vec4
&other,
ValueTypeParam
epsilon) const
|
constexpr
BoolType
|
IsZero
() const
|
constexpr void
|
SetZero
()
|
constexpr T
|
GetAverage
() const
|
constexpr T
|
GetSum
() const
|
constexpr void
|
ClampMin
(const
Vec4
&other=
Vec4
())
|
constexpr void
|
ClampMax
(const
Vec4
&other)
|
constexpr
Unstrided
|
Clamp01
() const
|
constexpr T
|
GetLength
() const
|
constexpr T
|
GetSquaredLength
() const
|
constexpr
Unstrided
|
GetNormalized
() const
|
constexpr
Unstrided
|
operator!
() const
|
constexpr void
|
Normalize
()
|
String
|
ToString
(const
FormatStatement
*formatStatement=nullptr) const
|
constexpr T
|
GetMin
() const
|
constexpr T
|
GetMax
() const
|
constexpr
Vec4
|
GetRightRotated
(
Int
rots) const
|
constexpr void
|
NormalizeW
()
|
template<typename V >
|
constexpr
Vec4
&
|
operator*=
(const
SqrMat4
< V > &m)
|
Friends
|
constexpr friend
Unstrided
|
operator*
(
ValueTypeParam
s, const
Vec4
&v)
|
constexpr friend T
|
Dot
(const
Vec4
&v1, const
Vec4
&v2)
|
constexpr friend
Unstrided
|
Abs
(const
Vec4
&v1)
|
template<typename T2 , Int S2>
|
constexpr friend
MultiplicativePromotion
< T, T2 >::type
|
Dot
(const
Vec4
&v1, const
Vec4
< T2, S2 > &v2)
|
constexpr friend
Unstrided
|
最小
(const
Vec4
&a, const
Vec4
&other)
|
constexpr friend
Unstrided
|
最大
(const
Vec4
&a, const
Vec4
&other)
|
constexpr friend void
|
SetMin
(
Vec4
&a, const
Vec4
&other)
|
constexpr friend void
|
SetMax
(
Vec4
&a, const
Vec4
&other)
|
constexpr friend T
|
GetAngle
(const
Vec4
&v1, const
Vec4
&v2)
|
Member Typedef Documentation
◆
Rebind
◆
VectorStrideType
◆
ValueType
◆
ValueTypeParam
◆
Unstrided
◆
BoolType
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.
构造函数 & 析构函数文档编制
◆
Vec4()
[1/9]
Initializes all vector components with 0.0.
◆
Vec4()
[2/9]
Initializes all vector components with a scalar.
◆
Vec4()
[3/9]
Initializes all vector components individually.
◆
Vec4()
[4/9]
constexpr
Vec4
|
(
|
const
Vec4
< T2, S2 > &
|
v
|
)
|
|
|
explicit
constexpr
|
Initializes components from another 4d vector.
◆
Vec4()
[5/9]
constexpr
Vec4
|
(
|
const
Col4
< T2, S2 > &
|
v
|
)
|
|
|
explicit
constexpr
|
Initializes components from another 4d vector.
◆
Vec4()
[6/9]
constexpr
Vec4
|
(
|
const
Vec4
< T, S2 > &
|
v
|
)
|
|
|
constexpr
|
Initializes components from another 4d vector.
◆
Vec4()
[7/9]
constexpr
Vec4
|
(
|
const
Vec3
< T2, S2 > &
|
v
,
|
|
|
T
|
iw
=
T(1)
|
|
)
|
|
|
|
explicit
constexpr
|
Initializes components from a 3d vector and add an additional value for the w-component. The default value for w is 1.0.
◆
Vec4()
[8/9]
Skips initialization of vector (for better speed)
◆
Vec4()
[9/9]
When STRIDE is not 1, we have to provide copy constructor and operator because the default ones would also copy the padding. When STRIDE is 1, we want to avoid to declare them (because then the type wouldn't be trivially copyable any longer), so we use DummyParamType for the parameter in that case.
成员函数文档编制
◆
GetColor()
[1/2]
constexpr const
Col4
<T,
STRIDE
>& GetColor
|
(
|
|
)
|
const
|
|
constexpr
|
Reinterprets the vector as color.
◆
GetColor()
[2/2]
Reinterprets the vector as color.
◆
GetVector3()
constexpr const
Vec3
<T,
STRIDE
>& GetVector3
|
(
|
|
)
|
const
|
|
constexpr
|
Gets the x/y/z components without w.
◆
operator=()
constexpr
Vec4
& operator=
|
(
|
const typename std::conditional<
STRIDE
==1, DummyParamType,
Vec4
< T,
STRIDE
> >::type &
|
src
|
)
|
|
|
constexpr
|
Copies the source vector.
-
参数
-
-
返回
-
*this.
◆
operator[]()
[1/2]
Accesses vector component: index 0 is 'x', index 1 is 'y', index 2 is 'z'. All other values must not be used and will crash.
◆
operator[]()
[2/2]
Accesses vector component: index 0 is 'x', index 1 is 'y', index 2 is 'z'. All other values must not be used and will crash.
◆
operator+=()
[1/2]
constexpr
Vec4
& operator+=
|
(
|
const
Vec4
< T2, S2 > &
|
v
|
)
|
|
|
constexpr
|
Adds two vectors.
◆
operator+=()
[2/2]
Adds a vector. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector.
-
参数
-
[in]
|
v
|
Vector to be added.
|
-
返回
-
*this.
◆
operator-=()
[1/2]
constexpr
Vec4
& operator-=
|
(
|
const
Vec4
< T2, S2 > &
|
v
|
)
|
|
|
constexpr
|
Subtracts two vectors.
◆
operator-=()
[2/2]
Subtracts a vector. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector.
-
参数
-
[in]
|
v
|
Vector to be substracted from this.
|
-
返回
-
*this.
◆
operator*=()
[1/4]
constexpr
Vec4
& operator*=
|
(
|
const
Vec4
< T2, S2 > &
|
v
|
)
|
|
|
constexpr
|
Multiplies two vectors component-wise.
◆
operator*=()
[2/4]
Multiplies with vector component-wise. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector.
-
参数
-
[in]
|
v
|
Vector to be multiplied with.
|
-
返回
-
*this.
◆
operator*=()
[3/4]
Multiplies each vector component by a scalar.
◆
operator/=()
Divides each vector component by a scalar. The passed argument is checked for 0.0.
◆
operator*()
[1/3]
Multiplies each vector component by a scalar.
◆
operator*()
[2/3]
Multiplies each vector component by a scalar.
◆
operator/()
Divides each vector component by a scalar. The scalar value is tested for 0.0.
◆
operator*()
[3/3]
Multiplies two vectors component-wise.
◆
operator+()
Adds two vectors.
◆
operator-()
[1/2]
Subtracts vector v2 from v1.
◆
operator-()
[2/2]
Negates vector v.
◆
operator==()
[1/2]
constexpr
BoolType
operator==
|
(
|
const
Vec4
< T2, S2 > &
|
v
|
)
|
const
|
|
constexpr
|
Equality operator.
-
参数
-
[in]
|
v
|
Comparison vector.
|
-
返回
-
True if this and v are equal, otherwise false.
◆
operator==()
[2/2]
Equality operator. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector
-
参数
-
[in]
|
v
|
Comparison vector.
|
-
返回
-
True if this and v are equal, otherwise false.
◆
operator!=()
[1/2]
Inequality operator.
-
参数
-
[in]
|
v
|
Comparison vector.
|
-
返回
-
False if this and v are equal, otherwise true.
◆
operator!=()
[2/2]
Inequality operator. We repeat the function template as non-template function, this allows the usage in contexts where the parameter is not a vector itself, but something with a conversion operator to a vector
-
参数
-
[in]
|
v
|
Comparison vector.
|
-
返回
-
False if this and v are equal, otherwise true.
◆
LessThanOrEqual()
◆
GetHashCode()
constexpr
HashInt
GetHashCode
|
(
|
|
)
|
const
|
|
constexpr
|
Returns the hash code of the vector (used for hash maps and comparisons).
-
返回
-
The vector's hash code.
◆
IsEqual()
Tests component-wise if the difference is no bigger than 'epsilon'.
◆
IsZero()
Checks if each component is zero.
◆
SetZero()
constexpr void SetZero
|
(
|
|
)
|
|
|
constexpr
|
Sets all components to zero.
◆
GetAverage()
constexpr T GetAverage
|
(
|
|
)
|
const
|
|
constexpr
|
Calculates the average value of 'x', 'y', 'z' and 'w'.
◆
GetSum()
constexpr T GetSum
|
(
|
|
)
|
const
|
|
constexpr
|
Calculates the sum of 'x', 'y', 'z' and 'w'.
◆
ClampMin()
Set the minimum of each component.
◆
ClampMax()
constexpr void ClampMax
|
(
|
const
Vec4
< T,
STRIDE
> &
|
other
|
)
|
|
|
constexpr
|
Set the maximum of each component.
◆
Clamp01()
Returns a vector that is clamped to the range [0.0 .. 1.0].
◆
GetLength()
constexpr T GetLength
|
(
|
|
)
|
const
|
|
constexpr
|
Returns the length of the vector.
◆
GetSquaredLength()
constexpr T GetSquaredLength
|
(
|
|
)
|
const
|
|
constexpr
|
Returns the squared length of the vector.
◆
GetNormalized()
Returns a normalized vector, so that GetLength(vector)==1.0.
◆
operator!()
Returns a normalized vector, so that GetLength(vector)==1.0.
◆
Normalize()
constexpr void Normalize
|
(
|
|
)
|
|
|
constexpr
|
Normalizes this vector, so that
GetLength()
==1.0.
◆
ToString()
Returns a readable string of the content.
-
参数
-
-
返回
-
The converted result.
◆
GetMin()
constexpr T GetMin
|
(
|
|
)
|
const
|
|
constexpr
|
Returns the minimum of 'x', 'y', 'z' and 'w'.
◆
GetMax()
constexpr T GetMax
|
(
|
|
)
|
const
|
|
constexpr
|
Returns the maximum of 'x', 'y', 'z' and 'w'.
◆
GetRightRotated()
constexpr
Vec4
GetRightRotated
|
(
|
Int
|
rots
|
)
|
const
|
|
constexpr
|
Returns a vector where the components have been rotated to the right (in the usual (x, y, z, w)-representation). E.g., with a value of 1 for rots, the result will be (w, x, y, z).
-
参数
-
[in]
|
rots
|
Number of rotations, may be negative. The result depends only on the number modulo 4.
|
-
返回
-
Vector with rotated components.
◆
NormalizeW()
constexpr void NormalizeW
|
(
|
|
)
|
|
|
constexpr
|
Scales this vector such that w equals 1.
◆
operator*=()
[4/4]
constexpr
Vec4
& operator*=
|
(
|
const
SqrMat4
< V > &
|
m
|
)
|
|
|
constexpr
|
Multiplies vector by a matrix.
◆
NullValue()
static constexpr const
Vec4
& NullValue
|
(
|
|
)
|
|
|
static
constexpr
|
Returns a null value of the vector (see
nullvalue.h
for more details).
-
返回
-
A null value of the vector.
Friends And Related Function Documentation
◆
operator*
Multiplies each vector component by a scalar.
◆
Dot
[1/2]
Calculates dot product of v1 and v2.
◆
Abs
Returns the vector with absolute value for each entry
-
参数
-
[in]
|
v1
|
input vector to work on
|
-
返回
-
component wise absolute value vector of input vector
◆
Dot
[2/2]
Calculates dot product of v1 and v2.
◆
最小
Calculates the minimum of each component.
◆
最大
Calculates the maximum of each component.
◆
SetMin
Set the minimum of each component.
◆
SetMax
Set the maximum of each component.
◆
GetAngle
Calculates angle (in radians) between v1 and v2.
Member Data Documentation
◆
_xpadding
◆
@1073
◆
_ypadding
◆
@1075
◆
_zpadding
◆
@1077
◆
_wpadding
◆
@1079