示例#1
0
        /// <summary>
        /// Rotate the specified matrix.
        /// </summary>
        /// <param name="matrix">Matrix.</param>
        public void Rotate(double[,] matrix)
        {
            for (int i = 0; i < Points.Count; i++)
            {
                point p = new point();
                p.X = (float)((Points[i].X * matrix[0, 0])
                     + (Points[i].Y * matrix[0, 1])
                     + (Points[i].Z * matrix[0, 2]));

                p.Y = (float)((Points[i].X * matrix[1, 0])
                     + (Points[i].Y * matrix[1, 1])
                     + (Points[i].Z * matrix[1, 2]));

                p.Z = (float)((Points[i].X * matrix[2, 0])
                     + (Points[i].Y * matrix[2, 1])
                     + (Points[i].Z * matrix[2, 2]));
            }
            Rescale();
        }
示例#2
0
        /// <summary>
        /// Transform the instance to a specified matrix.
        /// </summary>
        /// <param name="matrix">Matrix.</param>
        public void Transform(double[,] matrix)
        {
            if (matrix.GetLength(1) == 4)
            {
                for (int i = 0; i < Points.Count; i++)
                {
                    point p = new point();

                    p.X = (float)((Points[i].X * matrix[0, 0])
                        + (Points[i].Y * matrix[0, 1])
                        + (Points[i].Z * matrix[0, 2])
                        + (Points[i].W * matrix[0, 3]));

                    p.Y = (float)((Points[i].X * matrix[1, 0])
                         + (Points[i].Y * matrix[1, 1])
                         + (Points[i].Z * matrix[1, 2])
                         + (Points[i].W * matrix[1, 3]));

                    p.Z = (float)((Points[i].X * matrix[2, 0])
                         + (Points[i].Y * matrix[2, 1])
                         + (Points[i].Z * matrix[2, 2])
                         + (Points[i].W * matrix[2, 3]));

                    p.W = (float)((Points[i].X * matrix[3, 0])
                         + (Points[i].Y * matrix[3, 1])
                         + (Points[i].Z * matrix[3, 2])
                         + (Points[i].W * matrix[3, 3]));
                    Points[i] = p;
                }
            }
            else
            {
                for (int i = 0; i < Points.Count; i++)
                {
                    point p = new point();

                    p.X = (float)(
                        (Points[i].X * matrix[0, 0])
                         + (Points[i].Y * matrix[0, 1])
                         + (Points[i].Z * matrix[0, 2]));
                    p.Y = (float)(
                        (Points[i].X * matrix[1, 0])
                       + (Points[i].Y * matrix[1, 1])
                       + (Points[i].Z * matrix[1, 2]));
                    p.Z = (float)(
                        (Points[i].X * matrix[2, 0])
                         + (Points[i].Y * matrix[2, 1])
                         + (Points[i].Z * matrix[2, 2]));
                    Points[i] = p;
                }

            }
            Rescale();
        }
示例#3
0
 /// <summary>
 /// Rescale this instance.
 /// </summary>
 public void Rescale()
 {
     Parallel.For(0, Points.Count, i =>
      {
          point newPoint = new point();
          newPoint.X = Points[i].X / Points[i].W;
          newPoint.Y = Points[i].Y / Points[i].W;
          newPoint.Z = Points[i].Z / Points[i].W;
          newPoint.W = 1;//Points[i].F / Points[i].F;
          Points[i] = newPoint;
      });
 }