Example #1
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")
Example #2
0
    def test_Utils_Vector_OrthoBasis_GoodRandomRefVec(self):
        import numpy as np
        from opan.utils.vector import ortho_basis as ob
        from opan.utils.vector import vec_angle as ang

        nv = [8.5, -3.15, -2.1884]

        on1, on2 = ob(nv)

        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")
Example #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")
Example #4
0
    def test_Utils_Vector_OrthoBasis_GoodRandomRefVec(self):
        import numpy as np
        from opan.utils.vector import ortho_basis as ob
        from opan.utils.vector import vec_angle as ang

        nv = [8.5, -3.15, -2.1884]

        on1, on2 = ob(nv)

        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")