Canguro.Model.LineElement.RotationMatrix C# (CSharp) Method

RotationMatrix() public method

This method builds a rotation matrix from the global coordinate system to the local coordinate system formed by the local axes
public RotationMatrix ( Microsoft &m ) : void
m Microsoft The rotation matrix to build
return void
        public void RotationMatrix (out Microsoft.DirectX.Matrix m)
        {
            m = Microsoft.DirectX.Matrix.Identity;

            //Obtain local axes
            Microsoft.DirectX.Vector3[] axes = LocalAxes;

            // Build rotation matrix
            m.M11 = axes[0].X; m.M12 = axes[0].Y; m.M13 = axes[0].Z;
            m.M21 = axes[1].X; m.M22 = axes[1].Y; m.M23 = axes[1].Z;
            m.M31 = axes[2].X; m.M32 = axes[2].Y; m.M33 = axes[2].Z;
        }

Usage Example

        protected Vector3 toLocal(LineElement line, Vector3 v)
        {
            Matrix r;

            line.RotationMatrix(out r);
            return Vector3.TransformCoordinate(v, Matrix.TransposeMatrix(r));
        }