This is a function to calculate - from the two big dots (p1, p2) in the segment - a polygon consisting of 4 points. p3.x is the thickness of p1, and p3.y is the thickness of p2. Currently it works fine with IK movement but without the legs attached.

So what I'm trying to achieve with the legs basically the same thing as with generating 4points out of 2. I want to make the limbs always perpendicular to the body, so I'm asuming to achieve that I'd need to use the same method:
Code:
function normal(p1:Point, p2:Point):Point {
	var vx:Point = p2.subtract(p1);
	var n:Point = new Point(vx.y, -vx.x);
	n.normalize(1);
	return n;
}
Code:
pt1 = new Point(a[0][c], b[0][c]);
pt2 = new Point(a[0][c-1], b[0][c-1]);
pn = normal(pt1, pt2);
p1 = new Point(a[0][c]+a[c][i]*pn.x, b[0][c]+b[c][i]*pn.y);
p2 = new Point(a[0][c]+a[c][i+1]*pn.x, b[0][c]+b[c][i+1]*pn.y);
p3 = new Point(s[c][i], s[c][i+1]);
pointsToPoly(p1, p2, p3);
so instead of using p3 as a the thickness for each point use it as the distance from the joint to the limb, but there's a reoccuring problem.



Left/Right is fine besides the fact that the limbs overlap, but when turn to go up/down the limbs fold on themselves.