# Thread: Co-ordinates on a Curve knowing distance

1. ## Co-ordinates on a Curve knowing distance

Hi,

I'm writing a software program. I have a "road" or edge represented by a series of co-ordinates (see below). Its a curved road.

E.g.
98.10, 222.65
105.06,241.50
106.70,263.0
....
159.46,419.97

I also know the length of the road e.g. 214m. I have a vehicle that should be at position 213 on the road i.e. right near the end. How do I work out the co-ordinates the vehicle should be at but taking into account the curve of the road?

I currently do the following assuming a road is a straight line represented by (x1,xy) and (x2,y2) with road length l and vehicle position p. But this assumes a straight road.

Vx = x1 + p(x2-x1)/l
Vy = y1 + p(y2-y1)/l

2. Yes, it is likely that linear interpolations will prove unsatisfactory.

Three points define a circle. Thus, for each set of three points, calculate the equation of the circle that includes all three points. For your first three points listed, I get:

Center: (31.59235,257.91659)

If you keep your vehicle on this equation, when it is somewhere between the first and third points, this may improve your results.

Some questions should come to your mind. If I use three consecutive points, say #1, #2, and #3, then creating the second circle is a problem.

1) Should I used #2, #3, and #4? If so, which of the two paths should I use when I'm between #2 and #3? I've calculated it twice?

or

2) If I calculate circles independently, and don't overlap (Use #4, #5, adn #6 on the second circle) it seems unlikely that they will match up well at the end points. They should connect, but it is possible that I will get some very sharp turns.

These are legitimate concerns. There are various solutions to these problems. In my mind, it is a job for "Cubic Splines". It is quite an interesting methodoldolgy for such problems. You should explore it. It may stetch your programming ability. It is a vast improvement over mere circles. Circles have constant radius. Cubic curves don't have to do that. You can match both points and first or second derivative at end points and make the whole thing as smooth as you like.

Good luck. Keep us up with your progress.

3. Whoops, I forgot to attach the picture of the circle solution.