Logarithmic spiral
Approximate solution
The logarithmic spiral is self-similar. As a consequence of that, the tangents make the same angle with the position vector in each point of the spiral. You can use that to draw a reasonable approximation of the spiral simply by taking unit steps in the direction of the current tangent.
Perhaps it's easiest to look at this in terms of complex numbers:
$$
z(\theta)=ae^{(i+b)\theta}=a\left(e^{i+b}\right)^\theta\\
\frac{\mathrm dz}{\mathrm d\theta} = ae^{(i+b)\theta}(i+b)
$$
So the direction vector is the position vector rotated by $(i+b)$, which means the angle between them is
$$\alpha=\arctan\frac{1}{b}=\operatorname{arccot}b $$
So the above approach would be something like this (written in sage code):
def logspiral1(s):
hypot = sqrt(1 + b^2)
sinA = 1/hypot
cosA = b/hypot
x = 1
y = 0
for c in range(100):
yield (x, y)
f = s/sqrt(x^2 + y^2)
dx = f*(cosA*x - sinA*y)
dy = f*(sinA*x + cosA*y)
x += dx
y += dy
Looks like a log spiral if taken all by it self, but since errors accumulate it will diverge considerably from the parametric equation.
Exact solution
To avoid that, you should probably compute the new $\theta$ in terms of the direction you want to take. Doing so accurately would mean integrating curve length.
$$\int_{\theta_1}^{\theta_2}\left\lvert
ae^{(i+b)\theta}(i+b)\right\rvert\,\mathrm d\theta$$
According to Wolfram Alpha this can be computed using
$$\int\left\lvert ae^{(i+b)\theta}(i+b)\right\rvert\;\mathrm d\theta=
\frac{\lvert a(b+i)\rvert}{b}e^{b\theta}$$
so you want
$$
s=\frac{\lvert a(b+i)\rvert}{b}\left(e^{b\theta_2}-e^{b\theta_1}\right) \\
e^{b\theta_2}=\frac{sb}{\lvert a(b+i)\rvert}+e^{b\theta_1} \\
\theta_2=\frac1b\log\left(\frac{sb}{\lvert a(b+i)\rvert}+e^{b\theta_1}\right)
$$
def logspiral2(s):
theta = 0
h = s*b/(a*sqrt(1 + b^2))
for c in range(100):
yield (a*cos(theta)*exp(b*theta), a*sin(theta)*exp(b*theta))
theta = log(h + exp(b*theta))/b
The first, approximate approach is drawn in red in the following figure, the second exact one in green. The continuous line behind the green points is a simple parametric plot of the exact solution.
![Figure of logarithmic spirals](https://i.stack.imgur.com/0INdC.png)
Archimedean spiral
Attempted exact solution
So let's do the same for the Archimedean spiral, again using Wolfram Alpha.
$$z(\theta)=r\theta e^{i\theta} \\
\frac{\mathrm dz}{\mathrm d\theta} = r(1+i\theta)e^{i\theta} \\
\int\left\lvert r(1+i\theta)e^{i\theta}\right\rvert\;\mathrm d\theta = \int r\sqrt{1+\theta^2}\;\mathrm d\theta
=\frac r2\left(\theta\sqrt{1+\theta^2}+\operatorname{arsinh}\theta\right)$$
That last term is a real beast: it includes $\theta$ both inside and outside the transcendental function $\operatorname{arsinh}$ (the inverse sinus hyperbolicus), which means we probably won't be able to solve this expression for $\theta$ except perhaps numerically.
Approximate solution
You could again do this thing we did above, take unit steps in tangent direction. Since the tangent direction angle depends on $\theta$, you'd have to compute that:
def archspiral1(s):
x = 0
y = 0
for c in range(100):
yield (x, y)
theta = float(sqrt(x^2 + y^2)/r)
f = float(s/sqrt(1 + theta^2))
dx = f*(1*x - theta*y)
dy = f*(theta*x + 1*y)
if theta == 0: dx = s
x += dx
y += dy
Exact curve but approximate distances
Or you could consider the change in $\theta$ induced by such a step in tangent direction. If you look at the derivative, then you notice that the radial component of that distance is $r$ while the tangential (to the circle) component is $r\theta$. So you have something like
$$s = x\sqrt{1+\theta^2}\qquad r\left(\theta_2-\theta_1\right) = x \\
\theta_2=\theta_1+\frac s{r\sqrt{1+\theta_1^2}}$$
def archspiral2(s):
theta = s/2
for c in range(100):
yield (r*theta*cos(theta), r*theta*sin(theta))
theta += s/(r*sqrt(1 + theta^2))
![Figure of archimedean spirals](https://i.stack.imgur.com/tUON3.png)
The atan2
function is an extended version of the trigonometric inverse tangent function. In the figure below, $\tan{\theta}=y/x$, so $\tan^{-1}{y/x}=\theta$. The atan2
function just calculates $\tan^{-1}{y/x}$ with y and x as separate parameters. The reason it does so is to give a more accurate answer: since the tangent function is periodic, there are multiple values of x and y that would appear to have the same angle (but do not). Also, atan2
provides the correct values when y/x is undefined, such as at $\pi/2$.
![atan2 diagram](https://i.stack.imgur.com/DETRf.png)
Another way to find the angle you're looking for is to use vectors. Using the x-axis as one of the vectors and $\vec{OP}$ as another one, you could use the formula
$$\cos{\theta}=\frac{u\cdot v}{||u||\times||v||}$$
Note that whichever way you use, you need two lines to measure an angle. You would have to choose a reference line to measure the angle $\theta$ with; most commonly one would use the x-axis.
Best Answer
Well, I can answer it now I found the answer...here
Lets say that the center of the circle is (x0, y0) and that the arc contains your two points (x1, y1) and (x2, y2). Then the radius is: r=sqrt((x1-x0)(x1-x0) + (y1-y0)(y1-y0)). So: