Пример #1
0
        /**
         * Get a normalized copy of this quaternion.
         * If it is too small, returns an identity quaternion.
         *
         * @param Tolerance Minimum squared length of quaternion for normalization.
         */
        public Quat GetNormalized(float Tolerance = Const.SMALL_NUMBER)
        {
            Quat Result = this;

            Result.Normalize(Tolerance);
            return(Result);
        }
Пример #2
0
        public void SetFromMatrix(Matrix InMatrix)
        {
            Matrix M = InMatrix;

            // Get the 3D scale from the matrix
            Scale3D = M.ExtractScaling();

            // If there is negative scaling going on, we handle that here
            if (InMatrix.Determinant() < 0.0f)
            {
                // Assume it is along X and modify transform accordingly.
                // It doesn't actually matter which axis we choose, the 'appearance' will be the same
                Scale3D.X *= -1.0f;
                M.SetAxis(0, -M.GetScaledAxis(EAxis.X));
            }

            Rotation    = new Quat(M);
            Translation = InMatrix.GetOrigin();

            // Normalize rotation
            Rotation.Normalize();
        }