Advertisement
Guest User

vector transformed by quaternion

a guest
May 1st, 2012
2,960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. public static Vector3 Transform(Vector3 value, Quaternion rotation)
  2. {
  3.     Vector3 vector;
  4.     float num12 = rotation.X + rotation.X;
  5.     float num2 = rotation.Y + rotation.Y;
  6.     float num = rotation.Z + rotation.Z;
  7.     float num11 = rotation.W * num12;
  8.     float num10 = rotation.W * num2;
  9.     float num9 = rotation.W * num;
  10.     float num8 = rotation.X * num12;
  11.     float num7 = rotation.X * num2;
  12.     float num6 = rotation.X * num;
  13.     float num5 = rotation.Y * num2;
  14.     float num4 = rotation.Y * num;
  15.     float num3 = rotation.Z * num;
  16.     float num15 = ((value.X * ((1f - num5) - num3)) + (value.Y * (num7 - num9))) + (value.Z * (num6 + num10));
  17.     float num14 = ((value.X * (num7 + num9)) + (value.Y * ((1f - num8) - num3))) + (value.Z * (num4 - num11));
  18.     float num13 = ((value.X * (num6 - num10)) + (value.Y * (num4 + num11))) + (value.Z * ((1f - num8) - num5));
  19.     vector.X = num15;
  20.     vector.Y = num14;
  21.     vector.Z = num13;
  22.     return vector;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement