my favorite part of these videos is it shows the struggle, it shows the work of making a program work. I often get discouraged because I struggle so much sometimes... this allows me to understand that it's not just me and all the people who look like they do it flawlessly also have this same process.
Absolutely! I have to keep in mind that when I watch someone's video of a project, most of the time they have cut out hours of frustration and trying to find solutions online. Very few of us are these absolute genius's that can figure everything out on our own. Especially when it comes to coding.
I know nothing about Java but just randomly ended up watching this entire video, this was so brilliant! Your fun demeanor and the way you don't take yourself too serious makes a video like this so much fun to watch, and I learned a lot just watching it! Subscribed.
You're the best channel to teach scripting, thank you a lot, it's been months since i started searching for Inverse Kinematics, and now i found this video, your video for sure made it all easy
Even tough, I'm not familiar with Java, you explained the idea well enough so I can adapt this project for another programming language without rewatch anything. Thank you!
Check out my implementation, its done in javascript though but it has some detailed notes. www.khanacademy.org/computer-programming/kinematics/6459923859341312
@@boywithacoin For bones you have limited angle ranges (e.g. elbows and knees don't go backwards and are limited in how much they can twist) - this makes the IK solve more complicated as several different solutions can exist for certain poses. Think about a punching action, your shoulders, hips, elbows and everything is involved in the arm extension.
I'd do the follows thing by keeping track of the end of the tail, and then calling a recursive function like: void follow(Seg current, XY mousepos) { if(current.parent == null) { current.follow(mousepos); return; } follow(current.parent, mousepos); current.follow(current.parent); } Of course updating and drawing also needs to happen, but with this example I wanted to show the power of recursion. It first sets the last segment to follow the mouse, and then back traces to its childs without needing a reference to child segments!
I've got the similar thing... actually we do not need both side of parent and child, only need one side when initializing it, and other side to keep follow
btw, in order to do heading() function, you can just normalize the vector, and you get all of the results for the axes easily. EDIT: idk if this is right but it works for me. I'm giving this to you so your videos will be a lot easier if you try to replace PVector.heading() in 3D.
14:36 - "There's probably some redundancies in the way I'm thinking about calculating this, as there always are, but let's just do this." That right there is why I enjoy these videos so much. Sure, you can always spend more time to think of a more elegant way to code a given task, but then you could spend your whole day refining your thinking and never actually coding. I'm often guilty of that; I waste so much time coming up with better ways of coding the thing that I need to code that I end up taking much too long getting it done.
Game programmer of 30 years.. never seen this explained in such a fun way.. wish I had this video 20 years ago .. I had to figure it out with boring man books
This is so cool. Ive been trying to make inverse kinematics work inside of a vr game called Resonite for like a year now and this finally get me to the answer and now it works! Thank you
This final product looks suspiciously like forward kinematics. You should be able to move the end effector and have the starting position of the chain remain where it is.
the approach is a bit different than classic mathematical model of inverse kinematics and feels so realistic to follow and implement on my project, gonna try this but on 3D plane.
Argh, I've just started getting back to this for my full size humanoid robot. I forgot how much maths was involved. I'm a bit of a dummy when it comes to maths so I'll be watching this one a few time until it clicks back in my mind.
This would be really good for budget mocap stuff (like using the position and rotation of a small number of points to plausibly move a 3-D model, for example)!
I perfectly translated this code from processing to p5 and it's completely broken. Why do processing functions behave differently depending on their platform?
P5 is only related to processing in spirit, definitely not syntax. Virtually *all* of the math functions work differently, most notably rotation and random()
Good video, but you should be setting the child segment inside the segment class. Just parent.child = this; Doing this will help with portability of the segment class.
I really wish that the math classes required for my CS degree were CS specific. I would have had so much more interest in the math if it had been applied to code or things like this. Instead it was memorize this formula. Now plug and chug.
took me forever to realize this but the whole point of that plug and chug was so you would be able to do stuff like say "i have a problem...and i know an equation i can use to solve it". one great way to stay motivated is to find fun things to do with the math you learn. simple as rewriting a new equation in code or as complex as making a snake arm thingy move or whatever you want.
Helped me to make inverse kinematics in roblox, with only a few changes to work with the different coding language, and the difference in how each segment would be made/represented!
i am doing this in netbeans and i dont know what function to replace heading() with ,the Vec2d class doesnt seem to have anything like that ,what should i do ?
i cant belive it , i just made another java class , droppeD the source code for the pvector class ,and now i can use almost everything from it,THANK YOU
Got it myself. We need to set the point B on the target and not point A. PLUS- We can actually subtract dir from target vector instead of multiplying by -1 then adding to it.
Why would you use heading()? Isn't the point of this to explain the maths? This turns it into a Processing specific tutorial where now we have to look for other sources or the Processing source code to write an implementation.
Thats what i thought too, but you can do it all withought processing or Pvector. The mouse sets the point for the first heading, take its x and y component separately and calculate the distance to the first point, then just apply dy/dx and do atan(dy/dx) to get the heading angle. Probably otherways of doing this but it works. Heres an example. www.khanacademy.org/computer-programming/kinematics/6459923859341312
Hi everyone! This is working well in a 2D environment. But I'm trying to apply that inverse kinematics in a 3D environment. Any idea on how to calculate B based on xyz instead of just xy? Thanks by advance :)
I actually wrote myself an IK system first try in Godot w/o much hassle, this is a test (me hoping) of your ability (that you put a magnet property bc mine is barren of it)
Nice work on the link! This is very close to my project. Please can you share some experience on this with me. My email address is ootsorewilly@gmail.com. I expect your email for conversation.
Hi Corey, I wonder if you got my last reply so I had to hit a reminder. I am currently working on modelling Inverse Please I will be glad if you offer to discuss with me. My email is ootsorewilly@gmail.com.
You could interpolate between the current position and the target position using some constant (let's say 1/10th) and then use that to update to. If you do this 10 times a second (not sure if you have any control over the framerate/ update rate) you'll have it follow you with a second delay
This is like my 'rope' simulation I made many years ago. I did not know it was called Inverse Kinematics back then. I used an array for the coordinates, the segments were at maximum a pixel apart. A mouse cursor/box/reticle, when clicked would grab a segment (search through and find a segment inside the cursor) While dragged, the algorithm would make the 'grabbed' segment follow the mouse. Let's say index 25 was grabbed. It would loop both directions. 24 follows 25, 23 follows 24 and so on back to index zero. Then 26 follows 25 and 27 follows 26 and so on to end of the rope. It behaved similar to yours, more like cotton thread than rope. Perhaps some damping might work? I am this.this close to subscribing and downloading P5, is your setup unique or default? Link video to setup? I use Windows 7
@@Yourrrr Why do you have a problem with long comments? Nothing wrong with it. They're called comments for a reason. You don't ask someone for a comment, they just make it.
Yes, ive done it in khan academy code environment, to convert it to p5 just rename the funtion calls and create a setup function for the canvas the rest is exactly the same. Ie if you have Var x = function(){}; It becomes function x(){}; in p5 Thats it, that easy. Heres the link, please note its not entirely finished www.khanacademy.org/computer-programming/kinematics/6459923859341312
Why do we again, in the very beginning, make a statement ,that every next segment has an angle related to X, but not related to previous segment? In robotics with real motors it is actually so. The drive controller has no idea about orientation of the linked motor related to X. It has only a hardlink to the previous segment(s), and therefore the angle related X axis at every time moment is an unknown value, available only on a master-controller level - the controller that manages the motion of the whole "arm" can calculate it.
Memory efficient ? Not really in the way you explainded, the last object get garbage collected, and the new object is allocated, no waste, just a slightly more computation.
my favorite part of these videos is it shows the struggle, it shows the work of making a program work. I often get discouraged because I struggle so much sometimes... this allows me to understand that it's not just me and all the people who look like they do it flawlessly also have this same process.
Thank you for this feedback!
Absolutely ! Coding is learning from one's mistakes repetitively :)
@@ximecreature It feels like programming is 10% writing code and 90% of the time fixing it.
Absolutely! I have to keep in mind that when I watch someone's video of a project, most of the time they have cut out hours of frustration and trying to find solutions online. Very few of us are these absolute genius's that can figure everything out on our own. Especially when it comes to coding.
Always keep in mind, programming is 10% coding, 90% debugging ;) This is true in rough industry just like in games development.
this man gives me hope in life.
Michael Douglas why?
Because the answer to life universe and everything is 42 which equals to JS
He's using Processing, which is Java based...
cpdorli java and javascript are a world of a difference. processing.js already tells you its not java.
@@EJM07 There's processing and also processing.js which is a JavaScript port of Processing. The original version of Processing is written in Java.
I know nothing about Java but just randomly ended up watching this entire video, this was so brilliant! Your fun demeanor and the way you don't take yourself too serious makes a video like this so much fun to watch, and I learned a lot just watching it! Subscribed.
The Bob Ross of coding
If Bob Ross snorted a tablespoon of cocaine before filming
@@PurushNahiMahaPurush looool tru. he was speeeeedyyyy but I like it!
There are no errors, just happy little refactoring.. :)
lmfao
"Happy little trees", "Happy little clouds", "Happy little mountains" and "beat the devil out of it!"
You're the best channel to teach scripting, thank you a lot, it's been months since i started searching for Inverse Kinematics, and now i found this video, your video for sure made it all easy
your videos are the best. hilarious and I learn a lot. 10/10 would watch again.
thank you!!
Very right. I am busy right now but gonna put on my mobile and watch in train!
Me coming back to watch this for the third time..
Even tough, I'm not familiar with Java, you explained the idea well enough so I can adapt this project for another programming language without rewatch anything. Thank you!
please do something about constraints, that's the hard part of IK.
Check out my implementation, its done in javascript though but it has some detailed notes.
www.khanacademy.org/computer-programming/kinematics/6459923859341312
@@PaulGoux Cool but it doesn't have constraints...
github.com/tessavdheiden/tentacle_3d constraint in the base, is that what you mean?
What do you mean by constraints?
@@boywithacoin For bones you have limited angle ranges (e.g. elbows and knees don't go backwards and are limited in how much they can twist) - this makes the IK solve more complicated as several different solutions can exist for certain poses. Think about a punching action, your shoulders, hips, elbows and everything is involved in the arm extension.
Randy would love this video
This is my first video of ur channel, im not even half way done, and Im already your fan, Subscribed already.
Whenever he runs into a problem, and has to do a jump cut, my brain inserts the Spongebob meme:
🌸 _Three hours later..._ 🏵
I wish I was this enthusiastic about casual programming, like how I was like 5 years ago.
I'd do the follows thing by keeping track of the end of the tail, and then calling a recursive function like:
void follow(Seg current, XY mousepos) {
if(current.parent == null) {
current.follow(mousepos);
return;
}
follow(current.parent, mousepos);
current.follow(current.parent);
}
Of course updating and drawing also needs to happen, but with this example I wanted to show the power of recursion. It first sets the last segment to follow the mouse, and then back traces to its childs without needing a reference to child segments!
I've got the similar thing... actually we do not need both side of parent and child, only need one side when initializing it, and other side to keep follow
btw, in order to do heading() function, you can just normalize the vector, and you get all of the results for the axes easily.
EDIT: idk if this is right but it works for me. I'm giving this to you so your videos will be a lot easier if you try to replace PVector.heading() in 3D.
14:36 - "There's probably some redundancies in the way I'm thinking about calculating this, as there always are, but let's just do this."
That right there is why I enjoy these videos so much. Sure, you can always spend more time to think of a more elegant way to code a given task, but then you could spend your whole day refining your thinking and never actually coding. I'm often guilty of that; I waste so much time coming up with better ways of coding the thing that I need to code that I end up taking much too long getting it done.
Yes just make it work. Then if you walk against limits you can rewrite the code anyway.
Game programmer of 30 years.. never seen this explained in such a fun way.. wish I had this video 20 years ago .. I had to figure it out with boring man books
I never fully understood the Follow1, Follow2, Follow3 examples in Processing. This is an excellent explanation of them, thanks for that.
I'm so glad I found you on RUclips
i love the formulation and ease of comprehension of this coding squence
That it is not exactly what inverse kinematics is, but is great to see other way to solve similar problem via other ideas.
He is one of the reasons why i dont give up
This channel deserves more subs than PewDiePie
I love this man's enthusiasm
This is so cool. Ive been trying to make inverse kinematics work inside of a vr game called Resonite for like a year now and this finally get me to the answer and now it works! Thank you
Software engineer here.. Thank you so much for breaking this down in terms of code.
This guy was born to be a teacher.
Thank you so much for doing this. You are a wonderful teacher!
Thank you so much!
what did u do at 21:27 that fixed it? i cant see any change in code
Great video. Now we are waiting for IK with angle constraints,
This whole loop thing somehow defies the nesting idea... Why don't you just call the parent's update() inside of update?
Same for show().
it's wild to see the code just pour out like this
This final product looks suspiciously like forward kinematics. You should be able to move the end effector and have the starting position of the chain remain where it is.
the approach is a bit different than classic mathematical model of inverse kinematics and feels so realistic to follow and implement on my project, gonna try this but on 3D plane.
Argh, I've just started getting back to this for my full size humanoid robot. I forgot how much maths was involved. I'm a bit of a dummy when it comes to maths so I'll be watching this one a few time until it clicks back in my mind.
amazing
epic resource for ideas :) big thank
This would be really good for budget mocap stuff (like using the position and rotation of a small number of points to plausibly move a 3-D model, for example)!
Inverse Kinematics + flocking simulation = mindblown
35:42 what example ?
I perfectly translated this code from processing to p5 and it's completely broken. Why do processing functions behave differently depending on their platform?
P5 is only related to processing in spirit, definitely not syntax. Virtually *all* of the math functions work differently, most notably rotation and random()
Good video, but you should be setting the child segment inside the segment class. Just parent.child = this; Doing this will help with portability of the segment class.
Great point, thank you!
This man make we think things easier..
I actually did manage to follow this tutorial, and translated to a game engine, I'm really surprised by that
That grey background is so pleasing to eyes,
You Sir Are Brilliant!
That was very good but it wasnt the inv kinematics i expected :)
you are genius! you are the man!
first i saw you, i remember the "Professor" on a Money Heist Movies.... some kind of genius man....
I really wish that the math classes required for my CS degree were CS specific. I would have had so much more interest in the math if it had been applied to code or things like this. Instead it was memorize this formula. Now plug and chug.
took me forever to realize this but the whole point of that plug and chug was so you would be able to do stuff like say "i have a problem...and i know an equation i can use to solve it".
one great way to stay motivated is to find fun things to do with the math you learn. simple as rewriting a new equation in code or as complex as making a snake arm thingy move or whatever you want.
Love watching your videos! I don't have a JavaScript IDE on my iPad Pro, but if I did I would follow you.
Helped me to make inverse kinematics in roblox, with only a few changes to work with the different coding language, and the difference in how each segment would be made/represented!
How do you adjust the speed by which the segment follows the cursor ?
This guy is absolutely building terminator robots in his basement to subjugate humanity 100%.
any one can tell me , what's the using editor ?
To drive a group of 'snakes' around using steering behaviors/boids would be sweet.
Here's a simple example for anyone interested. I implemented my 'snakes' using a singly linked list instead, though. www.quillaja.net/snakes/
i am doing this in netbeans and i dont know what function to replace heading() with ,the Vec2d class doesnt seem to have anything like that ,what should i do ?
nvm i used angle=Math.atan2(ty-a.y, tx-a.x); and it seems to work
i cant belive it , i just made another java class , droppeD the source code for the pvector class ,and now i can use almost everything from it,THANK YOU
@@furtosstelianemanuel85 isn't it (tx - a.x) before (ty - a.y)?
@@Iconejey nope , that seemed strange to me at first aswell
I would really like to see you do this again, but then make a character walk with two legs or something
what is he using to make windows and draw lines?
What could those backwards rainbow stickers possibly mean?
Wow, subbed. Looking forward to watching you fixed point video on the same subject. Many thanks.
Why do we need a = target vector + dir vector ? We can just directly set a = targetVector
Got it myself. We need to set the point B on the target and not point A.
PLUS- We can actually subtract dir from target vector instead of multiplying by -1 then adding to it.
Why would you use heading()? Isn't the point of this to explain the maths? This turns it into a Processing specific tutorial where now we have to look for other sources or the Processing source code to write an implementation.
Jeru Sanders I think it would be pretty easy to implement calculating the heading in other languages, but yeah, that was an oversight.
Mate, if this was about maths, he wouldn't be using Processing to begin with.
Thats what i thought too, but you can do it all withought processing or Pvector. The mouse sets the point for the first heading, take its x and y component separately and calculate the distance to the first point, then just apply dy/dx and do atan(dy/dx) to get the heading angle. Probably otherways of doing this but it works. Heres an example.
www.khanacademy.org/computer-programming/kinematics/6459923859341312
Kinematics is also used in CNC machines
Hi everyone! This is working well in a 2D environment. But I'm trying to apply that inverse kinematics in a 3D environment. Any idea on how to calculate B based on xyz instead of just xy? Thanks by advance :)
Did you figure it out at some point? I have the same problem
34:09 great you've made artistic lazy stroke!
the 'we're actually done' xD (16:15)
Can anyone suggest the same for c++ and opengl
I suggest the same for c++ and opengl.
Is the method described here called: Cyclic-Coordinate Descent ?
You are the best.
I would love to just sit in a room with this man and let him talk.
The way it moves reminds me of how claymation moves
I envision the next uber snake game. No more NSEW only. Now you can go at 30,45,60 degree turns.
how could you combine inverse and forwards kinematics and what would it become?
Apply forward kinematics then inverse on the calculated pose, that's the normal approach. IK is usually used to fix FK into proper positioning
Something like this perhaps, please note its a work in progress.
www.khanacademy.org/computer-programming/kinematics/6459923859341312
When I was just looking how to use inverse kinematic in programming, and instead realize the importance of a goal.
I actually wrote myself an IK system first try in Godot w/o much hassle, this is a test (me hoping) of your ability (that you put a magnet property bc mine is barren of it)
Please please please make DS and Algorithm series!!
If you wanted to make it so that it takes a second to catch up to the mouse, would you limit the magnitude of the target vector of the head?
Love this idea! You could also look at my "seek" example.
I made it in JavaScript: redmoncoreyl.github.io/snake/
Nice work on the link!
This is very close to my project. Please can you share some experience on this with me. My email address is ootsorewilly@gmail.com.
I expect your email for conversation.
Hi Corey, I wonder if you got my last reply so I had to hit a reminder. I am currently working on modelling Inverse Please I will be glad if you offer to discuss with me. My email is ootsorewilly@gmail.com.
You could interpolate between the current position and the target position using some constant (let's say 1/10th) and then use that to update to. If you do this 10 times a second (not sure if you have any control over the framerate/ update rate) you'll have it follow you with a second delay
Is it possible to incorporate a z axis?
Mike Hatfield For sure, it would just need some calculus if you wanted the segments to retain their volume
how can i know this guy at 2020
so awesome !!!
So much love
Does someone know what the benefit of him using java instead of something like python which is what most use for IK?
Being able this use this IDE
What font is he using?
Just hit the gold mine
This is like my 'rope' simulation I made many years ago. I did not know it was called Inverse Kinematics back then.
I used an array for the coordinates, the segments were at maximum a pixel apart.
A mouse cursor/box/reticle, when clicked would grab a segment (search through and find a segment inside the cursor)
While dragged, the algorithm would make the 'grabbed' segment follow the mouse.
Let's say index 25 was grabbed. It would loop both directions. 24 follows 25, 23 follows 24 and so on back to index zero. Then 26 follows 25 and 27 follows 26 and so on to end of the rope.
It behaved similar to yours, more like cotton thread than rope. Perhaps some damping might work?
I am this.this close to subscribing and downloading P5, is your setup unique or default? Link video to setup? I use Windows 7
fox fyre3 1. this comment was so unnecessary and lengthy lol why? who asked??
2. one of his first videos shows his work space set up
Unique Antoinette, I thought it was an interesting comment. No need to rag on someone for a relatively long comment.
Unique Antoinette, who asked you :P I thought it was a nice comment.
@@Yourrrr Why do you have a problem with long comments? Nothing wrong with it. They're called comments for a reason. You don't ask someone for a comment, they just make it.
@@adamthedog1 yeah
Can you do something other than p5.js
You rock!
Thank you .
3:20 "jadi jada jada" this took away my last doubts about your broad general IT knowledge.
Motivating
I guess you can offset the alignment and make a lot of "fishes" following the mouse
This dude is so cool
THIS GUY IS BIG SMART
Can you do this in p5
Yes, ive done it in khan academy code environment, to convert it to p5 just rename the funtion calls and create a setup function for the canvas the rest is exactly the same. Ie if you have
Var x = function(){};
It becomes function x(){}; in p5
Thats it, that easy.
Heres the link, please note its not entirely finished
www.khanacademy.org/computer-programming/kinematics/6459923859341312
Why do we again, in the very beginning, make a statement ,that every next segment has an angle related to X, but not related to previous segment? In robotics with real motors it is actually so. The drive controller has no idea about orientation of the linked motor related to X. It has only a hardlink to the previous segment(s), and therefore the angle related X axis at every time moment is an unknown value, available only on a master-controller level - the controller that manages the motion of the whole "arm" can calculate it.
I changed the follow() function.
Now it looks like this:
void follow(PVector target){
follow(target.x,target.y);
}
void follow(float tx,float ty){
PVector target = new PVector(tx,ty);
PVector dir = PVector.sub(target,a);
angle=dir.heading();
dir.setMag(len);
dir.mult(-1);
a=PVector.add(target,dir);
if(parent!=null){
parent.follow(a);
}
hahah you're great. Thanks for this. xD
your anlge is just:
atan2(x2 - x1, y2 - y1)
@Rotten Brainz maybe
he's really funny inside and outside :))
Memory efficient ? Not really in the way you explainded, the last object get garbage collected, and the new object is allocated, no waste, just a slightly more computation.
Perlin noise: *exists*
Daniel: 👁👄👁