Welcome to Math.SE! Here is my sketch for the case of clockwise direction: initial point is $A$, the endpoint you want is $B$, and $C$ is the radius of the circle on which the arc lies.
I will use polar angles: you can see the description in Wikipedia. The formulas for conversion from polar to Cartesian (on the same wiki article) will also be used.
On the picture, $\theta$ is the polar angle of the direction in which the curve departs from point $A$. Since any radius of a circle is perpendicular to the circle, the polar angle of the vector $\vec{CA}$ is $\theta+\pi/2$. The length of $\vec{CA}$ is $r$. Therefore, its Cartesian coordinates are
$$\vec {CA} = ( r\cos(\theta+\pi/2), r\sin(\theta+\pi/2)) = ( -r\sin(\theta), r\cos(\theta)) $$
Next, we need the coordinates of the vector $\vec{CB}$. Its length is also $r$. Since $\angle ACB$ is $L/r$ radian, the polar angle of $\vec{CB}$ is $\theta+\pi/2-L/r$. Convert to Cartesian:
$$\vec {CB} = ( r\cos(\theta+\pi/2-L/r), r\sin(\theta+\pi/2-L/r)) = ( -r\sin(\theta-L/r), r\cos(\theta-L/r)) $$
Finally, $\vec{AB}=\vec{CB}-\vec{CA}$, which yields
$$\boxed{\vec {AB} = ( -r\sin(\theta-L/r)+r\sin(\theta), r\cos(\theta-L/r)-r\cos(\theta)) } $$
These can be rewritten using some trigonometric identities, but I don't think it would win anything. As a sanity check, consider what happens when $L=0$: the vector is zero, hence $B$ is the same as $A$. As an aside, if $r\to \infty$ the curve becomes a straight line segment, but figuring out the limit is an exercise in calculus. :-)
If the curve bends counterclockwise, the signs will be different in a few places. Namely, the polar angle of $\vec{CA}$ will be $\theta-\pi/2$, hence
$$\vec {CA} = ( r\sin(\theta), -r\cos(\theta)) $$
The polar angle of $\vec{CB}$ will be $\theta-\pi/2+L/r$, hence
$$\vec {CB} = ( r\sin(\theta+L/r), -r\cos(\theta+L/r)) $$
The conclusion in this case is
$$\boxed{\vec {AB} = ( r\sin(\theta+L/r)-r\sin(\theta), -r\cos(\theta+L/r)+r\cos(\theta))}$$
Later: a simpler solution for the case when $C$ is given. First, calculate the vector $\vec{CA}$ and convert it to polar coordinates using these formulas. Then either increase or decrease the angle by $L/r$, depending on counterclockwise/clockwise choice.
Since you wanted JavaScript, I made a jsfiddle and also copied the code below. The parameters are coordinates of A and C, as well as length of the arc and the direction. The radius $r$ is calculated within the function.
function findB(Ax, Ay, Cx, Cy, L, clockwise) {
var r = Math.sqrt(Math.pow(Ax - Cx, 2) + Math.pow(Ay - Cy, 2));
var angle = Math.atan2(Ay - Cy, Ax - Cx);
if (clockwise) {
angle = angle - L / r;
}
else {
angle = angle + L / r;
}
var Bx = Cx + r * Math.cos(angle);
var By = Cy + r * Math.sin(angle);
return [Bx, By];
}
document.write(findB(0, 1, 1, 0, 1, true));
You can derive a simple formula using the law of cosines. In fact, while all the planar geometry is helpful for visualization, there's really no need for most of it. You have 3 points: your arc start and stop points, which I'll call $A$ and $B$, and your circle center, $C$. The angle for the arc you're wanting to measure, I'll call it $\theta$, is the angle of the triangle $ABC$ at point $C$. Because $C$ is the center of the circle that $A$ and $B$ are on, the triangle sides $AC$ and $BC$ are equal to your circle's radius, $r$. We'll call the length of $AB$, the remaining side, $d$ (see picture).
(By the way, if $A=(x_1,y_1)$ and $B=(x_2,y_2)$, then
$d=\sqrt {(x_1-x_2)^2 + (y_1-y_2)^2}$.)
According to the law of cosines, $\cos (\theta )={{r^2+r^2-d^2}\over {2rr}}=1- {{d^2}\over {2r^2}}$.
So all you need is the distance between the end points of your arc and the radius of the circle to compute the angle,
$\theta = \arccos (1- {{d^2}\over {2r^2}})$
Lastly, the length is calculated -
$Length = r\theta$
Where $\theta$ is expressed in radians.
Best Answer
The angle an arc spans (in radians) is $$ \widehat{\rm angle} = \frac{\rm arclength}{\rm radius} $$
Then you simply add up all the angles of all the corners up to the one you are drawing to find where the orientation of the arc end.
When the final orientation is 360° you have completed one circuit of the track.
The more interesting problem is coming up with the arc endpoint coordinates from the standpoint coordinates $(x_1,\,y_1)$, the initial direction $\theta_1$, the radius $r$ and the arc length $s$.
A counter clockwise arc sweeps an angle $\varphi = s/r$ in radians, so the final direction of the track after the arc is $\theta_2 = \theta_1 + \varphi$.
The endpoint coordinates are found with some trigonometry
$$ \pmatrix{x_2 \\ y_2} = \pmatrix{x_1 -r \sin \theta_1 + r \sin \theta_2 \\ y_1 + r \cos \theta_1 - r \cos \theta_2 } $$
A clockwise arc sweeps an angle $\varphi = s/r$ in radians, so the final direction of the track after the arc is $\theta_2 = \theta_1 - \varphi$.
The endpoint coordinates are found with some trigonometry
$$ \pmatrix{x_2 \\ y_2} = \pmatrix{x_1 +r \sin \theta_1 - r \sin \theta_2 \\ y_1 - r \cos \theta_1 + r \cos \theta_2 } $$