예제 #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 FQuat GetNormalized(float Tolerance = Const.SMALL_NUMBER)
        {
            FQuat Result = this;

            Result.Normalize(Tolerance);
            return(Result);
        }
예제 #2
0
        public void SetFromMatrix(FMatrix InMatrix)
        {
            FMatrix 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 FQuat(M);
            Translation = InMatrix.GetOrigin();

            // Normalize rotation
            Rotation.Normalize();
        }