Intersect function - variadic argument "farthest"

   3445   8   0
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
Hello,

Anyone know how to make use of the variadic argument “farthest” for the vex intersect function?

Taking for granted the parameters are set up correctly for the following and not using “farthest”, this will work:

...
intersect( geoself(), @P, Direction, Intersection, U, V);
...

But if I add “farthest” to the function it errors out:

...
intersect( geoself(), @P, Direction, Intersection, U, V, "farthest");
...

I've tried using different variations like instead of the string, just put in 0 or 1 ( maybe it's a truth ), and even putting in a defined vector variable ( maybe it just needs to set a variable ).

Still can't seem to make use of it.

Any suggestions?
Edited by BabaJ - Oct. 3, 2018 12:08:26

Attachments:
Intersect Variadic_farthest.hiplc (69.5 KB)

User Avatar
Member
474 posts
Joined: July 2005
Offline
Hi,

it looks like that you can only use this function, if you put the full path name of the geometry into it, and you need another parameter (int) to set it to 1 (if set to 0 it will be the nearest intersection). There should be an overloaded function to make this easier … .
I haven't tried everything, but there should be a better solution.

Attachments:
intersectfar.hipnc (71.8 KB)

User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
Thanks Aizatulin,

Would have taken me forever to get that combination of ‘farthest’ and an int value.

On that point, I think it's worth an RFE to update and clarify the docs.

But the needing to use op: is odd since what this means is that when using ‘farthest’ it will only work if referencing an external node, since even op: defining the current node will not work.

Will have to mention that to support and see what they say.

//i@Found  = intersect(geoself(), point(0, "P", 0), Direction,  Intersection,  U, V); // Works 

//i@Found = intersect(geoself(), point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Does Not Work
//i@Found = intersect(0, point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Does Not Work

i@Found = intersect('op:/obj/geo1/merge1', point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Works. - 'merge1' is previous node to wrangle using intersect
i@Found = intersect('op:/obj/geo1/PW_Intersections', point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Does Not Work. - 'PW_Intersections' is node of wrangle using intersect function
Edited by BabaJ - Oct. 3, 2018 15:00:18

Attachments:
Intersect Variadic_farthest.hiplc (70.0 KB)

User Avatar
Member
474 posts
Joined: July 2005
Offline
“intersect_all” is another option, where you get an ordered point array from nearest to farthest point and where you don't have to use the ‘op..’ string input.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
Yeah..thanks for the tip…I was trying that with my original application (intersect_all).

But I had the issue that I couldn't use 0 tolerance, only a value very small and close to 0.

Maybe I'm wrong and will have to re-visit; I might be mistaken in my approach one way or the other.
User Avatar
Member
474 posts
Joined: July 2005
Offline
Yes, usually tolerance values close to zero should produce more accurate results, but the algorithm may probably take more time to converge. If the tolerance is set to zero, the algorithm may not converge unless it has other safety conditions to jump out, but I have no idea about implementation details. Usually 0.001 is not a bad value for tolerances (my personal opinion/experience)
User Avatar
Member
159 posts
Joined: Feb. 2018
Offline
BabaJ
Thanks Aizatulin,

Would have taken me forever to get that combination of ‘farthest’ and an int value.

On that point, I think it's worth an RFE to update and clarify the docs.

But the needing to use op: is odd since what this means is that when using ‘farthest’ it will only work if referencing an external node, since even op: defining the current node will not work.

Will have to mention that to support and see what they say.

//i@Found  = intersect(geoself(), point(0, "P", 0), Direction,  Intersection,  U, V); // Works 

//i@Found = intersect(geoself(), point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Does Not Work
//i@Found = intersect(0, point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Does Not Work

i@Found = intersect('op:/obj/geo1/merge1', point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Works. - 'merge1' is previous node to wrangle using intersect
i@Found = intersect('op:/obj/geo1/PW_Intersections', point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 0); // Does Not Work. - 'PW_Intersections' is node of wrangle using intersect function

Thanks, the ‘farthest’ argument is really confused me.
User Avatar
Member
9 posts
Joined: July 2010
Offline
Hi

There is another working variant (in wrangle)
intersect(@OpInput1, @P, Direction, Intersection, U, V, 'farthest', 1);

So, instead of explicitly write a path to a node, you can just use the wrangle's @OpInputX syntax.
User Avatar
Member
8538 posts
Joined: July 2007
Offline
you can also directly do this
intersect("opinput:0", point(0, "P", 0), Direction, Intersection, U, V, 'farthest', 1);
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links