本文整理汇总了C++中TransformationMatrix::decompose4方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformationMatrix::decompose4方法的具体用法?C++ TransformationMatrix::decompose4怎么用?C++ TransformationMatrix::decompose4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformationMatrix
的用法示例。
在下文中一共展示了TransformationMatrix::decompose4方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
PassRefPtr<TransformOperation> RotateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
{
if (from && !from->isSameType(*this))
return this;
if (blendToIdentity)
return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, m_type);
const RotateTransformOperation* fromOp = static_cast<const RotateTransformOperation*>(from);
// Optimize for single axis rotation
if (!fromOp || (fromOp->m_x == 0 && fromOp->m_y == 0 && fromOp->m_z == 1) ||
(fromOp->m_x == 0 && fromOp->m_y == 1 && fromOp->m_z == 0) ||
(fromOp->m_x == 1 && fromOp->m_y == 0 && fromOp->m_z == 0)) {
double fromAngle = fromOp ? fromOp->m_angle : 0;
return RotateTransformOperation::create(fromOp ? fromOp->m_x : m_x,
fromOp ? fromOp->m_y : m_y,
fromOp ? fromOp->m_z : m_z,
WebCore::blend(fromAngle, m_angle, progress), m_type);
}
const RotateTransformOperation* toOp = this;
// Create the 2 rotation matrices
TransformationMatrix fromT;
TransformationMatrix toT;
fromT.rotate3d((fromOp ? fromOp->m_x : 0),
(fromOp ? fromOp->m_y : 0),
(fromOp ? fromOp->m_z : 1),
(fromOp ? fromOp->m_angle : 0));
toT.rotate3d((toOp ? toOp->m_x : 0),
(toOp ? toOp->m_y : 0),
(toOp ? toOp->m_z : 1),
(toOp ? toOp->m_angle : 0));
// Blend them
toT.blend(fromT, progress);
// Extract the result as a quaternion
TransformationMatrix::Decomposed4Type decomp;
toT.decompose4(decomp);
// Convert that to Axis/Angle form
double x = -decomp.quaternionX;
double y = -decomp.quaternionY;
double z = -decomp.quaternionZ;
double length = sqrt(x * x + y * y + z * z);
double angle = 0;
if (length > 0.00001) {
x /= length;
y /= length;
z /= length;
angle = rad2deg(acos(decomp.quaternionW) * 2);
} else {
x = 0;
y = 0;
z = 1;
}
return RotateTransformOperation::create(x, y, z, angle, ROTATE_3D);
}