예제 #1
0
        public void Rotate(double angle, RotationLineEnum rotationLine)
        {
            if (this.elements.Count == 0)
            {
                return;
            }

            double radians = angle.ToRadians();

            this.object3d.Rotate(radians, rotationLine);
            this.RedrawObject();
        }
예제 #2
0
        /// <summary>
        /// Returns rotation matrix by specified rotation line
        /// </summary>
        /// <param name="rotationLineEnum">Specifies line of rotation</param>
        /// <param name="alpha">An angle measured in radians</param>
        /// <returns></returns>
        public static double[,] GetRotationMatrix(this RotationLineEnum rotationLineEnum, double alpha)
        {
            double[,] rotationMatrix = null;
            switch (rotationLineEnum)
            {
            case RotationLineEnum.AboutOX:
                rotationMatrix = RotationMatrix3D.GetXRotationMatrix(alpha);
                break;

            case RotationLineEnum.AboutOY:
                rotationMatrix = RotationMatrix3D.GetYRotationMatrix(alpha);
                break;

            case RotationLineEnum.AboutOZ:
                rotationMatrix = RotationMatrix3D.GetZRotationMatrix(alpha);
                break;
            }

            return(rotationMatrix);
        }
예제 #3
0
        /// <summary>
        /// Rotate each node about specified axis by the specified angle
        /// </summary>
        /// <param name="alpha">An angle measured in radians</param>
        ///  <param name="rotateAboutEnum">Specifies line of rotation (see RotationLineEnum)</param>

        public void Rotate(double alpha, RotationLineEnum rotationLineEnum)
        {
            //// Update mass center if it is null
            this.GetMassCenter(false);

            //// Move the origin to the mass center
            Node prevOrigin = this.MoveTheOrigin(this.MassCenter.X, this.MassCenter.Y, this.MassCenter.Z);

            //// Specify rotation matrix
            double[,] rotationMatrix = rotationLineEnum.GetRotationMatrix(alpha);

            //// Rotate each node about specified axis axis
            for (int i = 0; i < this.Nodes.Count; i++)
            {
                double[] result = Matrix.Multiply(rotationMatrix, this.Nodes[i].ToVector());
                this.Nodes[i].SetValuesFromVector(result);
            }

            //// Revert (move the origin to previous coordinate)
            this.MoveTheOrigin(prevOrigin.X, prevOrigin.Y, prevOrigin.Z);

            //// Update mass center
            this.GetMassCenter(true);
        }