예제 #1
0
파일: Matrix3.cs 프로젝트: zz5756712/bsf
        /// <summary>
        /// Converts an orthonormal matrix to axis angle representation.
        /// </summary>
        /// <param name="axis">Axis around which the rotation is performed.</param>
        /// <param name="angle">Amount of rotation.</param>
        public void ToAxisAngle(out Vector3 axis, out Degree angle)
        {
            float  trace   = m00 + m11 + m22;
            float  cos     = 0.5f * (trace - 1.0f);
            Radian radians = (Radian)MathEx.Acos(cos);  // In [0, PI]

            angle = radians;

            if (radians > (Radian)0.0f)
            {
                if (radians < MathEx.Pi)
                {
                    axis.x = m21 - m12;
                    axis.y = m02 - m20;
                    axis.z = m10 - m01;

                    axis.Normalize();
                }
                else
                {
                    // Angle is PI
                    float halfInverse;
                    if (m00 >= m11)
                    {
                        // r00 >= r11
                        if (m00 >= m22)
                        {
                            // r00 is maximum diagonal term
                            axis.x      = 0.5f * MathEx.Sqrt(m00 - m11 - m22 + 1.0f);
                            halfInverse = 0.5f / axis.x;
                            axis.y      = halfInverse * m01;
                            axis.z      = halfInverse * m02;
                        }
                        else
                        {
                            // r22 is maximum diagonal term
                            axis.z      = 0.5f * MathEx.Sqrt(m22 - m00 - m11 + 1.0f);
                            halfInverse = 0.5f / axis.z;
                            axis.x      = halfInverse * m02;
                            axis.y      = halfInverse * m12;
                        }
                    }
                    else
                    {
                        // r11 > r00
                        if (m11 >= m22)
                        {
                            // r11 is maximum diagonal term
                            axis.y      = 0.5f * MathEx.Sqrt(m11 - m00 - m22 + 1.0f);
                            halfInverse = 0.5f / axis.y;
                            axis.x      = halfInverse * m01;
                            axis.z      = halfInverse * m12;
                        }
                        else
                        {
                            // r22 is maximum diagonal term
                            axis.z      = 0.5f * MathEx.Sqrt(m22 - m00 - m11 + 1.0f);
                            halfInverse = 0.5f / axis.z;
                            axis.x      = halfInverse * m02;
                            axis.y      = halfInverse * m12;
                        }
                    }
                }
            }
            else
            {
                // The angle is 0 and the matrix is the identity.  Any axis will
                // work, so just use the x-axis.
                axis.x = 1.0f;
                axis.y = 0.0f;
                axis.z = 0.0f;
            }
        }
예제 #2
0
 /// <summary>
 /// Creates a new radian value.
 /// </summary>
 /// <param name="d">Value in degrees.</param>
 public Radian(Degree d)
 {
     this.value = d.Radians;
 }
예제 #3
0
파일: Quaternion.cs 프로젝트: zz5756712/bsf
 /// <summary>
 /// Converts the quaternion rotation into axis/angle rotation.
 /// </summary>
 /// <param name="rotation">Quaternion to convert.</param>
 /// <param name="axis">Axis around which the rotation is performed.</param>
 /// <param name="angle">Amount of rotation.</param>
 public static void ToAxisAngle(Quaternion rotation, out Vector3 axis, out Degree angle)
 {
     rotation.ToAxisAngle(out axis, out angle);
 }
예제 #4
0
        /// <summary>
        /// Rotates around local Y axis.
        /// </summary>
        /// <param name="angle">Angle to rotate by.</param>
        public void Yaw(Degree angle)
        {
            Radian radianAngle = angle;

            Internal_Yaw(mCachedPtr, ref radianAngle);
        }
예제 #5
0
        /// <summary>
        /// Rotates around local X axis.
        /// </summary>
        /// <param name="angle">Angle to rotate by.</param>
        public void Pitch(Degree angle)
        {
            Radian radianAngle = angle;

            Internal_Pitch(mCachedPtr, ref radianAngle);
        }
예제 #6
0
        /// <summary>
        /// Rotates around local Z axis.
        /// </summary>
        /// <param name="angle">Angle to rotate by.</param>
        public void Roll(Degree angle)
        {
            Radian radianAngle = angle;

            Internal_Roll(mCachedPtr, ref radianAngle);
        }
예제 #7
0
 private static extern void Internal_getPointInArcShell(IntPtr thisPtr, ref Degree angle, float thickness, out Vector2 __output);
예제 #8
0
 private static extern void Internal_getPointInArc(IntPtr thisPtr, ref Degree angle, out Vector2 __output);
예제 #9
0
 private static extern void Internal_getSpotFalloffAngle(IntPtr thisPtr, out Degree __output);
예제 #10
0
 private static extern void Internal_setSpotFalloffAngle(IntPtr thisPtr, ref Degree spotAngle);