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
chriswmackey committed Dec 5, 2020
1 parent 9aaded8 commit 4fb27c3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

![Ladybug](http://www.ladybug.tools/assets/img/ladybug.png)


[![Build Status](https://travis-ci.com/ladybug-tools/ladybug.svg?branch=master)](https://travis-ci.com/ladybug-tools/ladybug-geometry)
[![Build Status](https://github.com/ladybug-tools/ladybug-geometry/workflows/CI/badge.svg)](https://github.com/ladybug-tools/ladybug-geometry/actions)
[![Coverage Status](https://coveralls.io/repos/github/ladybug-tools/ladybug-geometry/badge.svg?branch=master)](https://coveralls.io/github/ladybug-tools/ladybug-geometry?branch=master)

[![Python 2.7](https://img.shields.io/badge/python-2.7-green.svg)](https://www.python.org/downloads/release/python-270/) [![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) [![IronPython](https://img.shields.io/badge/ironpython-2.7-red.svg)](https://github.com/IronLanguages/ironpython2/releases/tag/ipy-2.7.8/)
Expand Down
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 4fb27c3

Please sign in to comment.