Skip to content

Commit

Permalink
Merge branch 'v3-dev' into dogukan/test_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-Morgan authored Jan 23, 2025
2 parents 7a291ce + 85aa938 commit a658e12
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/specklepy/objects/geometry/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ def radius(self) -> float:
def length(self) -> float:
start_to_mid = self.startPoint.distance_to(self.midPoint)
mid_to_end = self.midPoint.distance_to(self.endPoint)
r = self.calculate_radius()
r = self.radius
angle = (2 * math.asin(start_to_mid / (2 * r))) + \
(2 * math.asin(mid_to_end / (2 * r)))
return r * angle

@property
def measure(self) -> float:
start_to_mid = self.startPoint.distance_to(self.midPoint)
mid_to_end = self.midPoint.distance_to(self.endPoint)
r = self.radius
return (2 * math.asin(start_to_mid / (2 * r))) + \
(2 * math.asin(mid_to_end / (2 * r)))
2 changes: 1 addition & 1 deletion src/specklepy/objects/geometry/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class Line(

@property
def length(self) -> float:
self.start.distance_to(self.end)
return self.start.distance_to(self.end)
1 change: 0 additions & 1 deletion src/specklepy/objects/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ def length(self) -> float:
@classmethod
def unit_interval(cls) -> "Interval":
interval = cls(start=0, end=1)
interval.length = interval.calculate_length()
return interval
4 changes: 2 additions & 2 deletions src/specklepy/objects/tests/test_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def test_arc_domain(sample_arc):


def test_arc_radius(sample_arc):
sample_arc.radius = sample_arc.calculate_radius()

assert sample_arc.radius == pytest.approx(1.0)


def test_arc_length(sample_arc):
sample_arc.length = sample_arc.calculate_length()

assert sample_arc.length == pytest.approx(math.pi)


Expand Down
1 change: 0 additions & 1 deletion src/specklepy/objects/tests/test_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def test_line_domain(sample_line):

def test_line_length(sample_line):

sample_line.length = sample_line.calculate_length()
assert sample_line.length == 5.0


Expand Down

0 comments on commit a658e12

Please sign in to comment.