本文整理汇总了C++中Transformable::rotateTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformable::rotateTo方法的具体用法?C++ Transformable::rotateTo怎么用?C++ Transformable::rotateTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformable
的用法示例。
在下文中一共展示了Transformable::rotateTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rotationX
TEST(Transformable_objects, can_be_rotated)
{
Transformable t;
quat rotationX(Transformable::X_AXIS, toRadian(90));
quat rotationY(Transformable::Y_AXIS, toRadian(180));
EXPECT_EQ(quat(0,0,0,1), t.rotation());
t.rotateTo(rotationX);
EXPECT_EQ(normalize(rotationX), t.rotation());
t.rotateTo(Transformable::Y_AXIS, toRadian(180));
EXPECT_EQ(normalize(rotationY), t.rotation());
t.rotate(quat(Transformable::X_AXIS, toRadian(90)));
EXPECT_EQ(normalize(rotationX * rotationY), t.rotation());
t.rotate(Transformable::X_AXIS, toRadian(-90));
EXPECT_EQ(normalize(rotationY), t.rotation());
}
示例2: pInModelSpace
TEST(Transformable_objects, have_a_rotation_matrix_to_move_from_model_space_to_world_space__x_axis_only)
{
Transformable model;
vec3 pInModelSpace(2,0,0), pInWorldSpace(2,0,0);
vec3 qInModelSpace(0,2,0), qInWorldSpace(0,0,2);
vec3 rInModelSpace(0,0,2), rInWorldSpace(0,-2,0);
model.rotateTo(Transformable::X_AXIS, toRadian(90));
EXPECT_EQ(pInWorldSpace, (model.rotationMatrix() * vec4(pInModelSpace,1)).xyz());
EXPECT_EQ(qInWorldSpace, (model.rotationMatrix() * vec4(qInModelSpace,1)).xyz());
EXPECT_EQ(rInWorldSpace, (model.rotationMatrix() * vec4(rInModelSpace,1)).xyz());
}