Example #1
0
        public Vector3D Axis()
        {
            Vector3D axis = new Vector3D(0, 0, 0);

            float d0 = this[0, 0], d1 = this[1, 1], d2 = this[2, 2];

            // The trace determines the method of decomposition
            float rr = 1.0f + d0 + d1 + d2;

            if (rr > 0)
            {
                axis.SetX(this[2, 1] - this[1, 2]);
                axis.SetY(this[0, 2] - this[2, 0]);
                axis.SetZ(this[1, 0] - this[0, 1]);
            }
            else
            {
                // Trace is less than zero, so need to determine which
                // major diagonal is largest
                if ((d0 > d1) && (d0 > d2))
                {
                    axis.SetX(0.5f);
                    axis.SetY(this[0, 1] + this[1, 0]);
                    axis.SetZ(this[0, 2] + this[2, 0]);
                }
                else
                if (d1 > d2)
                {
                    axis.SetX(this[0, 1] + this[1, 0]);
                    axis.SetY(0.5f);
                    axis.SetZ(this[1, 2] + this[2, 1]);
                }
                else
                {
                    axis.SetX(this[0, 2] + this[2, 0]);
                    axis.SetY(this[1, 2] + this[2, 1]);
                    axis.SetZ(0.5f);
                }
            }
            axis.Normalise();

            return(axis);
        }
Example #2
0
        public Vector3D Axis()
        {
            Vector3D axis = new Vector3D(0,0,0);

            float d0 = this[0,0], d1 = this[1,1], d2 = this[2,2];

            // The trace determines the method of decomposition
            float rr = 1.0f + d0 + d1 + d2;

            if (rr > 0) 
            {
                axis.SetX( this[2,1] - this[1,2] );
                axis.SetY( this[0,2] - this[2,0] );
                axis.SetZ( this[1,0] - this[0,1] );
            } 
            else 
            {
                // Trace is less than zero, so need to determine which
                // major diagonal is largest
                if ((d0 > d1) && (d0 > d2)) 
                {
                    axis.SetX( 0.5f );
                    axis.SetY( this[0,1] + this[1,0] );
                    axis.SetZ( this[0,2] + this[2,0] );
                } 
                else 
                    if (d1 > d2) 
                    {
                        axis.SetX( this[0,1] + this[1,0] );
                        axis.SetY( 0.5f );
                        axis.SetZ( this[1,2] + this[2,1] );
                    } 
                    else 
                    {
                        axis.SetX( this[0,2] + this[2,0] );
                        axis.SetY( this[1,2] + this[2,1] );
                        axis.SetZ( 0.5f );
                    }
            }
            axis.Normalise();

            return (axis);
        }