TEST(Transformable_objects, have_a_position_rotation_and_scaling) { Transformable t; EXPECT_EQ(vec3(0,0,0), t.position()); EXPECT_EQ(vec3(1,1,1), t.scaling()); EXPECT_EQ(quat(0,0,0,1), t.rotation()); }
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()); }
// SetTransformation void ChannelTransform::SetTransformation(const Transformable& other) { // calc affine parameters // translation double tx; double ty; other.translation(&tx, &ty); // rotation double rotation = agg::rad2deg(other.rotation()); // scale double scaleX; double scaleY; other.scaling(&scaleX, &scaleY); if (isnanf(tx) || isnanf(ty) || isnanf(scaleX) || isnanf(scaleY)) return; SetTransformation(B_ORIGIN, BPoint(tx, ty), rotation, scaleX, scaleY); }