Farthest point to geometry

Hi!

Is there an inverse of a node Geometry.ClosestPointTo thus Geometry.FarthestPointTo? Or a handy method the do this.

Hi @fluffyhugger

You can do this way:

2 Likes

Thanks @Kulkul! But it works only if you take points. I’m personally more into curves. Like what’s the farthest point from a straight line in relation to a curve.
image

Could you please share relevant files?

Project1.rvt (1.5 MB)

In place of the line should be a plane.what’s the farthest point from that plane on the curve.

@fluffyhugger You could try this workflow :grinning:

2 Likes

Already did exactly that! :slight_smile: Problem is thats it’s way to heavy operation, because to get exact point I’d need to put points every mm. Even if I put them every 10 of 100 mm, it takes very long time.

But isn’t it’s kinda weird… there is an easy way to get closest point but not farthest… or am I not getting something?

Try doing it in reverse; mirror the line to the other side of the nurbs curve with your chosen constraints, and get the closest point using OOTB nodes. Closest point on the mirrored side will be the furthest point on the originating side.

4 Likes

Something a little like this @Thomas_Mahon
(Though you would need to watch the setout of the mirror plane if the Nurbs curve geometry varied quite bit)

3 Likes

@Thomas_Mahon @Ewan_Opie I used this method too and this is exactly the reason why I can’t use it because there is no consistence in the output… :roll_eyes:

@fluffyhugger Can you upload a sample (files, sketches, etc) of the end geometry you are looking to apply a Furthest Point workflow to?

I don’t think you need to mirror the curve. Just to translate it in the direction of the other curve with a large enough distance. Then if you need to know the distance to that point from the original curve you can do it like that:

1 Like

As an alternative you can use the fact that the closest and farthest points to a straight line have their tangent parallel to the line. At least in this case. And vectors are fast to work with so maybe you can go for a parallell check to filter down the points you have to place. I’m sure there are better ways than this rough sketch, but anyways…

Works rather fast at least:

6 Likes

Or keep the conventional workflow all in python for a little speed benefit as well?

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('DSCoreNodes') 
import DSCore
from DSCore import *

def seq(start, stop, step=1):
    n = int(round((stop - start)/float(step)))
    if n > 1:
        return([start + step*i for i in range(n+1)])
    elif n == 1:
        return([start])
    else:
        return([])

ac = 0.001

line1 = IN[0]
line2 = IN[1]

seq1 = seq(0,1,ac)
plist = []
dlist = []

for s in seq1:
	pts = Line.PointAtParameter(line2,s)
	plist.append(pts)
	
for p in plist:
	dist = Geometry.DistanceTo(line1,p)
	dlist.append(dist)

maxdist = DSCore.List.MaximumItem(dlist)
ind = DSCore.List.FirstIndexOf(dlist,maxdist)
maxpoint = DSCore.List.GetItemAtIndex(plist,ind)

OUT = maxpoint
5 Likes

@viktor_kuzev @jostein_olsen @Ewan_Opie thank you a lot! All solutions do the job great!

This is why you got to love the community! When people get into it, you get any problem solved! :slight_smile:

1 Like

Hi Ewan,
Thank you for your Python node. It works well with Model Curve but not with Nurb Curves (I tried a nurbs curve which I imported it from Auto CAD).