Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector3<Type> ret;
- Type RollComponent1 = q.X * q.Z + q.Y * q.W;
- Type RollComponent2 = q.X * q.W - q.Y * q.Z;
- Type Pitch = -q.X * q.X + -q.Y * q.Y + -q.Z * q.Z + -q.W * q.W;
- Type YawComponent1 = q.X * q.Z - q.Y * q.W;
- Type YawComponent2 = q.Y * q.Z + q.X * q.W;
- Pitch = Pitch > 1.0 ? 1.0 : Pitch;
- Pitch = Pitch < -1.0 ? -1.0 : Pitch;
- ret[0] = std::atan2(RollComponent1, RollComponent2); //roll, x
- ret[1] = std::acos(Pitch); //pitch, y
- ret[2] = std::atan2(YawComponent1, YawComponent2); //yaw, z
- return ret;
- Vector3<Type> ret;
- Type RollComponent1 = 2.0 * (q.X * q.W + q.Y * q.Z);
- Type RollComponent2 = 1.0 - 2.0 * (q.X * q.X + q.Y * q.Y);
- Type Pitch = 2.0 * (q.Y * q.W - q.X * q.Z);
- Type YawComponent1 = 2.0 * (q.Z * q.W + q.X * q.Y);
- Type YawComponent2 = 1.0 - 2.0 * (q.Y * q.Y + q.Z * q.Z);
- ret[0] = std::atan2(YawComponent1, YawComponent2); //yaw, z
- ret[1] = std::asin(Pitch); //pitch, y
- ret[2] = std::atan2(RollComponent1, RollComponent2); //roll, x
- return ret;
Add Comment
Please, Sign In to add comment