# Robotic Appendages in MMA

I am trying to animate a generalized abstraction of robotic appendages (arms, hands, legs) in Mathematica where the translation is "smooth" in the sense that all of the points except for the "pinch point" moves simultaneously.

Assuming that an appendage can always be wrapped into one of two convex polygons, we pick a vertex of the polygon to be the "blossom point" where the convex polygon opens up at and a vertex that is the "pinch point" that does not. Sometimes the blossom and pinch points are the same.

Here are two photos of such starting polygons with a blue pinch points and an orange blossom point:

that was generated with the code:

randomPoly=RandomPolygon[{"Convex",RandomInteger[{3,20}]}];
pinchPoint=RandomChoice[randomPoly[[1]]];
blossomPoint=RandomChoice[randomPoly[[1]]];
Rasterize[ListPlot[Join[randomPoly[[1]],{randomPoly[[1]][[1]]}],Joined->True,Axes->False, Epilog -> {
PointSize[0.02], Blue, Point[pinchPoint], (* First special point in blue *)
PointSize[0.02], Orange, Point[blossomPoint] (* Second special point in orange *)
}]]


There are a couple of things that I know:

• The sum of exterior angles for any convex polygon is always $$2\pi$$.
• A straight line segment with nodes will always as the 'mid point' between the two convex polygons.
• The number of nodes will always be one more than the convex polygon vertex quantity when it is not completely closed.
• Obviously the length is the same through out the entire animation.

This is a partial answer and a good start.

So, there is a problem with the OP. The solution is not unique. There are many possible solutions. If you extend the line segments of the polygon around the pinch boint, $$P$$, provided that blossom point, $$B$$, is such that $$B \neq P$$, you always have three regions available. The region formed by the clockwise segments connected to the blossom point, and the region formed by the counterclockwise segments, and the one in the middle which is inbetween the line extensions. If the straightened line segment lies in the middle region, it will be a knot vector from $$\overline{PN}$$ where the knots collapse onto the segment. Otherwise The transitional line segment will be any line segment of the arc length, $$\sigma$$ , it connects a point in the first or last region such that the lengths on each side of the pinch point is $$\sigma(\unicode{x21BB}\overline{PT_1}) \text{ and } \sigma(\unicode{x21BB}\overline{PT_3})$$ where $$T_1$$ is a point in the first region and $$T_3$$ is a point in the third region, and $$\sigma()$$ means $$\textit{arc length of}$$.

Furthermore, closing it is not unique either. You need to have a "nyctinasty" point, $$N$$, specified if you are given a knot vector in order to get closure. The possibility of that point is any point on mirror side of the original polygon where the clockwise polygonal chain $$\unicode{x21BB}\overline{PN}$$ length can be collapsed to reach $$N$$ as well as the counterclockwise for $$\unicode{x21BA}\overline{PN}$$.

Now, if $$P = B$$, then obviously $$P = N$$ as well. So there are two posibilities given a polygon. It either opens up "clockwise" or unfurls "counterclockwise".

Here is a picture of a polygon with two normalized vectors pointing out of the pinch point as if the adjacent line segments were extended. Here $$P$$ is blue and $$B$$ is orange. There are 3 regions for the arms to be according to the description above:

randomPoly=RandomPolygon[{"Convex",RandomInteger[{3,20}]}];
pinchPoint=RandomChoice[randomPoly[[1]]];
blossomPoint=RandomChoice[randomPoly[[1]]];
(* Get the indices of the blossomPoint in the polygon point list *)
pinchIndex = First[First[Position[randomPoly[[1]],pinchPoint]]];
(* Calculate the vectors for the adjacent points *)
prevPoint = randomPoly[[1]][[Mod[pinchIndex - 1, Length[randomPoly[[1]]], 1]]];
nextPoint = randomPoly[[1]][[Mod[pinchIndex + 1, Length[randomPoly[[1]]], 1]]];
(* Create the direction vectors *)
dir1 = Normalize[pinchPoint - prevPoint];
dir2 = Normalize[pinchPoint - nextPoint];
(* Create the arrows *)
arrow1 ={Arrowheads[Large], Arrow[{pinchPoint, pinchPoint + dir1}]};
arrow2 = {Arrowheads[Large],Arrow[{pinchPoint, pinchPoint + dir2}]};
(* Add the arrows to the existing plot *)
ListPlot[Join[randomPoly[[1]], {randomPoly[[1]][[1]]}], Joined -> True, Axes -> False,
Epilog -> {
PointSize[0.02], Blue, Point[pinchPoint], (* First special point in blue *)
PointSize[0.02], Orange, Point[blossomPoint], (* Second special point in orange *)
Black, arrow1, arrow2
}]