Пример #1
0
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
0
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());
}