Esempio n. 1
0
 def setUp(self):
     self.cyl1 = geom.Cylinder(geom.Vertex(0.0, 0.0, 0.0), 1.0, 10.0,
                               geom.Vector.UnitVector(1.0, 0.0, 0.0))
     self.cyl2 = geom.Cylinder(geom.Vertex(0.0, 1.0, -0.3), 0.5, 5.0,
                               geom.Vector.UnitVector(1.0, -1.0, 0.0))
     self.cyl3 = geom.Cylinder(geom.Vertex(0.0, -1.0, -1.25), 0.5, 5.0,
                               geom.Vector.UnitVector(1.0, 1.0, 0.0))
     self.cyl4 = geom.Cylinder(geom.Vertex(0.0, -1.0, -1.51), 0.5, 5.0,
                               geom.Vector.UnitVector(1.0, 1.0, 0.0))
Esempio n. 2
0
    def test_cylinder_intersect(self):
        cyl1 = geom.Cylinder(geom.Vertex(0.0, 2.5, 1.0), 0.5, 2.0)
        cyl2 = geom.Cylinder(geom.Vertex(5.0, 2.5, 1.0), 0.5, 25.0, geom.Vector(0.0, 1.0, 0.0))

        vol_ratio_1 = self.cub1.volume_intersect(cyl1)
        vol_ratio_2 = self.cub1.volume_intersect(cyl2)

        self.assertAlmostEqual(vol_ratio_1, 0.5 * cyl1.volume())
        self.assertAlmostEqual(vol_ratio_2, 0.2 * cyl2.volume())
Esempio n. 3
0
    def test_move_by_vector(self):
        vec = geom.Vector(2.0, -1.0, 0.5)

        self.assertEqual(self.v1 + vec, geom.Vertex(3.1, 1.5, -2.9))

        va = self.v1 - vec
        vb = self.v1 + (-vec)

        vm = geom.Vertex(-0.9, 3.5, -3.9)

        self.assertAlmostEqual(va.x, vm.x)
        self.assertAlmostEqual(va.y, vm.y)
        self.assertAlmostEqual(va.z, vm.z)

        self.assertAlmostEqual(vb.x, vm.x)
        self.assertAlmostEqual(vb.y, vm.y)
        self.assertAlmostEqual(vb.z, vm.z)
Esempio n. 4
0
    def test_from_three_points(self):
        alpha = geom.Transformation.FromThreePoints(
            geom.Vertex(5.0, 2.0, 9.0),
            geom.Vertex(5.0, 3.0, 9.0),
            geom.Vertex(4.5, 2.5, 9.0))

        self.assertEqual(alpha.transform(geom.Vertex(5.0, 2.0, 9.0)), geom.Vertex(0.0, 0.0, 0.0))
        self.assertEqual(alpha.transform(geom.Vertex(6.0, 3.0, 0.0)), geom.Vertex(1.0, -1.0, -9.0))
Esempio n. 5
0
    def test_translation_to_and_back(self):
        v = self.alpha2.transform(geom.Vertex(0.0, 0.0, 0.0))

        self.assertEqual(v.x, 10.0)
        self.assertEqual(v.y, 20.0)
        self.assertEqual(v.z, 30.0)

        v0 = self.alpha2.inverse().transform(v)

        self.assertEqual(v0.x, 0.0)
        self.assertEqual(v0.y, 0.0)
        self.assertEqual(v0.z, 0.0)
Esempio n. 6
0
 def setUp(self):
     self.v1 = geom.Vertex(1.1, 2.5, -3.4)
     self.v2 = geom.Vertex(-5.0, 1.0, 0.5)
Esempio n. 7
0
 def setUp(self):
     self.cub1 = geom.Cuboid(geom.Vertex(5.0, 2.5, 1.0), 10.0, 5.0, 2.0)
Esempio n. 8
0
 def setUp(self):
     self.caps1 = geom.Capsule(geom.Vertex(0., 0., 0.), 1., 10., geom.Vector(1., 0., 0.))
     self.caps2 = geom.Capsule(geom.Vertex(0., 0., 0.), 1., 10., geom.Vector(1., 1., 1.))
Esempio n. 9
0
    def test_project_edge(self):
        l1 = geom.Edge(geom.Vertex(-2.0, 2.0, 0.0), geom.Vertex(3.0, 1.0, 0.5))
        l2 = geom.Plane.XZ.project_edge(l1)

        self.assertEqual(l2.v1, geom.Vertex(-2.0, 0.0, 0.0))
        self.assertEqual(l2.v2, geom.Vertex(3.0, 0.0, 0.5))
Esempio n. 10
0
    def test_closest_point(self):
        vc = geom.Plane.XZ.closest_point(geom.Vertex(5.0, 2.0, -1.0))

        self.assertEqual(vc, geom.Vertex(5.0, 0.0, -1.0))
Esempio n. 11
0
 def test_distance_to_point(self):
     self.assertEqual(geom.Plane.XZ.distance_to_point(geom.Vertex(5.0, 2.0, 0.0)), 2.0)
     self.assertEqual(geom.Plane.XZ.distance_to_point(geom.Vertex(-5.0, 3.0, 20.0)), 3.0)
     self.assertEqual(geom.Plane.Offset(geom.Plane.XZ, dy=1.0).distance_to_point(geom.Vertex(-5.0, 3.0, 20.0)), 2.0)
Esempio n. 12
0
    def test_offset(self):
        xy_plus_ten = geom.Plane.Offset(geom.Plane.XY, dz=10.0)

        self.assertEqual(xy_plus_ten.normal, geom.Vector(0.0, 0.0, 1.0))
        self.assertEqual(xy_plus_ten.point, geom.Vertex(0.0, 0.0, 10.0))
Esempio n. 13
0
 def test_collinear(self):
     v = geom.Vertex(5.0, 0.0, 0.0)
     self.assertTrue(self.edge1.collinear(v))
     self.assertFalse(self.edge4.collinear(v))
Esempio n. 14
0
    def setUp(self):
        self.edge1 = geom.Edge(geom.Vertex(0.0, 0.0, 0.0), geom.Vertex(10.0, 0.0, 0.0))
        self.edge2 = geom.Edge(geom.Vertex(0.0, 1.0, 0.0), geom.Vertex(10.0, 1.0, 0.0))
        self.edge3 = geom.Edge(geom.Vertex(5.0, -5.0, 0.0), geom.Vertex(6.0, 0.5, 0.0))
        self.edge4 = geom.Edge(geom.Vertex(5.0, -5.0, 0.0), geom.Vertex(6.0, 1.0, 0.0))
        self.edge5 = geom.Edge(geom.Vertex(-5.0, 0.0, 0.0), geom.Vertex(5.0, 0.0, 0.0))
        self.edge6 = geom.Edge(geom.Vertex(-1.8, -2.8, -10.0), geom.Vertex(1.8, 0.8, -10.0))

        self.edge7 = geom.Edge(geom.Vertex(0., 0., 0.), geom.Vertex(1., 0., 0.))
        self.edge8 = geom.Edge(geom.Vertex(2., 0., 0.), geom.Vertex(3., 0., 0.))