Finding the point furthest away from another point?

   2754   2   1
User Avatar
Member
6 posts
Joined: Sept. 2018
Offline
Hello. Is there a way to find which point is furthest away from another point? i got i set of points located on the outer edge of a grid, and i want something that when i group a point that finds the point furthest away from that point.

Attachments:
findpoint.PNG (488.8 KB)

User Avatar
Member
6 posts
Joined: Sept. 2018
Offline
Figured it out with help of friend if anyone is interested.


int pointToCheck = 0;

v@opening = point(0,"P",pointToCheck);

f[]@distance;

for(int i = 0; i < @numpt; ++i)
{
    v@ipoint = point(0,"P",i);
    
    @distance[i] = distance(@opening,@ipoint);
}
float dist = 0;
int point = 0;
for(int i = 0; i < @numpt; ++i)
{

    if(dist > @distance[i])
    {
    }
    else
    {
        dist = @distance[i];
        point = i;
    }
}
for(int i = 0; i < @numpt; ++i)
{
    if(i == point || i == pointToCheck)
    {
    }
    else
    {
        removepoint(0,i);
    }
}

setpointgroup(0, "originPoint", pointToCheck, 1, "set");
setpointgroup(0, "furthurestPoint", pointToCheck, 1, "set");
User Avatar
Member
1737 posts
Joined: May 2006
Online
Here's a brute force way!

Use nearpoints() to get a list of the nearest points. That list will be sorted nearest to furthest. Grab the last point in that list.

(edit)

Ugh, realised I'm running that same test for every point, not necessary. Swap the wrangle mode from ‘point’ to ‘detail’, so it only runs once.
Edited by mestela - Dec. 14, 2018 07:34:21

Attachments:
farpoint.hipnc (93.0 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
  • Quick Links