# 2 pivot arm Joint Movement

Hi.
Does anyone the "Algorythm"
To Simulate A Joint Movement
On The End Of An Arm ?

• : Hi.
: Does anyone the "Algorythm"
: To Simulate A Joint Movement
: On The End Of An Arm ?
:

:
:
:

I have a stickman program made in Delphi. You can get it by clicking my name at the top of this message. Its in my list of uploads.

The albow is the centre of a circle. The angle of the arm, is just an angle. By changing the angle, you change the location of the hand.

Here is some math for finding the location of the hand based on the location of the albow and an angle of the arm:

hand.x = albow.x + ArmLength*cos(angle)

hand.y = albow.y + ArmLength*sin(angle)
• [b][red]This message was edited by GrimChild at 2002-10-21 13:57:23[/red][/b][hr]
Thanx But !!

I've already done something a bit similar.
What i need is not far from that and your so close.

Im talking about Reversing what you have explained.
Instead of calculating the shoulder-->elbow-->hand what i need in fact is just the opposite. Like A Marionette. A string on the hand moves the hand. so Therefore I need to calculate Hand-->elbow-->Shoulder.

Check out this Java Applet i found at http://robot.me.gatech.edu/APPLETS/Platform3RRR.html , It does exactally what i'm looking for but on 3 appendages. each appendage has 3 points (the base which dont move) ,the elbow, and the hand part.

• I've been looking All Over The Internet and Still Cannot Find Anything That Helps.
I found A Few Java Applets containing the math i need to do this, but its too hard to decypher within the code itself. I keep comming up with Inverse Kinematics ???
It seems like this should'nt be so difficult.
I have the angle of the hand to shoulder. and the angle of the hand to the elbow. Along with the calculated distance of the hand to the shoulder. I've been trying to hopefully stumple upon the correct combination of these to create an algorythm knowing that the arm streached out should give 180 degrees with both joints.
So in other words. After about a week of searching and asking for the right answers. I'm still clueless and completely exhausted with this riddle. Yet, I never give up.
I hope someone comes up with something soon :-)
• : I've been looking All Over The Internet and Still Cannot Find Anything That Helps.
: I found A Few Java Applets containing the math i need to do this, but its too hard to decypher within the code itself. I keep comming up with Inverse Kinematics ???
: It seems like this should'nt be so difficult.
: I have the angle of the hand to shoulder. and the angle of the hand to the elbow. Along with the calculated distance of the hand to the shoulder. I've been trying to hopefully stumple upon the correct combination of these to create an algorythm knowing that the arm streached out should give 180 degrees with both joints.
: So in other words. After about a week of searching and asking for the right answers. I'm still clueless and completely exhausted with this riddle. Yet, I never give up.
: I hope someone comes up with something soon :-)

For the following, I will assume that you know the distance from the hand to the shoulder and how long the 2 parts of the arm will be. I'll try to be clear with explaining the math. It may look a little complicated but just read through it step by step and it'll be easy.

[hr]
If you look closely, you can find a triangle formed.
The verticies being the hand, the shoulder and the elbow.

if you know the coordinates of the hand and the shoulder, you can calculate the distance between the points by using the pathagorian theorum.

separation = sqrt( (p1.x-p2.x) + (p1.y-p2.y) )

[hr]

Here is the cos law
a = b+c - 2*b*c*cos(A)

Now I will substitute some, more symbolic variable names.
e = s+h - 2*s*h*cos(E)

e = the distance from the hand to the shoulder
This is the separation calculated above.

s,h = the distances from the elbow to the hand and to the shoulder
E = the angle at the elbow

For the following, I will solve for the angle E.

[hr]
e = s+h - 2*s*h*cos(E)
e - (s+h) = (s+h) - (s^2+h^2) - 2*s*h*cos(E)
e - (s+h) = [s](s+h)[/s] - [s](s^2+h^2)[/s] - 2*s*h*cos(E)
e - s - h = - 2*s*h*cos(E)
(e - s - h)* [1/(-2*s*h)] = (- 2*s*h) * [1/(-2*s*h)] *cos(E)
(e - s - h)* [1/(-2*s*h)] = (- 2*s*h) * [1/(-2*s*h)] *cos(E)
(e - s - h)* [1/(-2*s*h)] = [s](- 2*s*h)[/s] * [s][1/(-2*s*h)][/s] *cos(E)
(e - s - h)* [1/(-2*s*h)] = cos(E)
arccos[(e - s - h)* [1/(-2*s*h)]] = arccos(cos(E))
arccos[(e - s - h)* [1/(-2*s*h)]] = [s]arccos[/s]([s]cos[/s](E))
arccos[(e - s - h)* [1/(-2*s*h)]] = E
E = arccos[(e - s - h)* [1/(-2*s*h)]]

Since you know the related values for each of the 3 angles in the triangle, you can also find the other angles using the same formulae but the appropriate variables.

H = arccos[(h - s - e)* [1/(-2*s*e)]], where H is the angle between the shoulder and the elbow

S = arccos[(s - h - e)* [1/(-2*h*e)]], where S is the angle between the elbow and the hand

[hr]

http://robot.me.gatech.edu/APPLETS/Platform3RRR.html
This site, you showed me, it illustrates 2 posible solutions for each arm. The reason for 2 is that arccos can return 2 posible angles in a full circle that are both correct angles. I mean the cos of both results is the same.

cos(x) = cos(-x)

This statement is true no matter what the value of x.

[hr]

Anyway,

By knowing the angles of the joints and the length of the different parts of the arm, you can calculate the coordinates of the elbow.

[hr]

I hope I was right in my assumption that you know where the shoulder and hand are. I assumed that based on the link, you gave me.
• Holy Moly...lol'

Brilliant !!

Thanx A Billion Joshcode' !!!

You see, my problem is that i dont understand all them
weird looking symbols. I only know whats going on when its put in
a normal mathmatical formula.

I tried it out and it works great.
I see what you mean by the 2 possible solutions. when the arm is straight and the hand is then moved to the left, the elbow joint thus flips to the right. I suppose that would be the (inverse) in the (Kinematics)... lol

I can sleep Now !!
Thank You !!!