Skip to content

Add methods to the RhinoCurve class #1455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@
- Joseph Kenny <<[email protected]>> [@jckenny59](https://github.com/jckenny59)
- Panayiotis Papacharalambous <<[email protected]>> [@papachap](https://github.com/papachap)
- Oliver Bucklin <<[email protected]>> [@obucklin](https://github.com/obucklin)
- Ananya Kango <<[email protected]>> [@kangoananya](https://github.com/kangoananya)
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Added
* Added `trim`, `trimmed`, `change_seam` and `point_at_length` methods to `RhinoCurve` class.

* Added `Group` to `compas.scene`.
* Added `compas.geometry.Brep.cap_planar_holes`.
Expand Down
71 changes: 68 additions & 3 deletions src/compas_rhino/geometry/curves/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ def point_at(self, t):
point = self.native_curve.PointAt(t) # type: ignore
return point_to_compas(point)

def point_at_length(self, length):
"""Compute a point on the curve at a specific length.

Parameters
----------
length : float
The length along the curve.

Returns
-------
:class:`compas.geometry.Point`
The corresponding point on the curve.

"""
point = self.native_curve.PointAtLength(length) # type: ignore
return point_to_compas(point)

def tangent_at(self, t):
"""Compute the tangent vector at a point on the curve.

Expand Down Expand Up @@ -375,7 +392,7 @@ def fair(self, tol=1e-3):
raise NotImplementedError

def offset(self, distance, direction, tolerance=1e-3):
"""Compute the length of the curve.
"""Offset the curve.

Parameters
----------
Expand All @@ -401,5 +418,53 @@ def smooth(self):
def split(self):
raise NotImplementedError

def trim(self):
raise NotImplementedError
def trim(self, t0, t1):
"""Trim the curve to a specific domain.

Parameters
----------
t0 : float
The start of the domain.
t1 : float
The end of the domain.

Returns
-------
None

"""
self.native_curve = self.native_curve.Trim(t0, t1) # type: ignore

def trimmed(self, t0, t1):
"""Trim the curve to a specific domain.

Parameters
----------
t0 : float
The start of the domain.
t1 : float
The end of the domain.

Returns
-------
:class:`compas_rhino.geometry.RhinoCurve`
The trimmed curve.
"""

curve = self.native_curve.Trim(t0, t1) # type: ignore
return RhinoCurve.from_native(curve)

def change_seam(self, t):
"""Change the seam of the curve to a specific parameter.

Parameters
----------
t : float
The parameter at which to set the seam.

Returns
-------
None

"""
self.native_curve.ChangeClosedCurveSeam(t) # type: ignore
Loading