Inverse Kinematics

From WikiCoder
Revision as of 13:52, 4 August 2020 by Retrotation (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Inverse Kinematics is a technique of determining the angles of a chain of joints, via the start and end position in the chain of joints. Because the segments of the joints are of known size, we can mathematically determine the angles of those joints from the sides.

Finding The Angle

Using the Law Of Cosines, we can find Angle C (in Radians) if we know the lengths of sides a, b, and c. We do know the lengths of these sides, because the segments of the joints are fixed in length, and (in the case of an arm or leg joint) the third side of the triangle is known by the distance between the start and end-points of the joint chain.

c^2 = a^2 + b^2 − 2ab cos(C)

// Finding the Angle C
c^2 - c^2 = a^2 + b^2 - c2
2ab cos(C) = a^2 + b^2 - 2ab cos(C) + 2ab cos(C)
(2ab cos(C)) / 2ab = (a^2 + b^2 - c^2) / 2ab
aCos(cos(C)) = aCos((a^2 + b^2 - c^2) / 2ab)
C = aCos((a^2 + b^2 - c^2) / 2ab)