Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Jan 17, 2022
2 parents a2df551 + 9ff1bf3 commit 0419a3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Fixed input parameters and docstring of `compas_occ.geometry.NurbsSurface.closest_point`.
* Fixed bug in `compas_occ.geometry.NurbsCurve.transform`.

### Removed
Expand Down
18 changes: 16 additions & 2 deletions src/compas_occ/geometry/surfaces/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,26 @@ def frame_at(self, u, v):
self.occ_surface.D1(u, v, point, uvec, vvec)
return Frame(Point.from_occ(point), Vector.from_occ(uvec), Vector.from_occ(vvec))

def closest_point(self, point, distance=None, parameter=False):
def closest_point(self, point, return_parameters=False):
"""Compute the closest point on the curve to a given point.
Parameters
----------
point : Point
The point to project to the surface.
return_parameters : bool, optional
Return the projected point as well as the surface UV parameters as tuple.
Returns
-------
:class:`compas.geometry.Point`
The nearest point on the surface, if ``return_parameters`` is false.
(:class:`compas.geometry.Point`, (float, float))
The nearest as (point, parameters) tuple, if ``return_parameters`` is true.
"""
projector = GeomAPI_ProjectPointOnSurf(point.to_occ(), self.occ_surface)
point = Point.from_occ(projector.NearestPoint())
if not parameter:
if not return_parameters:
return point
return point, projector.LowerDistanceParameters()

Expand Down

0 comments on commit 0419a3a

Please sign in to comment.