Skip to content

Commit

Permalink
fix(line): Add vertices property to line
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Mackey authored and chriswmackey committed Dec 5, 2020
1 parent 9fee2a8 commit 47768a8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 1
update_configs:
- package_manager: "python"
directory: "/"
update_schedule: "live"
automerged_updates:
- match:
dependency_type: "all"
update_type: "all"
commit_message:
prefix: "fix"
prefix_development: "chore"
include_scope: true
6 changes: 6 additions & 0 deletions ladybug_geometry/geometry2d/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LineSegment2D(Base1DIn2D):
* p2
* midpoint
* length
* vertices
"""
__slots__ = ()

Expand Down Expand Up @@ -85,6 +86,11 @@ def length(self):
"""The length of the line segment."""
return self.v.magnitude

@property
def vertices(self):
"""Tuple of both vertices in this object."""
return (self.p1, self.p2)

def is_equivalent(self, other, tolerance):
"""Boolean noting equivalence (within tolerance) between this line and another.
Expand Down
6 changes: 6 additions & 0 deletions ladybug_geometry/geometry3d/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class LineSegment3D(Base1DIn3D):
* p2
* midpoint
* length
* vertices
"""
__slots__ = ()

Expand Down Expand Up @@ -78,6 +79,11 @@ def length(self):
"""The length of the line segment."""
return self.v.magnitude

@property
def vertices(self):
"""Tuple of both vertices in this object."""
return (self.p1, self.p2)

def is_horizontal(self, tolerance):
"""Test whether this line segment is horizontal within a certain tolerance.
Expand Down
3 changes: 2 additions & 1 deletion tests/line2d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def test_linesegment2_init():
"""Test the initalization of LineSegment2D objects and basic properties."""
"""Test the initialization of LineSegment2D objects and basic properties."""
pt = Point2D(2, 0)
vec = Vector2D(0, 2)
seg = LineSegment2D(pt, vec)
Expand All @@ -22,6 +22,7 @@ def test_linesegment2_init():
assert seg.point_at(0.25) == Point2D(2, 0.5)
assert seg.point_at_length(1) == Point2D(2, 1)
assert seg.length == 2
assert len(seg.vertices) == 2

flip_seg = seg.flip()
assert flip_seg.p == Point2D(2, 2)
Expand Down
3 changes: 2 additions & 1 deletion tests/line3d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_linesegment3d_init():
"""Test the initalization of LineSegment3D objects and basic properties."""
"""Test the initialization of LineSegment3D objects and basic properties."""
pt = Point3D(2, 0, 2)
vec = Vector3D(0, 2, 0)
seg = LineSegment3D(pt, vec)
Expand All @@ -23,6 +23,7 @@ def test_linesegment3d_init():
assert seg.point_at(0.25) == Point3D(2, 0.5, 2)
assert seg.point_at_length(1) == Point3D(2, 1, 2)
assert seg.length == 2
assert len(seg.vertices) == 2

flip_seg = seg.flip()
assert flip_seg.p == Point3D(2, 2, 2)
Expand Down

0 comments on commit 47768a8

Please sign in to comment.