Skip to content

Instantly share code, notes, and snippets.

@kg
Created May 7, 2011 17:09
Show Gist options
  • Save kg/960648 to your computer and use it in GitHub Desktop.
Save kg/960648 to your computer and use it in GitHub Desktop.
// Microsoft.Xna.Framework.Vector2
public static Vector2 Transform(Vector2 value, Quaternion rotation)
{
float num = rotation.X + rotation.X;
float num2 = rotation.Y + rotation.Y;
float num3 = rotation.Z + rotation.Z;
float num4 = rotation.W * num3;
float num5 = rotation.X * num;
float num6 = rotation.X * num2;
float num7 = rotation.Y * num2;
float num8 = rotation.Z * num3;
float x = value.X * (1f - num7 - num8) + value.Y * (num6 - num4);
float y = value.X * (num6 + num4) + value.Y * (1f - num5 - num8);
Vector2 result;
result.X = x;
result.Y = y;
return result;
}
Microsoft.Xna.Framework.Vector2.Transform$2 = function (value, rotation) {
var result = new Microsoft.Xna.Framework.Vector2();
var num2 = (rotation.Y + rotation.Y);
var num3 = (rotation.Z + rotation.Z);
var num4 = (rotation.W * num3);
var num6 = (rotation.X * num2);
var num8 = (rotation.Z * num3);
var x = ((value.X * ((1 - (rotation.Y * num2)) - num8)) + (value.Y * (num6 - num4)));
var y = ((value.X * (num6 + num4)) + (value.Y * ((1 - (rotation.X * (rotation.X + rotation.X))) - num8)));
result.X = x;
result.Y = y;
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment