示例#1
0
class TestLineSegment3:
    line_default = geo.LineSegment3(geo.Point3(1, 1, 1), geo.Point3(3, 1, 1))

    def test_magnitude_squared(self):
        assert self.line_default.magnitude_squared() == 4

    def test_repr(self):
        assert (str(self.line_default) ==
                'LineSegment3(<1.00, 1.00, 1.00> to <3.00, 1.00, 1.00>)')

    def test_abs(self):
        assert abs(self.line_default) == 2

    def test_length(self):
        assert self.line_default.length == 2
示例#2
0
class TestLine3:
    line_default = geo.Line3(geo.Point3(1, 1, 1), geo.Point3(3, 1, 1))
    line_other = geo.Line3(geo.Point3(2, 1, 1), geo.Point3(2, 3, 1))

    def test_constructor(self):
        assert self.line_default.position == geo.Point3(1, 1, 1)
        assert self.line_default.vector == geo.Vector3(2, 0, 0)
        assert self.line_default.p1 == geo.Point3(1, 1, 1)
        assert self.line_default.p2 == geo.Point3(3, 1, 1)

    def test_copy(self):
        line_copy = self.line_default.copy()
        assert line_copy == self.line_default
        assert line_copy is not self.line_default

    def test_repr(self):
        assert (str(self.line_default) ==
                'Line3(<1.00, 1.00, 1.00> + u<2.00, 0.00, 0.00>)')

    def test_ne(self):
        assert self.line_default != self.line_other
示例#3
0
def test_lerp_vector3_as_point3():
    first = geo.Point3(0, 0, 0)
    second = geo.Point3(1, 4, 8)
    expected = geo.Point3(0.25, 1, 2)
    actual = util.lerp_vector3(first, second, 0.25)
    assert actual == expected
示例#4
0
 def test_constructor(self):
     assert self.line_default.position == geo.Point3(1, 1, 1)
     assert self.line_default.vector == geo.Vector3(2, 0, 0)
     assert self.line_default.p1 == geo.Point3(1, 1, 1)
     assert self.line_default.p2 == geo.Point3(3, 1, 1)
示例#5
0
class TestRay3:
    line_default = geo.Ray3(geo.Point3(1, 1, 1), geo.Point3(3, 1, 1))

    def test_repr(self):
        assert (str(self.line_default) ==
                'Ray3(<1.00, 1.00, 1.00> + u<2.00, 0.00, 0.00>)')
示例#6
0
 def test_point_sub_point(self):
     point_left = geo.Point3(1, 2, 3)
     point_right = geo.Point3(2, 4, 6)
     answer = point_left - point_right
     assert isinstance(answer, geo.Vector3)
     assert answer == geo.Vector3(-1, -2, -3)
示例#7
0
 def test_point_sub_vector(self):
     point_other = geo.Point3(2, 4, 6)
     answer = point_other - self.vec_default
     assert isinstance(answer, geo.Point3)
     assert answer == geo.Point3(1, 2, 3)
示例#8
0
 def test_vector_sub_point(self):
     point_other = geo.Point3(2, 4, 6)
     answer = self.vec_default - point_other
     assert isinstance(answer, geo.Point3)
     assert answer == geo.Point3(-1, -2, -3)
示例#9
0
class TestPoint3:
    point_default = geo.Point3(1, 2, 3)

    def test_repr(self):
        assert str(self.point_default) == 'Point3(1.00, 2.00, 3.00)'