I've been trying to make a function that returns the position of an elbow joint based on arm segment length and the shoulder and hand's position. However, my method isn't working, despite my best efforts!
Here's what I've tried so far:
var x = 0;
var y = 0;
var r = 0;
while(dist(x, y, p1x, p1y) > segLength-1 && dist(x, y, p1x, p1y) < segLength+1 && dist(x, y, p2x, p2y) > segLength-1 && dist(x, y, p2x, p2y) < segLength + 1){
r ++;
x = 200 + (cos(r) * segLength);
y = 200 + (sin(r) * segLength);
}
I know there are two different points at this distance, and I'd like to pick the one that makes the most sense as an elbow joint (usually the lower one)
I am using Khan Academy's Processing environment, so I cannot use ES6 syntax (sadly).
Circle-circle intersection points helped me with this.
here is the working code below, doing what I originally wanted it to do (draw an arm)