// modelMatrix is passed by reference for efficiency only.  It is not modified.
        private static void TransformSingular(ref Matrix3D modelMatrix,
                                              ref Point3D origin, ref Vector3D direction)
        {
            double [,] matrix = TransformedLineMatrix(ref modelMatrix, ref origin, ref direction);
            matrix            = Square(matrix);

            double[,] eigen = new double[, ] {
                { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 }
            };

            // We'll just do 5 iterations with each pair because according to my results & Golub &
            // Van Loan this process converges quickly.
            int iterations = 5 * s_pairsCount;

            for (int iter = 0; iter < iterations; ++iter)
            {
                int            pair = iter % s_pairsCount;
                JacobiRotation jrot = new JacobiRotation(s_pairs[pair, 0], s_pairs[pair, 1], matrix);
                matrix = jrot.LeftRightMultiply(matrix);
                eigen  = jrot.RightMultiply(eigen);
            }

            // That was it as far as finding eigenvectors

            int evec1, evec2;

            FindSmallestTwoDiagonal(matrix, out evec1, out evec2);

            // The eigenvectors corresponding to the two smallest eigenvalues are columns evec1 &
            // evec2.  These, in homogeneous space, are two different points on our line.  We are
            // going to convert them to an affine point & vector.
            ColumnsToAffinePointVector(eigen, evec1, evec2, out origin, out direction);
        }
Beispiel #2
0
        // modelMatrix is passed by reference for efficiency only.  It is not modified.
        private static void TransformSingular(ref Matrix3D modelMatrix,
                                              ref Point3D origin, ref Vector3D direction)
        {
            double [,] matrix = TransformedLineMatrix(ref modelMatrix, ref origin, ref direction);
            matrix = Square(matrix);
                
            double[,] eigen = new double[,]{ {1,0,0,0}, {0,1,0,0}, {0,0,1,0}, {0,0,0,1} };

            // We'll just do 5 iterations with each pair because according to my results & Golub &
            // Van Loan this process converges quickly.
            int iterations = 5 * s_pairsCount;
            for (int iter = 0; iter < iterations; ++iter)
            {
                int pair = iter % s_pairsCount;
                JacobiRotation jrot = new JacobiRotation(s_pairs[pair,0],s_pairs[pair,1],matrix);
                matrix = jrot.LeftRightMultiply(matrix);
                eigen = jrot.RightMultiply(eigen);
            }

            // That was it as far as finding eigenvectors

            int evec1,evec2;
            FindSmallestTwoDiagonal(matrix, out evec1, out evec2);

            // The eigenvectors corresponding to the two smallest eigenvalues are columns evec1 &
            // evec2.  These, in homogeneous space, are two different points on our line.  We are
            // going to convert them to an affine point & vector.
            ColumnsToAffinePointVector(eigen, evec1, evec2, out origin, out direction);
        }