本文整理汇总了C++中FQuat::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ FQuat::Set方法的具体用法?C++ FQuat::Set怎么用?C++ FQuat::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FQuat
的用法示例。
在下文中一共展示了FQuat::Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToFQuat
FQuat ToFQuat() const
{
static const float s = 0.70710678118f / 32767; // short -> range(sqrt(2))
float A = short(X & 0xFFFE) * s;
float B = short(Y & 0xFFFE) * s;
float C = short(Z & 0xFFFE) * s;
float D = sqrt(1.0f - (A*A + B*B + C*C));
if (Z & 1) D = -D;
FQuat r;
if (Y & 1)
{
if (X & 1) r.Set(D, A, B, C);
else r.Set(C, D, A, B);
}
else
{
if (X & 1) r.Set(B, C, D, A);
else r.Set(A, B, C, D);
}
return r;
}
示例2: ToFQuatOld
FQuat ToFQuatOld() const // for version older than 151
{
static const float s = 0.000095876726845745f; // pi/32767
float X2 = X * s;
float Y2 = Y * s;
float Z2 = Z * s;
float tmp = sqrt(X2*X2 + Y2*Y2 + Z2*Z2);
if (tmp > 0)
{
float scale = sin(tmp / 2) / tmp; // strange code ...
X2 *= scale;
Y2 *= scale;
Z2 *= scale;
}
float W2 = 1.0f - (X2*X2 + Y2*Y2 + Z2*Z2);
if (W2 < 0) W2 = 0;
else W2 = sqrt(W2);
FQuat r;
r.Set(X2, Y2, Z2, W2);
return r;
}
示例3: EulerToQuat
static FQuat EulerToQuat(const FRotator &Rot)
{
// signs was taken from experiments
float yaw = Rot.Yaw * (M_PI / 32768.0f);
float pitch = -Rot.Pitch * (M_PI / 32768.0f);
float roll = -Rot.Roll * (M_PI / 32768.0f);
// derived from Doom3 idAngles::ToQuat()
float sz = sin(yaw / 2);
float cz = cos(yaw / 2);
float sy = sin(pitch / 2);
float cy = cos(pitch / 2);
float sx = sin(roll / 2);
float cx = cos(roll / 2);
float sxcy = sx * cy;
float cxcy = cx * cy;
float sxsy = sx * sy;
float cxsy = cx * sy;
FQuat Q;
Q.Set(cxsy*sz - sxcy*cz, -cxsy*cz - sxcy*sz, sxsy*cz - cxcy*sz, cxcy*cz + sxsy*sz);
return Q;
}