Exemple #1
0
 def test_intersectLine(self):
     p = Plane((0.,0.,0.), (-1.,0.,0.), (0.,-1.,0.))
     
     a = (0.,0.,-1.)
     b = (0.,0.,1.)
     
     self.assertTrue(p.intersectLine(a, b) == (0.,0.,0.))
     
     a = (1.,1.,-1.)
     b = (1.,1.,1.)
     
     self.assertTrue(p.intersectLine(a, b) == (1.,1.,0.))
Exemple #2
0
 def test_flip(self):
     p1 = Plane((0.,0.,0.), (-1.,0.,0.), (0.,-1.,0.))
     
     self.assertTrue(p1.distanceTo((0.,0.,-1.5)) == -1.5)
     self.assertTrue(p1.distanceTo((0.,0.,1.5)) == 1.5)
     
     p1.flip()
     
     self.assertTrue(p1.distanceTo((0.,0.,-1.5)) == 1.5)
     self.assertTrue(p1.distanceTo((0.,0.,1.5)) == -1.5)
Exemple #3
0
 def test_transform(self):
     p = Plane.fromNormal((0.,0.,0.), (0.,0.,1.))
     tr = Transform().translate(0.,0.,1.)
     
     self.assertTrue(p.distanceTo((0.,0.,-1.5)) == -1.5)
     self.assertTrue(p.origin == Point(0.,0.,0.))
     
     p.transform(tr)
     
     self.assertTrue(p.distanceTo((0.,0.,-1.5)) == -2.5)
     self.assertTrue(p.origin == Point(0.,0.,1.))
Exemple #4
0
 def test_fromFrame(self):
     p1 = Plane.fromFrame((0.,0.,0.), (-1.,0.,0.), (0.,-1.,0.))
     
     self.assertTrue(p1.origin == Point(0.,0.,0.))
     self.assertTrue(p1.xaxis == Vector(-1.,0.,0.))
     self.assertTrue(p1.yaxis == Vector(0.,-1.,0.))
     self.assertTrue(p1.zaxis == Vector(0.,0.,1.))
     
     self.assertTrue(p1.a == 0.)
     self.assertTrue(p1.b == 0.)
     self.assertTrue(p1.c == 1.)
     self.assertTrue(p1.d == 0.)
Exemple #5
0
    def test_mirror(self):
        eq = self.almostEqual

        e1 = Edge().createLine((0., 0., 0.), (1., 0., 0.))
        plane = Plane.fromNormal((0., 0., 0.), (1., 0., 0.))
        e1.mirror(plane)
        v1, v2 = e1

        eq(v1, (0., 0., 0.))
        eq(v2, (-1., 0., 0.))

        e2 = e1.mirror(plane, copy=True)
        v1, v2 = e1
        eq(v1, (0., 0., 0.))
        eq(v2, (-1., 0., 0.))

        v1, v2 = e2
        eq(v1, (0., 0., 0.))
        eq(v2, (1., 0., 0.))
Exemple #6
0
 def test_mirror(self):
     eq = self.almostEqual
     
     e1 = Edge().createLine((0.,0.,0.), (1.,0.,0.))
     plane = Plane.fromNormal((0.,0.,0.), (1.,0.,0.))
     e1.mirror(plane)
     v1, v2 = e1
     
     eq(v1, (0.,0.,0.))
     eq(v2, (-1.,0.,0.))
     
     e2 = e1.mirror(plane, copy = True)
     v1, v2 = e1
     eq(v1, (0.,0.,0.))
     eq(v2, (-1.,0.,0.))
     
     v1, v2 = e2
     eq(v1, (0.,0.,0.))
     eq(v2, (1.,0.,0.))
Exemple #7
0
 def test_closestPoint(self):
     p1 = Plane((0.,0.,0.), (-1.,0.,0.), (0.,-1.,0.))
     
     self.assertTrue(p1.closestPoint((1.,2.,-1.5)) == Point(1.,2.,0.))