Пример #1
0
        public static System.Windows.Media.Media3D.Matrix3D SetSpin(
            this System.Windows.Media.Media3D.Matrix3D matrix, double spin)
        {
            Vector3D translation = new System.Windows.Media.Media3D.Vector3D(matrix.OffsetX, matrix.OffsetY, matrix.OffsetZ);

            // backoff translation
            matrix.Translate(new System.Windows.Media.Media3D.Vector3D(-translation.X, -translation.Y, -translation.Z));

            Vector3D localZ = matrix.Transform(new System.Windows.Media.Media3D.Vector3D(0, 0, 1));

            // backoff existing spin
            matrix.Rotate(new System.Windows.Media.Media3D.Quaternion(localZ, matrix.GetSpin() * -1.0));
            matrix.Rotate(new System.Windows.Media.Media3D.Quaternion(localZ, spin));
            // add back translation
            matrix.Translate(translation);
            return(matrix);
        }