예제 #1
0
파일: test_node.py 프로젝트: raysect/source
    def test_to_invalid(self):
        """Calling the to() method with invalid arguements."""

        # two nodes, not linked so each forms a seperate scenegraph
        a = Node()
        b = Node()

        with self.assertRaises(ValueError, msg="Attempting to find a transform between two independent scenegraphs should have raised a ValueError exception."):
            a.to(b)

        with self.assertRaises(TypeError, msg="Passing an invalid arguement (a string) did not raise a TypeError."):
            a.to("bad input")
예제 #2
0
    def test_to_invalid(self):
        """Calling the to() method with invalid arguements."""

        # two nodes, not linked so each forms a seperate scenegraph
        a = Node()
        b = Node()

        with self.assertRaises(ValueError, msg="Attempting to find a transform between two independent scenegraphs should have raised a ValueError exception."):
            a.to(b)

        with self.assertRaises(TypeError, msg="Passing an invalid arguement (a string) did not raise a TypeError."):
            a.to("bad input")
예제 #3
0
파일: test_node.py 프로젝트: raysect/source
    def test_to(self):
        """Test the to() method returns a matrix transform between nodes.

        The returned affine matrix should transform a point in the coordinate
        space defined by the calling node to the coordinate space defined by the
        specified node in the tree."""

        # build test tree
        root = Node()
        a1 = Node(root, translate(1,0,0))
        a2 = Node(a1, translate(10,0,0))
        b1 = Node(root, translate(0,1,0))
        b2 = Node(b1, translate(0,10,0))
        c = Node(root, translate(0,0,1))

        # test a2 to root
        self.assertTransformAlmostEqual(a2.to(root), translate(11,0,0), delta = 1e-14, msg="The a2.to(root) transform is incorrect.")

        # test b2 to root
        self.assertTransformAlmostEqual(b2.to(root), translate(0,11,0), delta = 1e-14, msg="The b2.to(root) transform is incorrect.")

        # test a2 to b2
        self.assertTransformAlmostEqual(a2.to(b2), translate(11,-11,0), delta = 1e-14, msg="The a2.to(b2) transform is incorrect.")

        # test b2 to a2
        self.assertTransformAlmostEqual(b2.to(a2), translate(-11,11,0), delta = 1e-14, msg="The b2.to(a2) transform is incorrect.")

        # test a2 to c
        self.assertTransformAlmostEqual(a2.to(c), translate(11,0,-1), delta = 1e-14, msg="The a2.to(c) transform is incorrect.")

        # test c to b1
        self.assertTransformAlmostEqual(c.to(b1), translate(0,-1,1), delta = 1e-14, msg="The c.to(b1) transform is incorrect.")
예제 #4
0
    def test_to(self):
        """Test the to() method returns a matrix transform between nodes.

        The returned affine matrix should transform a point in the coordinate
        space defined by the calling node to the coordinate space defined by the
        specified node in the tree."""

        # build test tree
        root = Node()
        a1 = Node(root, translate(1,0,0))
        a2 = Node(a1, translate(10,0,0))
        b1 = Node(root, translate(0,1,0))
        b2 = Node(b1, translate(0,10,0))
        c = Node(root, translate(0,0,1))

        # test a2 to root
        self.assertTransformAlmostEqual(a2.to(root), translate(11,0,0), delta = 1e-14, msg="The a2.to(root) transform is incorrect.")

        # test b2 to root
        self.assertTransformAlmostEqual(b2.to(root), translate(0,11,0), delta = 1e-14, msg="The b2.to(root) transform is incorrect.")

        # test a2 to b2
        self.assertTransformAlmostEqual(a2.to(b2), translate(11,-11,0), delta = 1e-14, msg="The a2.to(b2) transform is incorrect.")

        # test b2 to a2
        self.assertTransformAlmostEqual(b2.to(a2), translate(-11,11,0), delta = 1e-14, msg="The b2.to(a2) transform is incorrect.")

        # test a2 to c
        self.assertTransformAlmostEqual(a2.to(c), translate(11,0,-1), delta = 1e-14, msg="The a2.to(c) transform is incorrect.")

        # test c to b1
        self.assertTransformAlmostEqual(c.to(b1), translate(0,-1,1), delta = 1e-14, msg="The c.to(b1) transform is incorrect.")