-
首页
-
C4D R23.110 C++ SDK
Quaternion< ValueType > Class Template Reference
Math Library
#include <quaternion.h>
详细描述
template<typename ValueType>
class maxon::Quaternion< ValueType >
Quaternions extend the concept of rotation in three dimensions to rotation in four dimensions. This avoids the problem of "gimbal-lock" and allows for the implementation of smooth and continuous rotation. In effect, they may be considered to add an additional rotation angle to spherical coordinates ie. Longitude, Latitude and Rotation angles. A
Quaternion
is defined using four floating point values |v.x v.y v.z w|. These are calculated from the combination of the three coordinates of the rotation axis and the rotation angle. Because the rotation axis is specified as a unit direction vector, it may be calculated through vector mathematics or from spherical coordinates ie. (longitude/latitude). Quaternions offer another advantage in that they be interpolated - this allows for smooth and predictable rotation effects.
静态公共成员函数
|
static ValueType
|
GetDot
(const
QuaternionType
&q1, const
QuaternionType
&q2)
|
static
Result
<
QuaternionType
>
|
GetLerp
(const
QuaternionType
&q1, const
QuaternionType
&q2, const ValueType t)
|
static
Result
<
QuaternionType
>
|
GetSlerp
(const
QuaternionType
&q1, const
QuaternionType
&q2, const ValueType t)
|
static
Result
<
QuaternionType
>
|
GetSquad
(const
QuaternionType
&qi, const
QuaternionType
&qi_p1, const
QuaternionType
&si, const
QuaternionType
&si_p1, const ValueType t)
|
static
Result
<
QuaternionType
>
|
GetInnerQuaternion
(const
QuaternionType
&qi_m1, const
QuaternionType
&qi, const
QuaternionType
&qi_p1)
|
static
Result
<
QuaternionType
>
|
GetSpline
(const
QuaternionType
&qi_m1, const
QuaternionType
&qi, const
QuaternionType
&qi_p1, const
QuaternionType
&qi_p2, const ValueType t)
|
static
Result
< void >
|
DescribeIO
(const
DataSerializeInterface
&stream)
|
私有成员函数
|
ValueType
|
MyCopysign
(const ValueType &x, const ValueType &y) const
|
Member Typedef Documentation
◆
VectorType
◆
MatrixType
◆
QuaternionType
构造函数 & 析构函数文档编制
◆
Quaternion()
[1/3]
Creates a quaternion initialized with default values (all components 0.0).
◆
Quaternion()
[2/3]
Creates a quaternion and initialize it with given quaternion values.
◆
Quaternion()
[3/3]
Quaternion
|
(
|
const ValueType
|
x
,
|
|
|
const ValueType
|
y
,
|
|
|
const ValueType
|
z
,
|
|
|
const ValueType
|
w
|
|
)
|
|
|
Creates a quaternion and initialize it with given quaternion values.
成员函数文档编制
◆
MyCopysign()
ValueType MyCopysign
|
(
|
const ValueType &
|
x
,
|
|
|
const ValueType &
|
y
|
|
)
|
|
const
|
|
private
|
◆
operator+=()
Adds the components of two quaternions.
◆
operator-=()
Subtract the components of two quaternions.
◆
operator*=()
Concatenate two quaternion operations.
◆
operator+()
Adds the components of two quaternions.
◆
operator-()
Subtracts the components of two quaternions.
◆
operator*()
[1/2]
Concatenates two quaternion operations.
◆
operator*()
[2/2]
Quaternion
< ValueType > operator*
|
(
|
const ValueType
|
s
|
)
|
const
|
Scales the components of a quaternion.
◆
SetMatrix()
Converts a rotation matrix into a quaternion.
-
参数
-
[in]
|
m
|
Rotation matrix (does not need to be normalized).
|
◆
SetRotation()
Converts a rotation of order X -> Y -> Z into a quaternion.
-
参数
-
[in]
|
rotation
|
Rotation angle vector in radians.
|
◆
SetAxisRotation()
void SetAxisRotation
|
(
|
const
VectorType
&
|
axis
,
|
|
|
const ValueType
|
rotation
|
|
)
|
|
|
Converts an axis and angle to a quaternion.
-
参数
-
[in]
|
axis
|
Axis (does not need to be normalized).
|
[in]
|
rotation
|
Rotation angle in radians.
|
◆
GetMatrix()
Derives a rotation matrix from the quaternion.
◆
GetAxisRotation()
Calculate axis and rotation angle from quaternion
-
参数
-
[out]
|
axis
|
axis vector
|
[out]
|
angle
|
angle value in radians
|
-
返回
-
OK on success. Returns an error if quaternion is not normalized or the direction of the axis is undefined (singularity at 0 / 180 degree)
◆
GetSquaredLength()
ValueType GetSquaredLength
|
Calculates the squared magntitude/length/norm of a quaternion.
◆
GetLength()
Calculates the magntitude/length/norm of a quaternion.
◆
GetNormalized()
Calculates the normalized quaternion.
-
返回
-
OK on sucess. Returns an error if the length of the quaternion is zero
◆
GetInverse()
Calculates the inverse of a quaternion.
-
返回
-
OK on sucess. Returns an error if the length of the quaternion is zero
◆
GetConjugate()
Calculates the conjugate of a quaternion.
-
返回
-
conjugated quaternion
◆
GetLog()
Calculates the logarithm of a quaternion.
-
返回
-
OK on sucess. Returns an error if the length of the quaternion axis is zero
◆
GetExp()
Calculates the exponential of a quaternion.
-
返回
-
OK on sucess. Returns an error if the length of the quaternion is zero
◆
GetPow()
Calculates the quaternion power q^t.
-
参数
-
-
返回
-
OK on sucess. Returns an error if the length of the quaternion is zero
◆
GetDot()
Calculates the dot product of two quaternions.
◆
GetLerp()
Interpolates two quaternions linearly with blend parameter t.
-
参数
-
[in]
|
q1
|
first quaternion
|
[in]
|
q2
|
second quaternion
|
[in]
|
t
|
blend parameter [0.0, 1.0.]
|
-
返回
-
The interpolated quaternion.
◆
GetSlerp()
Interpolates two quaternions spherical linearly with blend parameter t.
-
参数
-
[in]
|
q1
|
first quaternion
|
[in]
|
q2
|
second quaternion
|
[in]
|
t
|
blend parameter [0.0, 1.0.]
|
-
返回
-
The interpolated quaternion.
◆
GetSquad()
Spherical quadrangle interpolation of a sequence of quaternions qi and qi+1 with blend parameter t Additionally you have to specify the innner quaternions si and si+1.
-
参数
-
[in]
|
qi
|
main quaternion at index i
|
[in]
|
qi_p1
|
main quaternion at index i+1
|
[in]
|
si
|
inner quaterniona at index i
|
[in]
|
si_p1
|
inner quaternion at index i+1
|
[in]
|
t
|
blend parameter [0.0, 1.0.]
|
-
返回
-
The interpolated quaternion.
◆
GetInnerQuaternion()
Computer the inner quaternion from the series of quaternions qi-1, qi and qi+1
-
参数
-
[in]
|
qi_m1
|
quaternion at index i-1
|
[in]
|
qi
|
quaternion at index i
|
[in]
|
qi_p1
|
quaternion at index i+1
|
-
返回
-
The interpolated quaternion.
◆
GetSpline()
Interpolates two quaternions qi and qi+1 smoothly using spherical spline interpolation with parameter t. qi-1 and qi+2 are used to provide C1 continuity at the borders.
-
参数
-
[in]
|
qi_m1
|
quaternion at index i-1
|
[in]
|
qi
|
quaternion at index i
|
[in]
|
qi_p1
|
quaternion at index i+1
|
[in]
|
qi_p2
|
quaternion at index i+2
|
[in]
|
t
|
blend parameter [0.0, 1.0.]
|
-
返回
-
The interpolated quaternion.
◆
ToString()
Returns a readable string of the content.
-
参数
-
-
返回
-
The converted result.
◆
DescribeIO()
Describe all elements of this class for I/O operations.
-
参数
-
[in]
|
stream
|
The stream that is used to register the class members.
|
-
返回
-
OK on success.
◆
MAXON_OPERATOR_EQUALITY_HASHCODE()
MAXON_OPERATOR_EQUALITY_HASHCODE
|
(
|
Quaternion
< ValueType >
|
,
|
|
|
v
|
,
|
|
|
w
|
|
|
)
|
|
|
Friends And Related Function Documentation
◆
operator*
Scales the components of a quaternion with a scalar.
Member Data Documentation
direction vector component
angle component