Esempio n. 1
0
        /// <summary> Sets the value of this axis-angle to the rotational component of
        /// the passed matrix.
        /// If the specified matrix has no rotational component, the value
        /// of this AxisAngle4f is set to an angle of 0 about an axis of (0,1,0).
        /// </summary>
        /// <param name="m1">the matrix4d
        /// </param>
        public void  set_Renamed(Matrix4d m1)
        {
            Matrix3d m3d = new Matrix3d();

            m1.get_Renamed(m3d);


            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            x = (float)(m3d.m21 - m3d.m12);
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            y = (float)(m3d.m02 - m3d.m20);
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            z = (float)(m3d.m10 - m3d.m01);
            double mag = x * x + y * y + z * z;

            if (mag > EPS)
            {
                mag = System.Math.Sqrt(mag);
                double sin = 0.5 * mag;
                double cos = 0.5 * (m3d.m00 + m3d.m11 + m3d.m22 - 1.0);
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                angle = (float)System.Math.Atan2(sin, cos);

                double invMag = 1.0 / mag;
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                x = (float)(x * invMag);
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                y = (float)(y * invMag);
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                z = (float)(z * invMag);
            }
            else
            {
                x     = 0.0f;
                y     = 1.0f;
                z     = 0.0f;
                angle = 0.0f;
            }
        }