Interpolation between 2 points on the perimeter of a circle?

6.2k Views Asked by At

I'm trying to produce movement on a unit circle from one point to another in equal increments, but I'm having trouble doing this without the use of angles (which isn't an option).

Given 2 points on a unit circle, a from position and a to position, how do I interpolate between the two positions given an amount to interpolate by t?

i.e.:

from = [0,1]

to = [1,0]

t = .25 (A quarter way between from and to on the perimeter of the unit circle)

Unfortunately, I don't think linear interpolation projected on the unit circle would work:

enter image description here

Is there a way to interpolate on the perimeter of the circle as shown here?

enter image description here

R, A, and B are segments of the circle's perimeter. |R| = |A| and |R| * 2 = |B|.

4

There are 4 best solutions below

2
On BEST ANSWER

The interpolation you want is a linear interpolation of the angle (which is identical to the arclength for the unit circle): $$ \phi = \phi_a (1-t)+\phi_b t $$ which could involve segments of length more than $\pi$. If the shortest path is wanted, one needs to modify the above.

The problem is that you would need to calculate:

  1. $\phi_a$ and $\phi_b$ from $(x_a, y_a)$ and $(x_b, y_b)$, and then

  2. $(x, y)$ from $\phi$

The first is calculated via $\arctan(x)$ the second via $\cos(x)$ and $\sin(x)$ or one of them replaced by the square root function.

So your real problem is to approximate the above functions.

If you have restrictions on using trigonometric functions and their inverses, then you probably have more restrictions (maybe even no floating point arithmethic). We would need more information on them, to give useful advice. E.g. using symmetry and a lookup table for $\cos$ for the first $1/8$th of the circle might fail due to having not much memory etc.

Another approach would be to approximate the circle by a polygon:

circle approximation

Assign each line segment a parameter interval $[t_i, t_{i+}]$. So first step would be to look at $t$ and determine which interval applies e.g. $[t_3, t_4] = [0.75,1.00]$ and then do the interpolation on that segment.

This would only need in advance calculation and storage of the segement end points, e.g. $5$ points for the image above with $4$ segments. If you use symmetry only about half of the points are needed.

2
On

If you have two points, $a=(a_x,a_y)$ and $b=(b_x,b_y)$, then take their sum $c=(a_x+b_x,a_y+b_y)$. Then your point could be $\frac{c}{\|c\|}$ where $\|c\|=\sqrt{c_x^2+c_y^2}$.

For the given example, $a=(1,0)$, $b=(0,1)$ and $c=(1,1)$. Then you would take the point $c/\sqrt{2}=\left(\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}}\right)$.

If you wanted $t=1/2$, now do the same thing again between the $c$ constructed above and $a$.

1
On

If you know the coordinates of the two points in Cartesian coordinates $(x_1, y_1), (x_2, y_2)$, then find the midpoint $(a,b)$ of the line segment joining them:

$$(a,b) = \left(\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2}\right).$$

The calculated coordinates, by definition, are the point's (vector) displacement from the origin. Divide the coordinates by the magnitude of this displacement, $\sqrt{a^2 + b^2}$ (which is some number less than $1$), and you'll arrive at the point midway between the two points, on the unit circle.

0
On

If you are willing to use nonlinear interpolation, you can use the old standby of $\left(\frac{2t}{1+t^2}, \frac{1-t^2}{1+t^2}\right) $ for $0 \le t \le 1$. Since $(2t)^2+(1-t)^2 =(1+t)^2 $, this goes on the circle from $(0, 1)$ to $(1, 0)$ as $t$ goes from $0$ to $1$.

This gets the first quadrant, and you can flip signs as needed to get the other three.


(Added later)

Note: To convert $(x, y)$ to this form, you want $x = 2t/(1+t^2)$ and $y = (1-t^2)/(1+t^2)$. Assuming that $x^2+y^2 = 1$ and the point is in the first quadrant, we get $x(1+t^2)=2t$ or $t^2x-2t+x=0$. Solving $t =\frac{2\pm \sqrt{4-4x^2}}{2x} =\frac{1\pm \sqrt{1-x^2}}{x} $. Since $0 \le x \le 1$, we must choose the negative square root to ensure $0 \le t \le 1$. Since $x^2+y^2 = 1$, $\sqrt{1-x^2} =\sqrt{y^2} = y $. Therefore, $t = \frac{1-y}{x} $. If $x=0$, set $t = 0$.