/// <summary> /// calculate the matrix used to transform 3D to 2D /// </summary> /// <returns>maxtrix is use to transform 3d points to 2d</returns> public Matrix4 Get3DTo2DMatrix() { Matrix4 result = Matrix4.Multiply( m_to2DMatrix.Inverse(), m_moveToCenterMatrix.Inverse()); result = Matrix4.Multiply(result, m_scaleMatrix); return(Matrix4.Multiply(result, m_MoveToPictureBoxCenter)); }
/// <summary> /// calculate the matrix used to transform 2D to 3D /// </summary> /// <returns>maxtrix is use to transform 2d points to 3d</returns> public Matrix4 Get2DTo3DMatrix() { Matrix4 matrix = Matrix4.Multiply( m_MoveToPictureBoxCenter.Inverse(), m_scaleMatrix.Inverse()); matrix = Matrix4.Multiply( matrix, m_moveToCenterMatrix); return(Matrix4.Multiply(matrix, m_to2DMatrix)); }
/// <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); }