Notifications
Clear all

[Closed] Get point on spline

Hi,

I have a spline and a position right above the spline.
Am trying to get the Z value where that position above the spline will hit the spline straight vertically down.

Any idea how?

Thanks a lot,
Davy

6 Replies
1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

In your case the point that you are looking for is probably the nearest to your position point on the spline.

to get this point:


_point = pathInterp your_shape <_spline_index> (nearestPathParam your_shape <_spline_index> your_position)
 
_point.z -- the value which you are looking for 

…yes I was aware of those functions but it will take the closest point, not the one closest aiming directly downwards.

Cause if in the spline is a high vertex close the the point I want to measure from, it will get the Z value on the position of the spline (that is high) not the one aiming down which could be located a lot lower.

I do hope I can somehow point the function in a vertical direction?

Davy

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

how can you be sure that vertical ray from your position to the spline intersects the spline?

…I can’t be sure but I hope to get an undefined

The best I can do probably is repeating that function feeding a lower point all the time and see if I get a closer match but then again, I hope it will not give a lot of overload in calculating.

So I was hoping to be able to shoot directly down, no?

Davy

How I would do it…

  1. get zMax and zMin of the slpine (easy… _slpine.max.z and _spline.min.z)

  2. in interval zMin – zMax with some reasonable step look for nearest point to [_my_pos.x, _my_pos.y, _zMin+k*step] (k is ZERO based)

  3. sort by distance…

…yes exactly.

I will use that method only the other way around to improve speed:

I find nearest point on spline.
I check if X and Y of the detected point fall into a certain step from my original point.
If not, I lower my original point with a step and repeat checking for closest point on spline.

Works just fine.

Thanks a lot for the help,
Davy