本文整理汇总了C++中Quaternion::FromRotationTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaternion::FromRotationTo方法的具体用法?C++ Quaternion::FromRotationTo怎么用?C++ Quaternion::FromRotationTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion::FromRotationTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FromLookRotation
bool Quaternion::FromLookRotation(const Vector3& direction, const Vector3& upDirection)
{
Quaternion ret;
Vector3 forward = direction.Normalized();
Vector3 v = forward.CrossProduct(upDirection);
// If direction & upDirection are parallel and crossproduct becomes zero, use FromRotationTo() fallback
if (v.LengthSquared() >= M_EPSILON)
{
v.Normalize();
Vector3 up = v.CrossProduct(forward);
Vector3 right = up.CrossProduct(forward);
ret.FromAxes(right, up, forward);
}
else
ret.FromRotationTo(Vector3::FORWARD, forward);
if (!ret.IsNaN())
{
(*this) = ret;
return true;
}
else
return false;
}
示例2: AddCircle
void DebugRenderer::AddCircle(const Vector3& center, const Vector3& normal, float radius, const Color& color, int steps, bool depthTest)
{
Quaternion orientation;
orientation.FromRotationTo(Vector3::UP, normal.Normalized());
Vector3 p = orientation * Vector3(radius, 0, 0) + center;
unsigned uintColor = color.ToUInt();
for(int i = 1; i <= steps; ++i)
{
const float angle = (float)i / (float)steps * 360.0f;
Vector3 v(radius * Cos(angle), 0, radius * Sin(angle));
Vector3 c = orientation * v + center;
AddLine(p, c, uintColor, depthTest);
p = c;
}
p = center + normal * (radius / 4.0f);
AddLine(center, p, uintColor, depthTest);
}