public static void Transform( ref Vector3 value, ref Quaternion rotation, out Vector3 result ) { float x = 2 * ( rotation.Y * value.Z - rotation.Z * value.Y ); float y = 2 * ( rotation.Z * value.X - rotation.X * value.Z ); float z = 2 * ( rotation.X * value.Y - rotation.Y * value.X ); result.X = value.X + x * rotation.W + ( rotation.Y * z - rotation.Z * y ); result.Y = value.Y + y * rotation.W + ( rotation.Z * x - rotation.X * z ); result.Z = value.Z + z * rotation.W + ( rotation.X * y - rotation.Y * x ); }
public Matrix4x4( Quaternion q ) { float num9 = q.X * q.X, num8 = q.Y * q.Y, num7 = q.Z * q.Z, num6 = q.X * q.Y; float num5 = q.Z * q.W, num4 = q.Z * q.X, num3 = q.Y * q.W, num2 = q.Y * q.Z; float num1 = q.X * q.W; M11 = 1f - ( 2f * ( num8 + num7 ) ); M12 = 2f * ( num6 + num5 ); M13 = 2f * ( num4 - num3 ); M14 = 0f; M21 = 2f * ( num6 - num5 ); M22 = 1f - ( 2f * ( num7 + num9 ) ); M23 = 2f * ( num2 + num1 ); M24 = 0f; M31 = 2f * ( num4 + num3 ); M32 = 2f * ( num2 - num1 ); M33 = 1f - ( 2f * ( num8 + num9 ) ); M34 = 0f; M41 = 0f; M42 = 0f; M43 = 0f; M44 = 1f; }
public static void Divide( ref Quaternion a, ref Quaternion b, out Quaternion result ) { float x = a.X, y = a.Y, z = a.Z, w = a.W; float num14 = ( ( ( b.X * b.X ) + ( b.Y * b.Y ) ) + ( b.Z * b.Z ) ) + ( b.W * b.W ); float num5 = 1f / num14, num4 = -b.X * num5, num3 = -b.Y * num5, num2 = -b.Z * num5, num1 = b.W * num5; float num13 = ( y * num2 ) - ( z * num3 ), num12 = ( z * num4 ) - ( x * num2 ); float num11 = ( x * num3 ) - ( y * num4 ), num10 = ( ( x * num4 ) + ( y * num3 ) ) + ( z * num2 ); result = new Quaternion ( ( ( x * num1 ) + ( num4 * w ) ) + num13, ( ( y * num1 ) + ( num3 * w ) ) + num12, ( ( z * num1 ) + ( num2 * w ) ) + num11, ( w * num1 ) - num10 ); }
public static void Concatenate( ref Quaternion v1, ref Quaternion v2, out Quaternion result ) { float x = v2.X; float y = v2.Y; float z = v2.Z; float w = v2.W; float num4 = v1.X; float num3 = v1.Y; float num2 = v1.Z; float num = v1.W; float num12 = ( y * num2 ) - ( z * num3 ); float num11 = ( z * num4 ) - ( x * num2 ); float num10 = ( x * num3 ) - ( y * num4 ); float num9 = ( ( x * num4 ) + ( y * num3 ) ) + ( z * num2 ); result = new Quaternion ( ( ( x * num ) + ( num4 * w ) ) + num12, ( ( y * num ) + ( num3 * w ) ) + num11, ( ( z * num ) + ( num2 * w ) ) + num10, ( w * num ) - num9 ); }
public static void Slerp( ref Quaternion v1, ref Quaternion v2, float amount, out Quaternion result ) { float num2, num3, num = amount; float num4 = ( ( ( v1.X * v2.X ) + ( v1.Y * v2.Y ) ) + ( v1.Z * v2.Z ) ) + ( v1.W * v2.W ); bool flag = false; if ( num4 < 0f ) { flag = true; num4 = -num4; } if ( num4 > 0.999999f ) { num3 = 1f - num; num2 = flag ? -num : num; } else { float num5 = ( float ) Math.Acos ( ( double ) num4 ); float num6 = ( float ) ( 1.0 / Math.Sin ( ( double ) num5 ) ); num3 = ( ( float ) Math.Sin ( ( double ) ( ( 1f - num ) * num5 ) ) ) * num6; num2 = flag ? ( ( ( float ) -Math.Sin ( ( double ) ( num * num5 ) ) ) * num6 ) : ( ( ( float ) Math.Sin ( ( double ) ( num * num5 ) ) ) * num6 ); } result = new Quaternion( ( num3 * v1.X ) + ( num2 * v2.X ), ( num3 * v1.Y ) + ( num2 * v2.Y ), ( num3 * v1.Z ) + ( num2 * v2.Z ), ( num3 * v1.W ) + ( num2 * v2.W ) ); }
public static void Lerp( ref Quaternion v1, ref Quaternion v2, float amount, out Quaternion result ) { float num = amount; float num2 = 1f - num; float num5 = ( ( ( v1.X * v2.X ) + ( v1.Y * v2.Y ) ) + ( v1.Z * v2.Z ) ) + ( v1.W * v2.W ); if ( num5 >= 0f ) result = new Quaternion ( ( num2 * v1.X ) + ( num * v2.X ), ( num2 * v1.Y ) + ( num * v2.Y ), ( num2 * v1.Z ) + ( num * v2.Z ), ( num2 * v1.W ) + ( num * v2.W ) ); else result = new Quaternion ( ( num2 * v1.X ) - ( num * v2.X ), ( num2 * v1.Y ) - ( num * v2.Y ), ( num2 * v1.Z ) - ( num * v2.Z ), ( num2 * v1.W ) - ( num * v2.W ) ); float num4 = ( ( ( result.X * result.X ) + ( result.Y * result.Y ) ) + ( result.Z * result.Z ) ) + ( result.W * result.W ); float num3 = 1f / ( ( float ) Math.Sqrt ( ( double ) num4 ) ); result *= num3; }
public static void Multiply( ref Quaternion a, ref Quaternion b, out Quaternion result ) { float x = a.X, y = a.Y, z = a.Z, w = a.W; float num4 = b.X, num3 = b.Y, num2 = b.Z, num1 = b.W; float num12 = ( y * num2 ) - ( z * num3 ), num11 = ( z * num4 ) - ( x * num2 ), num10 = ( x * num3 ) - ( y * num4 ), num9 = ( ( x * num4 ) + ( y * num3 ) ) + ( z * num2 ); result = new Quaternion ( ( ( x * num1 ) + ( num4 * w ) ) + num12, ( ( y * num1 ) + ( num3 * w ) ) + num11, ( ( z * num1 ) + ( num2 * w ) ) + num10, ( w * num1 ) - num9 ); }
public static Quaternion Multiply( float a, Quaternion b ) { return b * a; }
public void Normalize( out Quaternion result ) { Normalize ( ref this, out result ); }
public static Quaternion Dividie( Quaternion a, Quaternion b ) { return a / b; }
public static void Add( ref Quaternion a, ref Quaternion b, out Quaternion result ) { result = new Quaternion ( a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W ); }
public static void Subtract( ref Quaternion a, ref Quaternion b, out Quaternion result ) { result = new Quaternion ( a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W ); }
public static void Negate( ref Quaternion a, out Quaternion result ) { result = new Quaternion ( -a.X, -a.Y, -a.Z, -a.W ); }
public static void Multiply( ref Quaternion a, float b, out Quaternion result ) { result = new Quaternion ( a.X * b, a.Y * b, a.Z * b, a.W * b ); }
public static Quaternion Slerp( Quaternion v1, Quaternion v2, float amount ) { Quaternion result; Slerp ( ref v1, ref v2, amount, out result ); return result; }
public static void Conjugate( ref Quaternion v, out Quaternion result ) { result = new Quaternion ( -v.X, -v.Y, -v.Z, v.W ); }
public static Quaternion Conjugate( Quaternion v ) { Quaternion result; Conjugate ( ref v, out result ); return result; }
public static Quaternion Concatenate( Quaternion v1, Quaternion v2 ) { Quaternion result; Concatenate ( ref v1, ref v2, out result ); return result; }
public static void Multiply( float a, ref Quaternion b, out Quaternion result ) { Multiply ( ref b, a, out result ); }
public static Vector3 Transform( Vector3 value, Quaternion rotation ) { Vector3 result; Transform ( ref value, ref rotation, out result ); return result; }
public static Quaternion Subtract( Quaternion a, Quaternion b ) { return a - b; }
public static void Dot( ref Quaternion a, ref Quaternion b, out float result ) { result = ( ( ( ( a.X * b.X ) + ( a.Y * b.Y ) ) + ( a.Z * b.Z ) ) + ( a.W * b.W ) ); }
public static Quaternion Add( Quaternion a, Quaternion b ) { return a + b; }
public static Quaternion Invert( Quaternion a ) { return ~a; }
public static Quaternion Divide( Quaternion a, float b ) { return a / b; }
public static void Invert( ref Quaternion a, out Quaternion result ) { result = new Quaternion ( -a.X / a.LengthSquared, -a.Y / a.LengthSquared, -a.Z / a.LengthSquared, a.W / a.LengthSquared ); }
public static void Divide( ref Quaternion a, float b, out Quaternion result ) { result = new Quaternion ( a.X / b, a.Y / b, a.Z / b, a.W / b ); }
public static Quaternion Multiply( Quaternion a, float b ) { return a * b; }
public static float Dot( Quaternion a, Quaternion b ) { float result; Dot ( ref a, ref b, out result ); return result; }
public static void Normalize( ref Quaternion v, out Quaternion result ) { result = new Quaternion ( v.X / v.Length, v.Y / v.Length, v.Z / v.Length, v.W / v.Length ); }