Get x,y along an arc with a defined starting & ending points

63 Views Asked by At

I am trying to figure out how to create an arc and then get equidistant points along it. I've brought this here from Stack Overflow b/c it's more of a math question than a programming one, however I am not a math person so if you answer please keep in mind you're speaking to a layperson.

I have a starting point:

(144,166)

I have an ending point:

(296,318)

My coordinate system starts at (0,0) on the upper left corner.

I'd like to know how to get 4 equidistant points within an arc between my starting and ending points.

enter image description here

So how would I get the x,y for X1, X2, X3 & X4 ?

2

There are 2 best solutions below

0
On

To make this easier we're going to use polar coordinates and a parametric representation. In polar coordinates, circles are defined by a center $(x_0,y_0)$, a radius $r$, and an angle $\theta$.

For your circle, $x_0$ is the x-value of the point $S$, and $y_0$ is the y-value of point $F$. Radius $r$ is equal to the difference in the x-value for $F$ and the x-value for $S$.

$x_0=144$, $y_0=318$, $r=152$

Then using a parametric representation of the circle in polar coordinates,

$x=144+152 cos(t)$, $y=318+152sin(t)$

Here, $t$ is a parametric parameter which can take any value, but of interest it represents $2 \pi$ radians of $\theta$. When you plug $t=0$ into the two parametric equations the $x$ and $y$ results will yield the point $F$, and $t=-\pi/2$ will yield the point $S$. Now just divide $t$ five times between $-\pi/2$ and $0$ for the five segments and find the $x$ and $y$ values that give you your arc points!

$-\pi/2+5a=0$, solving for $a$, $a=\pi/10$

So we have $t_{x1}=-\pi/2+\pi/10$, $t_{x2}=-\pi/2+2\pi/10$, etc. Finally,

$X_1=(190.97,173.44)$, $X_2=(233.34,195.03)$, $X_3=(266.97,228.656)$, $X_4=(288.56,271.03)$

0
On

If the circle passes through $A=(a, b)$ and $B=(c,d)$, its center $C=(u, v)$ has to be on the perpendicular bisector of $AB$.

This line passes through $D=(A+B)/2$ and, since the slope of $AB$ is $m=\frac{d-b}{c-a}$, has slope $-1/m = -\frac{c-a}{d-b}$. The points on it are of the form $D-t(d-b, c-a)$ for real $t$.

Choose one of these, and call it $P$. Get the angles from $P$ to $A$ and $P$ to $B$; their difference is $\angle APB$.

Now, consider these points as complex numbers. This allows rotation to be done by multiplication.

Compute $\theta = \angle APB/n$ ($n=5$ in your case).

For $k$ from $1$ to $n-1$, compute $P+(P-A)(\cos(k\theta)+i\sin(k\theta)$, which is the line from $P$ to $A$ rotated by $k \theta$. These are your points.