Skip to content

Commit

Permalink
more position_at tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danieledapo committed Aug 30, 2024
1 parent 8527fe8 commit 2300504
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_direct_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,25 @@ def test_position_at(self):
wire.edge().position_at(3, position_mode=PositionMode.LENGTH), (3, 0, 0), 5
)

circle_wire = Wire(
[
Edge.make_circle(1, start_angle=0, end_angle=180),
Edge.make_circle(1, start_angle=180, end_angle=360),
]
)
p1 = circle_wire.position_at(math.pi, position_mode=PositionMode.LENGTH)
p2 = circle_wire.position_at(math.pi / circle_wire.length)
self.assertVectorAlmostEquals(p1, (-1, 0, 0), 14)
self.assertVectorAlmostEquals(p2, (-1, 0, 0), 14)
self.assertVectorAlmostEquals(p1, p2, 14)

circle_edge = Edge.make_circle(1)
p3 = circle_edge.position_at(math.pi, position_mode=PositionMode.LENGTH)
p4 = circle_edge.position_at(math.pi / circle_edge.length)
self.assertVectorAlmostEquals(p3, (-1, 0, 0), 14)
self.assertVectorAlmostEquals(p4, (-1, 0, 0), 14)
self.assertVectorAlmostEquals(p3, p4, 14)

circle = Wire(
[
Edge.make_circle(2, start_angle=0, end_angle=180),
Expand All @@ -2015,6 +2034,17 @@ def test_position_at(self):
(-2, 0, 0),
5,
)
print(circle.edge().length, circle.length)
self.assertVectorAlmostEquals(
circle.edge().position_at(0.5),
(-2, 0, 0),
5,
)
self.assertVectorAlmostEquals(
circle.edge().position_at(2 * math.pi, position_mode=PositionMode.LENGTH),
(-2, 0, 0),
5,
)

def test_positions(self):
e = Edge.make_line((0, 0, 0), (1, 1, 1))
Expand Down

0 comments on commit 2300504

Please sign in to comment.