示例#1
0
 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 );
 }
示例#2
0
 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;
 }
示例#3
0
 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 );
 }
示例#4
0
 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
     );
 }
示例#5
0
 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 )
     );
 }
示例#6
0
 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;
 }
示例#7
0
 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 );
 }
示例#8
0
 public static Quaternion Multiply( float a, Quaternion b )
 {
     return b * a;
 }
示例#9
0
 public void Normalize( out Quaternion result )
 {
     Normalize ( ref this, out result );
 }
示例#10
0
 public static Quaternion Dividie( Quaternion a, Quaternion b )
 {
     return a / b;
 }
示例#11
0
 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 );
 }
示例#12
0
 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 );
 }
示例#13
0
 public static void Negate( ref Quaternion a, out Quaternion result )
 {
     result = new Quaternion ( -a.X, -a.Y, -a.Z, -a.W );
 }
示例#14
0
 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 );
 }
示例#15
0
 public static Quaternion Slerp( Quaternion v1, Quaternion v2, float amount )
 {
     Quaternion result; Slerp ( ref v1, ref v2, amount, out result ); return result;
 }
示例#16
0
 public static void Conjugate( ref Quaternion v, out Quaternion result )
 {
     result = new Quaternion ( -v.X, -v.Y, -v.Z, v.W );
 }
示例#17
0
 public static Quaternion Conjugate( Quaternion v )
 {
     Quaternion result; Conjugate ( ref v, out result ); return result;
 }
示例#18
0
 public static Quaternion Concatenate( Quaternion v1, Quaternion v2 )
 {
     Quaternion result; Concatenate ( ref v1, ref v2, out result ); return result;
 }
示例#19
0
 public static void Multiply( float a, ref Quaternion b, out Quaternion result )
 {
     Multiply ( ref b, a, out result );
 }
示例#20
0
 public static Vector3 Transform( Vector3 value, Quaternion rotation )
 {
     Vector3 result;
     Transform ( ref value, ref rotation, out result );
     return result;
 }
示例#21
0
 public static Quaternion Subtract( Quaternion a, Quaternion b )
 {
     return a - b;
 }
示例#22
0
 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 ) );
 }
示例#23
0
 public static Quaternion Add( Quaternion a, Quaternion b )
 {
     return a + b;
 }
示例#24
0
 public static Quaternion Invert( Quaternion a )
 {
     return ~a;
 }
示例#25
0
 public static Quaternion Divide( Quaternion a, float b )
 {
     return a / b;
 }
示例#26
0
 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 );
 }
示例#27
0
 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 );
 }
示例#28
0
 public static Quaternion Multiply( Quaternion a, float b )
 {
     return a * b;
 }
示例#29
0
 public static float Dot( Quaternion a, Quaternion b )
 {
     float result; Dot ( ref a, ref b, out result ); return result;
 }
示例#30
0
 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 );
 }