You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the response of getNearestPosition you have a value for "u". This is the uniform position along the curve (parameterized by curve length). You can use this value to get the time along the curve ("t"), using the getTimeFromPosition function. The time along the curve is directly mapped to point indices, so you can find it's lower index by multiplying it by the number of points if your curve is closed, or number of points - 1 if it's not closed:
Note that this will give you the index as a decimal number, and unless you floor the value, the fraction part will tell you how far you are from the lower bound index to the next.
Something like this:
const { u } = interp.getNearestPosition(point)
const t = interp.getTimeFromPosition(u)
const index = Math.floor(t * (interp.getPoints().length - 1)) // assumes non-closed curve
Maybe I'll add a function to the lib for this purpose if anyone finds it useful.
Let's say I want to know which indexes the result point of getNearestPositionis between. As there any way?
The text was updated successfully, but these errors were encountered: