コード例 #1
0
 public void Rotate(double xDeg, double yDeg, double zDeg)
 {
     for (int i = 0; i < baseListOfPoints.Count; i++)
     {
         Figure.currentListOfPoints[i] = MatrixOperations.RotateMatrix(baseListOfPoints[i], xDeg, yDeg, zDeg);
     }
 }
コード例 #2
0
 public static double[] ProjectionPoints(double[] input) // inpu len = 3
 {
     double[] consis = new double[input.Length + 1];
     for (int i = 0; i < input.Length; i++)
     {
         consis[i] = input[i];
     }
     consis[3] = 1;
     double[] output = MatrixOperations.MultipleMatrixAndVector(projectionMatrix, consis);
     output = MatrixOperations.MakeVectorConsistent(output);
     return(new double[] { output[0], output[1] });
 }
コード例 #3
0
        /// <summary>
        /// Fill plane with appriopriate color. Whole plane is shaded with one color
        /// </summary>
        /// <param name="plane">plane (trinagle) </param>
        /// <param name="l1">source of light </param>
        /// <returns></returns>
        public static byte GetColor(Triangle plane, double[] l1)
        {
            double[] normal = new double[] { plane.A, plane.B, plane.C };
            l1     = MatrixOperations.Normalize(l1);
            normal = MatrixOperations.Normalize(normal);

            double scalar = MatrixOperations.VectorScalar(l1, normal);
            double color  = Math.Max(20, 255 * Math.Max(0, scalar));

            if (color == 20)
            {
                plane.FlipNormal();
                normal = new double[] { plane.A, plane.B, plane.C };
                normal = MatrixOperations.Normalize(normal);
                scalar = MatrixOperations.VectorScalar(l1, normal);
                color  = Math.Max(20, 255 * Math.Max(0, scalar));
                plane.FlipNormal();
            }
            return((byte)color);
        }