本文整理汇总了C++中Quaternion::Getz方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaternion::Getz方法的具体用法?C++ Quaternion::Getz怎么用?C++ Quaternion::Getz使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion::Getz方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// helper function to run slerp with 2.0 as t value
Quaternion<double> Interpolator::Double(Quaternion<double> p, Quaternion<double> q)
{
// students should implement this
Quaternion<double> result;
double pDotq = q.Gets()*p.Gets() + q.Getx()*p.Getx() + q.Gety()*p.Gety() + q.Getz()*p.Getz();
result = (2*pDotq)*q - p;
return result;
}
示例2: acos
// SLERP function for quaternions
Quaternion<double> Interpolator::Slerp(double t, Quaternion<double> & qStart, Quaternion<double> & qEnd_)
{
// students should implement this
Quaternion<double> result;
Quaternion<double> q3;
double qStartDotqEnd = qStart.Gets()*qEnd_.Gets() + qStart.Getx()*qEnd_.Getx() + qStart.Gety()*qEnd_.Gety() + qStart.Getz()*qEnd_.Getz();
// need to check for the great arc that is the smallest, and change the quaternion accordingly if chosen wrong one
if (qStartDotqEnd < 0)
{
q3 = -1*qEnd_;
qStartDotqEnd = -qStartDotqEnd;
}
else
{
q3 = qEnd_;
}
// cos(theta) = s1s2 + x1x2 + y1y2 + z1z2
double theta = acos(qStartDotqEnd);
if (sin(theta) == 0)
{
return qStart;
}
// slerp formula
result = (sin((1-t)*theta)/sin(theta))*qStart + (sin(t*theta)/sin(theta))*q3;
result.Normalize();
return result;
}