Calculate segment distance to cover before turning via a pivot I'm building a visualisation where I have a body that is moving along-a-path, which is comprised of multiple segments, each with an arbitrary angle.
The body is moving along the path and: 


*

*When the body's centre reaches the end of each segment it stops.

*It then rotates around it's centre to align itself with the next segment .

*It starts moving again along the next segment.


I can get this working just fine when the rotation point is the body's centre. 
Here's an animation of the body rotating by it's centre (blue dot):

However now I'd like to rotate the body from a pivot point.
How can I calculate the distance I should cover in each segment before I stop and start turning around my pivot, so when the rotation ends my body's centre lies exactly in the centre of the next segment?
In short, when the body is moving it's centre must always lie on the segment line it moves on.
Here's an animation of the body rotating by it's pivot point (red dots):

In the above example the body overshoots the position on each segment where it should stop and start rotating, thus when it starts moving again - it's centre doesn't lie on the path.
FWIW I've got some code for this working in a browser sandbox, available here
 A: If your body's centre must always be on a segment while moving in straight line, your problem looks impossible to me when the rotation pivot is "in front" of the body centre. If you allow the centre to only lie on the (infinite) line through the (finite) segment, consider the situation below.

To preserve the front of the body at the front, you should rotate by the same angle $\theta$ between the two line segments.
Let $O'$ be the rotation of $O$ around the pivot, the locus of $O'$ as $O$ moves along the first line, is a line parallel to that first line. Intersect that locus with the second line, and you'll obtain the location of $O'$ after the appropriate rotation, from which you can deduce the position of the pivot, and the position of the body centre $O$.
A: You should turn when pivot point $N$ reaches the angle bisector of $\angle ABC$, with a rotation of $2\angle BNO$. But the rotated body is turned by $180°-2\angle BON$ with respect to the direction of the path. 

To make this work, then, you must choose your pivot so that $\angle BON=90°$.

