# Inverse Kinematics: The Math

Hey guys,

So, I'm new here. And I'm of 13 years of age. I am a programmer in a platform called "ROBLOX". I wanted to create my own Animator within that platform, using Inverse Kinematics. However, searching through the web, everything is just so complicated to me. I don't seem to understand the wide and complicated scope of the vocabulary.

I kind-of understand the concept of Inverse Kinematics. But I don't really understand it overall. The math, and how to calculate it, what it is, how it works, etc. So, I was wondering if any of you could give me a rundown, suited for a 13 year old, like me.

I would be very grateful.

## Answers and Replies

Related Other Physics Topics News on Phys.org
berkeman
Mentor
Hey guys,

So, I'm new here. And I'm of 13 years of age. I am a programmer in a platform called "ROBLOX". I wanted to create my own Animator within that platform, using Inverse Kinematics. However, searching through the web, everything is just so complicated to me. I don't seem to understand the wide and complicated scope of the vocabulary.

I kind-of understand the concept of Inverse Kinematics. But I don't really understand it overall. The math, and how to calculate it, what it is, how it works, etc. So, I was wondering if any of you could give me a rundown, suited for a 13 year old, like me.

I would be very grateful.
Welcome to the PF.

It would help a lot if you could post some links to the reading you've been doing. What math have you had so far? Algebra, any trig?, any early calculus?

We may end up moving this thread to one of the other forums here at the PF if it matches better.

What is inverse kinematics?

Welcome to the PF.

It would help a lot if you could post some links to the reading you've been doing. What math have you had so far? Algebra, any trig?, any early calculus?

We may end up moving this thread to one of the other forums here at the PF if it matches better.
Hi, thanks for the response. I've been looking at some links like a Lecture, Unity Engines and most primarily: http://freespace.virgin.net/hugo.elias/models/m_ik2.htm .

Anyone have any ideas?

Nugatory
Mentor
Anyone have any ideas?
Well, it's in the nature of an Internet forum that if people think they have something to say they say it, and then you have a different problem on your hands: separating the few good answers from the many bad ones. So the fact that you're not hearing much suggests that the answer to that question is "no" - no one has any ideas about a good writeup suitable for a 13-year-old.

That doesn't mean you're stuck, but it may mean that it will be a bit harder than you had hoped. You said "I don't seem to understand the wide and complicated scope of the vocabulary" when you read what's out there; that's generally a sign that the authors are assuming their readers have more background, in this case math, than you do. You still haven't answered Berkeman's question about how much math you've studied, but it may be that you just have to learn more. Can you study ahead in your school's math curriculum?

ogg
The math you need to solve the problem is fairly straight-forward. I've never heard of "inverse kinematics" and know nothing about it. You're on your own there.

But if you want a "brute force" approach, then read on. First, you need to understand how to determine the distance between two points. The formula you use depends on what KIND of coordinate system you choose to use. Its a choice. Lets see, if you're 13 you're maybe in 7th Grade? So you haven't had any exposure to geometry and angles? Sines and cosines?

Oh, boy. This makes it a bit harder. That's why you were asked what your background was. Why you didn't respond is another issue. So, if I have a rod attached to a ball joint, I can describe the position of the tip of the rod (its end) by a set of coordinates (2 coordinates if you're working on a plane, for instance on a monitor). If the rod is a fixed length then the possible locations (assuming the origin is fixed) are all on the surface of a sphere. So, you actually need only to know the length and one coordinate. (the other coordinate is a function of it).

You might use the x and y coordinates (euclidean coordinates) or you might use polar coordinates and use an angles instead. For most people angles are a bit easier to understand with an arm consisting of rods and joints, but there's no fundamental difference between using angles and using xyz coordinates; the problem can be solved either way. Each rod starts at a fixed point (as a result of the 'previous' rods connecting it to the real starting point) and can rotate through a range of angles (but NOT 360°, I assume - you can't fold two rods so they both occupy the same space).

So the problem becomes A. determining the location of a given joint (at previous rod's tip) and B. selecting a position (a location) of a rod FROM that joint so that it gets your arm closer to the desired final point. The most brute force approach is to pick each joint's position as being on the straight line between the origin and the end-point and then figure out the position of the next rod.

One of two things happens: A. after you've positioned the final rod, you are short of your goal, meaning your arm isn't long enough to reach OR B. your arm is extended past your goal, meaning you will have to bend some of the joints. Chose one, bend it and you now need to extend the rods from that joint towards the goal and you're back in the same situation with two possibilities.

I've made a bunch of assumptions here, one is that you can easily look up the equations for distance, and the equations for polar coordinates (if you want them). Another is that there are few constraints on the arm, and any there are are easily handled by your program. The final assumption is that you simply don't have the math background to understand all of the math which would be required for a more "elegant" solution.

You could be an exception, but for most people the math would require months or years of study in order to understand what you call "the vocabulary". If you have a specific question about a specific term, we can help (but other sources are likely to be better), but if you want to understand all of (or even most of) the math background you won't be solving this anytime soon. You need trigonometry, and differential calculus and multivariate (differential) calculus, as well as an understanding of matrices, linear equations and in computer science depth-first and breadth-first optimization.

We can't do all that here. Your arm may have one joint or a thousand, the solution gets harder and harder for each length you add.

Last edited by a moderator:
Welcome to the PF.

It would help a lot if you could post some links to the reading you've been doing. What math have you had so far? Algebra, any trig?, any early calculus?

We may end up moving this thread to one of the other forums here at the PF if it matches better.
Sorry for the really, really late reply. I've been very busy with tests, assessments, and just general life. However, that's all finished so I'm ready to concentrate again!

For what math I have done so far, I've done Algebra, haven't really touched trigonometry, however, I've done independent studying on trigonometry using KhanAcademy. The fact that I don't know what exactly "calculus" is doesn't really help, I guess.

Well, it's in the nature of an Internet forum that if people think they have something to say they say it, and then you have a different problem on your hands: separating the few good answers from the many bad ones. So the fact that you're not hearing much suggests that the answer to that question is "no" - no one has any ideas about a good writeup suitable for a 13-year-old.

That doesn't mean you're stuck, but it may mean that it will be a bit harder than you had hoped. You said "I don't seem to understand the wide and complicated scope of the vocabulary" when you read what's out there; that's generally a sign that the authors are assuming their readers have more background, in this case math, than you do. You still haven't answered Berkeman's question about how much math you've studied, but it may be that you just have to learn more. Can you study ahead in your school's math curriculum?
I don't know if I can study ahead of my school's math curriculum due to it being within a classroom environment. However, I can do my own independent study within places like KhanAcademy, in books, etc.

The math you need to solve the problem is fairly straight-forward. I've never heard of "inverse kinematics" and know nothing about it. You're on your own there.

We can't do all that here. Your arm may have one joint or a thousand, the solution gets harder and harder for each length you add.
But if you want a "brute force" approach, then read on. First, you need to understand how to determine the distance between two points. The formula you use depends on what KIND of coordinate system you choose to use. Its a choice. Lets see, if you're 13 you're maybe in 7th Grade? So you haven't had any exposure to geometry and angles? Sines and cosines?

What is exactly is the "brute force" approach? Since you indicated that you know nothing on the subject of inverse kinematics, is it some sort of "replication" of inverse kinematics, something that isn't exactly inverse kinematics, but is trying to behave like it?

I've covered angles, but geometry I haven't. In my own independent studying, I've touched upon sines and cosines, but very lightly.

Oh, boy. This makes it a bit harder. That's why you were asked what your background was. Why you didn't respond is another issue. So, if I have a rod attached to a ball joint, I can describe the position of the tip of the rod (its end) by a set of coordinates (2 coordinates if you're working on a plane, for instance on a monitor). If the rod is a fixed length then the possible locations (assuming the origin is fixed) are all on the surface of a sphere. So, you actually need only to know the length and one coordinate. (the other coordinate is a function of it).

I'm assuming this is for a 2D example, due to two coordinates and working on a plane.
Saying the "rod" is the arm, then yes, it will be of a fixed length, but as far as I know, you're describing an arm which is made up of one joint? The ball joint is just where it is rotated at?

You might use the x and y coordinates (euclidean coordinates) or you might use polar coordinates and use an angles instead. For most people angles are a bit easier to understand with an arm consisting of rods and joints, but there's no fundamental difference between using angles and using xyz coordinates; the problem can be solved either way. Each rod starts at a fixed point (as a result of the 'previous' rods connecting it to the real starting point) and can rotate through a range of angles (but NOT 360°, I assume - you can't fold two rods so they both occupy the same space).

So the problem becomes A. determining the location of a given joint (at previous rod's tip) and B. selecting a position (a location) of a rod FROM that joint so that it gets your arm closer to the desired final point. The most brute force approach is to pick each joint's position as being on the straight line between the origin and the end-point and then figure out the position of the next rod.

So, we start off deciding one joints position/location, and then do the exact same thing to the next join, depending on the previous joints position/location?

One of two things happens: A. after you've positioned the final rod, you are short of your goal, meaning your arm isn't long enough to reach OR B. your arm is extended past your goal, meaning you will have to bend some of the joints. Chose one, bend it and you now need to extend the rods from that joint towards the goal and you're back in the same situation with two possibilities.

So, it's like a trial-and-error system? We keep on calculating until it's at its closest point? Going back to the previous step, and repeating that?

I've made a bunch of assumptions here, one is that you can easily look up the equations for distance, and the equations for polar coordinates (if you want them). Another is that there are few constraints on the arm, and any there are are easily handled by your program. The final assumption is that you simply don't have the math background to understand all of the math which would be required for a more "elegant" solution.

You could be an exception, but for most people the math would require months or years of study in order to understand what you call "the vocabulary". If you have a specific question about a specific term, we can help (but other sources are likely to be better), but if you want to understand all of (or even most of) the math background you won't be solving this anytime soon.

Yeah, I agree. The problem here is my inexperience and, well my age. The main problem is the "vocabulary", or even knowing what I need. I'm like a builder who doesn't know what tools he needs or has.

You need trigonometry, and differential calculus and multivariate (differential) calculus, as well as an understanding of matrices, linear equations and in computer science depth-first and breadth-first optimization.

You just gave me some tools! I'll start studying/researching on these topics!

You've been a great help. I can't thank you enough! Hopefully using this, I achieve my goal of utilising inverse kinematics! Thanks!

You want to build a robot arm (on the computer) as shown in the picture. So you want to compute for a target, the necessary angles a and b that do that for you? Is that your goal?

Grobner bases are probably of much better use then than this entire inverse kinematics stuff.

You want to build a robot arm (on the computer) as shown in the picture. So you want to compute for a target, the necessary angles a and b that do that for you? Is that your goal?

Grobner bases are probably of much better use then than this entire inverse kinematics stuff.
Well, kind of. I'm not exactly building a "robot arm", I'm building [in-game] character/humanoid arms/legs.

I've just looked up on Grobner bases, I can't really find any "implementation" of it specifically, but I will try to dive deeper into it. However, I have found something from: http://mathworld.wolfram.com/GroebnerBasis.html
It states:
"computing a Gröbner basis can be so computationally expensive".

This is a worry, since the calculations for the original IK solution would happen nearly all the time. Since, when the character moves, it has to calculate new positions/rotations for the legs/arms with the new and old positions/rotations, I guess.