Beispiel #1
0
        public static void Rot12(SMat3 m, float c, float s)
        {
            float [] cs  = Svd.CalcSymmetricGivensCoefficients(m.m11, m.m12, m.m22, c, s);
            float    cc  = cs[0] * cs[0];
            float    ss  = cs[1] * cs[1];
            float    mix = 2 * c * s * m.m12;

            m.SetSymmetric(m.m00, c * m.m01 - s * m.m02, s * m.m01 + c * m.m02,
                           cc * m.m11 - mix + ss * m.m22, 0, ss * m.m11 + mix + cc * m.m22);
        }
Beispiel #2
0
        public static void Rot01(SMat3 m, float c, float s)
        {
            float [] cs  = Svd.CalcSymmetricGivensCoefficients(m.m00, m.m01, m.m11, c, s);
            float    cc  = cs[0] * cs[0];
            float    ss  = cs[1] * cs[1];
            float    mix = 2 * c * s * m.m01;

            m.SetSymmetric(cc * m.m00 - mix + ss * m.m11, 0, c * m.m02 - s * m.m12,
                           ss * m.m00 + mix + cc * m.m11, s * m.m02 + c * m.m12, m.m22);
        }
Beispiel #3
0
        public static float solveLeastSquares(Mat3 a, Vector3 b, Vector3 x, float svd_tol, int svd_sweeps, float pinv_tol)
        {
            Mat3    at  = new Mat3();
            SMat3   ata = new SMat3();
            Vector3 atb = new Vector3();

            MatUtils.Transpose(at, a);
            MatUtils.Mmul_ata(ata, a);
            atb = MatUtils.Vmul(at, b);
            return(Svd.SolveSymmetric(ata, atb, x, svd_tol, svd_sweeps, pinv_tol));
        }