How can I find coordinates of points along a curved path?

1.1k Views Asked by At

I have a very basic grasp of the math concepts behind this question so I need a very basic explanation if at all possible. The question is in regards to a game program where a player is traveling through a curved course made up of bezier curves. The curves are all $90$ degrees in terms of the start and end points. I have the start coordinates of each section and the end coordinates of each section. In the image example I have a curve section which starts at $x= 0$, $y= 0$ (the red square) and ends at $x = +100$, $y = +100$ (the green square). I need to determine the coordinates of some points along the curve (the black squares).

Rather than just the "equation" to determine the points (I don't really understand a lot of the symbols used in equations or how to translate that to programming code), I need to know the sequence of basic math steps to get the $x$-$y$ coordinates of the points. If possible some "pseudo code" would be great to help me understand how to achieve coordinates for several points along the curve.

example image to understand my question

1

There are 1 best solutions below

6
On BEST ANSWER

Assuming the curve is an quarter of circle, and that the six point are spaced uniformly, we can write $$ (x,y)=(100+100\cos t,100\sin t), \quad t=\frac{\pi}{2}+k\frac{\pi}{10}, \quad k=0,\ldots,5 $$ so we have \begin{align} &(100., 100.),\\ &(69.0983, 95.1057),\\ &(41.2215, 80.9017),\\ &(19.0983, 58.7785),\\ &(4.89435, 30.9017),\\ &(0., 0.) \end{align}

Here a short piece of program in C++ (not tested)

double pi = 3.14159;
for (int k = 0; k <= 5; k++) {
  double t = pi/2 + k*pi/10;
  double x = 100+100*cos(t);
  double y = 100*sin(t);
  printf("%f, %f\n", x, y);
}