Matrix used to transform between ucs coordinate and world coordinate.
Exemple #1
0
        /// <summary>
        /// Get a matrix which can transform points to 2D
        /// </summary>
        /// <returns>matrix which can transform points to 2D</returns>
        public Matrix4 GetTo2DMatrix()
        {
            Vector4 xAxis = new Vector4(1, 0 ,0);
            //Because Y axis in windows UI is downward, so we should Multiply(-1) here
            Vector4 yAxis = new Vector4(0, -1, 0);
            Vector4 zAxis = new Vector4(0, 0, 1);

            Matrix4 result = new Matrix4(xAxis, yAxis, zAxis);
            return result;
        }
Exemple #2
0
        /// <summary>
        /// rotate slab with specific angle
        /// </summary>
        /// <param name="xAngle">rotate angle in X direction</param>
        /// <param name="yAngle">rotate angle in Y direction</param>
        public void RotateFloor(double xAngle, double yAngle)
        {
            if (0 == xAngle && 0 == yAngle) { return; }
            m_rotateAngleX += xAngle;
            m_rotateAngleY += yAngle;

            Matrix4 rotateX = Matrix4.RotateX(m_rotateAngleX);
            Matrix4 rotateY = Matrix4.RotateY(m_rotateAngleY);
            Matrix4 rotateMatrix = Matrix4.Multiply(rotateX, rotateY);

            m_rotateMatrix = Matrix4.Multiply(m_MoveToPictureBoxCenter.Inverse(), rotateMatrix);
            m_rotateMatrix = Matrix4.Multiply(m_rotateMatrix, m_MoveToPictureBoxCenter);
        }
Exemple #3
0
 /// <summary>
 /// Calculate geometry info for Slab
 /// </summary>
 public void GetSlabProfileInfo()
 {
     // get all the edges of the Slab
     m_edges = GetFloorEdges();
     // Get a matrix which can transform points to 2D
     m_to2DMatrix = GetTo2DMatrix();
     // get the boundary of all the points
     m_boundPoints = GetBoundsPoints();
     // get a matrix which can keep all the points in the center of the canvas
     m_moveToCenterMatrix = GetMoveToCenterMatrix();
     // get a matrix for scaling all the points and lines within the canvas
     m_scaleMatrix = GetScaleMatrix();
     // get a matrix for moving all point in the middle of PictureBox
     m_MoveToPictureBoxCenter = GetMoveToCenterOfPictureBox();
     // transform 3D points to 2D
     m_transformMatrix = Get3DTo2DMatrix();
     // transform from 2D to 3D
     m_restoreMatrix = Get2DTo3DMatrix();
 }
Exemple #4
0
 /// <summary>
 /// make rotate matrix null
 /// </summary>
 public void ClearRotateMatrix()
 {
     m_rotateMatrix = null;
 }
Exemple #5
0
        /// <summary>
        /// get a matrix used to rotate object specific angle on Z direction
        /// </summary>
        /// <param name="angle">rotate angle</param>
        /// <returns>matrix which rotate object specific angle on Z direction</returns>
        public static Matrix4 RotateZ(double angle)
        {
            Matrix4 rotateX = new Matrix4();
            rotateX.Type = MatrixType.Rotation;
            rotateX.Identity();
            double sin = (double)Math.Sin(angle);
            double cos = (double)Math.Cos(angle);
            rotateX.Matrix[1, 1] = cos;
            rotateX.Matrix[1, 2] = sin;

            rotateX.Matrix[2, 1] = -sin;
            rotateX.Matrix[2, 2] = cos;
            return rotateX;
        }
Exemple #6
0
 /// <summary>
 ///  multiply matrix left and right
 /// </summary>
 /// <param name="left">left matrix</param>
 /// <param name="right">right matrix</param>
 /// <returns></returns>
 public static Matrix4 Multiply(Matrix4 left, Matrix4 right)
 {
     Matrix4 result = new Matrix4();
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             result[i, j] = left[i, 0] * right[0, j] + left[i, 1] * right[1, j]
                 + left[i, 2] * right[2, j] + left[i, 3] * right[3, j];
         }
     }
     return result;
 }
Exemple #7
0
 /// <summary>
 /// make rotate matrix null
 /// </summary>
 public void ClearRotateMatrix()
 {
     m_rotateMatrix = null;
 }