Example #1
0
        static public Vector <double> WersorFromPlane(Point p1, Point p2, Point p3)
        {
            /* Matrix<double> A = Matrix<double>.Build.Dense(4, 4, 0);
             * A[0, 0] = p1.x; A[0, 1] = p1.y; ; A[0, 2] = p1.z; A[0, 3] = 1;
             * A[1, 0] = p2.x; A[1, 1] = p2.y; ; A[1, 2] = p2.z; A[1, 3] = 1;
             * A[2, 0] = p3.x; A[2, 1] = p3.y; ; A[2, 2] = p3.z; A[2, 3] = 1;
             * A[3, 0] = 1.0; A[3, 1] = 0; ; A[3, 2] = 0; A[3, 3] = 0;
             * if (A.Determinant() == 0) return Vector<double>.Build.Dense(3, 0);
             * Vector<double> b = Vector<double>.Build.DenseOfArray(new double[4] { 0, 0, 0, 1 });
             * Vector<double> res = A.Solve(b);
             * b = Vector<double>.Build.Dense(3);
             * for (int i = 0; i < 3; i++)
             *   b[i] = res[i];*/

            Vector <double> b = MatrixExt.Cross(p1 - p3, p2 - p3);

            if (b.L1Norm() == 0)
            {
                throw new AlgorithmException("Linear points");
            }
            return(b.Normalize(2));
        }
Example #2
0
 private double GetArea()
 {
     return(MatrixExt.Cross(vertix[1] - vertix[0], vertix[2] - vertix[0]).Norm(2) / 2);
 }