CNCMaps.Engine.Rendering.VxlRenderer.ExtractRotationVector C# (CSharp) Method

ExtractRotationVector() static private method

static private ExtractRotationVector ( float mtx ) : Vector3
mtx float
return Vector3
        static Vector3 ExtractRotationVector(float[] mtx)
        {
            var tVec = MatrixVectorMultiply(mtx, zVector);
            var tOrigin = MatrixVectorMultiply(mtx, zeroVector);
            tVec[0] -= tOrigin[0] * tVec[3] / tOrigin[3];
            tVec[1] -= tOrigin[1] * tVec[3] / tOrigin[3];
            tVec[2] -= tOrigin[2] * tVec[3] / tOrigin[3];

            // Renormalize
            var w = (float)Math.Sqrt(tVec[0] * tVec[0] + tVec[1] * tVec[1] + tVec[2] * tVec[2]);
            tVec[0] /= w;
            tVec[1] /= w;
            tVec[2] /= w;
            tVec[3] = 1f;

            return new Vector3(tVec[0], tVec[1], tVec[2]);
        }