# Finding shape preserving positioning of a 'piston'

I have a chain of rods that are setup in a default, ideal orientation. Points are labelled with a 'p' prefix, their lengths with an r:

I then stretch them to reach a desired end location, but they lose their shape:

I'd like to see if there's a better 'result' that tries to respect the shape of the original setup, with the following constraints:

• r1, r2 and r3 can't change length
• p1 and p4 are fixed

My intuition here says that I could build an equation for p2 based on the circle described by p1 and r1, and do the same thing for p4 and r3. I have an equation for p3 and p2 (satisfying length), but I'm unsure how to use the math to describe "maintaining the shape".

• Something is not clear. What do you mean by "stretch" if p1 and p4 are fixed? Are they not the same values in the upper and lower figure? May 14, 2018 at 15:35
• Just to make sure I understand, in the second set up you change $|\overline{p_1p_4}|$ and let the rods move around the circles, is that it? May 14, 2018 at 15:36
• @Andrei: Apologies, my usage of "stretch" meant to "stretch the chain of rods out", not stretch any of the individual rods. So yes, the rods are all of equal length, but their angles differ. May 14, 2018 at 16:02
• @caverac: Yes. To be precise: I've left P1 alone, and moved P2, P3 and P4 to new locations, preserving joint length. The only things I care about however are that P1 and P4 remain fixed, and P2 and P3 retain some of the shape of the original configuration, if possible. May 14, 2018 at 16:04
• But if you keep P1 and P4, why not keep P2 and P3 as well? May 14, 2018 at 16:05

As in your bottom drawing you know p2 is on the left circle and p3 is on the right. Put p1 at the origin and measure the angle of the p1p2 segment by $\theta$ with $0$ to the right and increasing counterclockwise. The position of p2 is then $(r1\cos \theta, r1\sin \theta)$ You can put p4 on the positive $x$ axis. Also define $\phi$ as the angle of p3p4 measured the same way. The position of p3 is $(p4+r3\cos \phi,r3\sin \phi)$. For a given $\theta$ there will be $0,1,$ or $2$ points that p3 can be to maintain the length r2. Probably the best measure of similarity is to compare the two angles of the linkage from start to finish. You might add the absolute differences, but you have to watch out for wrapping around.