0
votes

Situation looks as follows:

The situation

The SDK I'm working with represents position on a spline as a 0-1 value. From that position I can get (x,y,z) coords of a point. I start with point A, let's say at 0.5 on the spline and some (xa,ya,za) position in space. I want to now move along the spline (so subtracting from that 0.5) until i get B (xb,yb,zb) so that the distance (A,B) is a given d. The difference between the spline position of A(0.5) and B(x) is the n I'm looking for. My naive approach was to get start = n/length_of_the_spline, set a new point at 0.5 - start and then in a subtract 0.001 from it, get the (x,y,z) position, measure the distance of that point from A and if it's more that d, try again until it is. This I think is a rather wasteful way of doing it.

Can anyone point me to some algorithm that could help me? I'm not able to get the parametric representation of the spline, so can't math out where a circle intersects the spline. What I can do is traverse the spline, get (x,y,z) coords and measure distances.

Here's what this is for (current python script inside) https://www.reddit.com/r/Cinema4D/comments/vyuyiu/chains_with_python/

Don't post code and images outside SO. - Jean-Baptiste Yunès
binary search on spline's parameter, for starters. - Will Ness
...each time measuring the distance from the point to the target point. to not get trapped in a local minimum, initially put N points along the spline at equal delta-parameter values, and thus find the interval of interest so that its two end points have different signs of the value distance - Radius. If there is no such interval, increase N=2*N and try again. or indeed start from your stating point A and go along the spline by some increment, possibly increasing it incr=1.1*incr on each step. or something. it's a search problem. - Will Ness
(IOW you're asking about circle-spline intersection. try googling for that, maybe). - Will Ness
Will Ness - That was my first thought but 1. It would be a sphere spline intersection 2. The SDK I'm using doesn't allow me to get a parametric version of the spline. - Andrew Zmurowski