Skip to content

Commit

Permalink
fix(arc): Fix tolerance issue in Arc.subdivide_evenly
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Mar 16, 2020
1 parent 249518e commit df2ffa2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ladybug_geometry/geometry2d/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,10 @@ def subdivide_evenly(self, number):
interval = 1 / number
parameter = interval
sub_pts = [self.p1]
while parameter < 1:
while parameter <= 1:
sub_pts.append(self.point_at(parameter))
parameter += interval
sub_pts.append(self.p2)
return sub_pts
return sub_pts

def point_at(self, parameter):
"""Get a point at a given fraction along the arc.
Expand Down
1 change: 1 addition & 0 deletions ladybug_geometry/geometry2d/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class LineSegment2D(Base1DIn2D):
* v
* p1
* p2
* midpoint
* length
"""
__slots__ = ()
Expand Down
1 change: 1 addition & 0 deletions ladybug_geometry/geometry3d/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class LineSegment3D(Base1DIn3D):
* v
* p1
* p2
* midpoint
* length
"""
__slots__ = ()
Expand Down
9 changes: 9 additions & 0 deletions tests/arc3d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ def test_arc3_init_from_start_mid_end():
with pytest.raises(Exception):
arc = Arc3D.from_start_mid_end(p1, m, p2)

def test_arc3_init_from_start_mid_end_flipped():
"""Test the init of Arc3D objects from_start_mid_end using a flipped plane."""
p1 = Point3D(-91.47, 40.40, 0.76)
m = Point3D(0.06, 23.23, 97.27)
p2 = Point3D(91.49, 40.35, 0.99)
arc = Arc3D.from_start_mid_end(p1, m, p2)

assert arc.midpoint.z > 0


def test_arc3_to_from_dict():
"""Test the initalization of Arc3D objects and basic properties."""
Expand Down

0 comments on commit df2ffa2

Please sign in to comment.