Example #1
0
        /// <summary>
        /// Rotation matrix for OZ.
        /// </summary>
        /// <param name="angle">Rotation angle in degrees</param>
        /// <returns>OZ rotation matrix</returns>
        private Matrix4x4 BuildRotationZMatrix(float angle)
        {
            Matrix4x4 rotationZ = Matrix4x4.Identity;
            float     rad       = MathExtension.ToRadians(angle);
            float     cos       = (float)Math.Cos(rad);
            float     sin       = (float)Math.Sin(rad);

            rotationZ.M11 = cos;
            rotationZ.M12 = -sin;
            rotationZ.M21 = sin;
            rotationZ.M22 = cos;

            return(rotationZ);
        }
Example #2
0
        /// <summary>
        /// Rotation matrix for OX.
        /// </summary>
        /// <param name="angle">Rotation angle in degrees</param>
        /// <returns>OX rotation matrix</returns>
        private Matrix4x4 BuildRotationXMatrix(float angle)
        {
            Matrix4x4 rotationX = Matrix4x4.Identity;
            float     rad       = MathExtension.ToRadians(angle);
            float     cos       = (float)Math.Cos(rad);
            float     sin       = (float)Math.Sin(rad);

            rotationX.M22 = cos;
            rotationX.M23 = -sin;
            rotationX.M32 = sin;
            rotationX.M33 = cos;

            return(rotationX);
        }
Example #3
0
        /// <summary>
        /// Rotation matrix for OY.
        /// </summary>
        /// <param name="angle">Rotation angle in degrees</param>
        /// <returns>OY rotation matrix</returns>
        private Matrix4x4 BuildRotationYMatrix(float angle)
        {
            Matrix4x4 rotationY = Matrix4x4.Identity;
            float     rad       = MathExtension.ToRadians(angle);
            float     cos       = (float)Math.Cos(rad);
            float     sin       = (float)Math.Sin(rad);

            rotationY.M11 = cos;
            rotationY.M13 = sin;
            rotationY.M31 = -sin;
            rotationY.M33 = cos;

            return(rotationY);
        }