Esempio n. 1
0
    def template_rej(self, name, data):
        from opan.utils.vector import rej

        v1 = data[self.DType.V1]
        v2 = data[self.DType.V2]
        r = rej(v1, v2)
        for i, t in enumerate(zip(r, data[self.DType.REJ])):
            self.assertAlmostEqual(*t, delta=1e-6,
                       msg="Test {0}: Index {1}; V1 = {2}; V2 = {3}"
                            .format(name, i, v1, v2))
Esempio n. 2
0
    def template_rej(self, name, data):
        from opan.utils.vector import rej

        v1 = data[self.DType.V1]
        v2 = data[self.DType.V2]
        r = rej(v1, v2)
        for i, t in enumerate(zip(r, data[self.DType.REJ])):
            self.assertAlmostEqual(
                *t,
                delta=1e-6,
                msg="Test {0}: Index {1}; V1 = {2}; V2 = {3}".format(
                    name, i, v1, v2))
Esempio n. 3
0
    def test_Utils_Vector_OrthoBasis_GoodDefinedRefVec(self):
        import numpy as np
        from opan.utils.vector import ortho_basis as ob
        from opan.utils.vector import vec_angle as ang
        from opan.utils.vector import rej

        nv = [2.5, 31.15, -25.1884]
        rv = [-12.15, 0.0034, 35.18]

        on1, on2 = ob(nv, rv)

        self.assertAlmostEqual(
            np.dot(nv, on1),
            0.0,
            delta=1e-10,
            msg="Normal vector not normal to first basis vector")

        self.assertAlmostEqual(
            np.dot(nv, on2),
            0.0,
            delta=1e-10,
            msg="Normal vector not normal to second basis vector")

        self.assertAlmostEqual(np.dot(on1, on2),
                               0.0,
                               delta=1e-10,
                               msg="Basis vectors not normal")

        self.assertAlmostEqual(np.sum(np.power(on1, 2.)),
                               1.0,
                               delta=1e-10,
                               msg="First basis vector not normalized")

        self.assertAlmostEqual(np.sum(np.power(on2, 2.)),
                               1.0,
                               delta=1e-10,
                               msg="Second basis vector not normalized")

        self.assertAlmostEqual(ang(nv, np.cross(on1, on2)),
                               0.0,
                               delta=1e-5,
                               msg="Incorrect handedness of basis vectors")

        self.assertAlmostEqual(
            ang(rej(rv, nv), on1),
            0.0,
            delta=1e-5,
            msg="First basis vector not aligned with reference")
Esempio n. 4
0
    def test_Utils_Vector_OrthoBasis_GoodDefinedRefVec(self):
        import numpy as np
        from opan.utils.vector import ortho_basis as ob
        from opan.utils.vector import vec_angle as ang
        from opan.utils.vector import rej

        nv = [2.5, 31.15, -25.1884]
        rv = [-12.15, 0.0034, 35.18]

        on1, on2 = ob(nv, rv)

        self.assertAlmostEqual(np.dot(nv, on1), 0.0,
                delta=1e-10,
                msg="Normal vector not normal to first basis vector")

        self.assertAlmostEqual(np.dot(nv, on2), 0.0,
                delta=1e-10,
                msg="Normal vector not normal to second basis vector")

        self.assertAlmostEqual(np.dot(on1, on2), 0.0,
                delta=1e-10,
                msg="Basis vectors not normal")

        self.assertAlmostEqual(np.sum(np.power(on1, 2.)), 1.0,
                delta=1e-10,
                msg="First basis vector not normalized")

        self.assertAlmostEqual(np.sum(np.power(on2, 2.)), 1.0,
                delta=1e-10,
                msg="Second basis vector not normalized")

        self.assertAlmostEqual(ang(nv, np.cross(on1, on2)), 0.0,
                delta=1e-5,
                msg="Incorrect handedness of basis vectors")

        self.assertAlmostEqual(ang(rej(rv, nv), on1), 0.0,
                delta=1e-5,
                msg="First basis vector not aligned with reference")