diff --git a/AUTHORS.md b/AUTHORS.md index 6c8bcca892c3..cadf13b8c2a0 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -42,3 +42,4 @@ - Joseph Kenny <> [@jckenny59](https://github.com/jckenny59) - Panayiotis Papacharalambous <> [@papachap](https://github.com/papachap) - Oliver Bucklin <> [@obucklin](https://github.com/obucklin) +- Ananya Kango <> [@kangoananya](https://github.com/kangoananya) diff --git a/CHANGELOG.md b/CHANGELOG.md index 570fb07cbe61..dd9705a6f96e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/src/compas_rhino/geometry/curves/curve.py b/src/compas_rhino/geometry/curves/curve.py index 6b3eab7c5fa8..01abb52d2c05 100644 --- a/src/compas_rhino/geometry/curves/curve.py +++ b/src/compas_rhino/geometry/curves/curve.py @@ -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. @@ -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 ---------- @@ -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