1:20 oh my god this slowed down and then sped up visualization was amazing a picture is worth a thousand words, and a video can be worth a thousand pictures :D
I think it would be really cool to combine this technique with something like Boid's algorithm and get whole flocks of creatures moving around like this!
Thank you for the video. I've been trying to figure out inverse kinematics for a long time and you helped a lot. I was able to reproduce your Processing in Python. I hope to eventually implement it in Godot and try to add paws to the fish.
You’re welcome. I’m glad it was helpful. Which graphics library do you use with Python? I’ve played with Godot a little bit, but mostly use Unity for game development.
I should have guessed :) I've used the Python version myself a little bit, but I'm so used to Java in the Processing environment that when I switch languages in Processing I make all sorts of mistakes. It's like I need to use a different IDE for each language so my brain knows what language I'm using.
Thanks! You're right that there's a strong resemblance to tadpoles. I tried to lean away from the look because it's too easy to get misinterpreted as other large headed swimmy things and I didn't want to get in trouble with the UA-cam algorithm :)
This is a great video. I saw that you mentioned working in other languages. You might find better traction on youtube swapping out java for a more popular language/framework. For example, Javascript with p5.js. I'm not super familiar with p5 but I'm sure that it has all of the features needed to recreate this concept with it. This is just one example though. Either way, this was fun to watch.
Thanks for the comment and the suggestion. I've programmed a reasonable amount in Javascript, but haven't taken the time to work with p5.js much. I've been tempted to use C++, but installing it for graphics might be a pain for viewers.
Thanks for the reminder. I regularly switch between languages, not all of which have a TWO_PI or use a different convention for formatting constants. So, I find it easier to use 2*PI then to try to remember which form the constant takes. I'm curious if you know if 2*PI would be precomputed when the Java is compiled into byte-code. I couldn't find a definitive answer.
@@programmingchaos8957 As documented it is the number 6.28... and in Java there are no "#define'd constants" only "uppercase variables", so it is at worst a variable fetch. But my point is more the use of the modulo instead of iterating additions/subtractions.
@programmingchaos8957 As documented it is the number 6.28... and in Java there are no "#define'd constants" only "uppercase variables", so it is at worst a variable fetch. But my point is more the use of the modulo instead of iterating additions/subtractions.
Ah, that is a good point. My personal problem is that not all languages handle modulo with decimals (or it's a newer feature). So, in a given language I can't always remember if its valid or not - hence relying on addition/subtraction.
That's an excellent question. With the algorithm in the video movement tends to 'dampen out' whereas sidewinders maintain a fairly strong curve over their whole body. Watching some videos of them it looks like maybe all of their body 'segments' move through the same spaces/curves. So, something more like a traditional snake game snake, but with the head moving in sin() wave might be a good starting point. It's also possible that someone has already figured out the algorithm and posted it, but if so, I haven't seen it. If you make any progress on this, I'd love to hear about it.
@@programmingchaos8957 For me it looks like it is stepping with its head, or neck. Based on its trail i can see that there are always two contact points to it with the ground. This reminds me of a cork screw that is rolling with its tip that is like the snake's head region, or rather the neck of it because it keeps its head away from the ground. Also the trail of it looks like the tangent function a littlebit
Good observations. The bit about looking like a corkscrew might be a clue as to how to model it. The whole body shaped roughly like a corkscrew, but with each section progressing through the curve.
@@programmingchaos8957 Humanoid things have their feet on the ground while they are stepping too. I can imagine the place where the snake puts its neck to the first time as a humanoid foot step. Basically the segments must go through that first footprint first, and then towards the neck of the snake. After that spot there is a straight part on which the snake "stands", and then a turn which is the last stationary place of the snake's step. Each snake step consists of two turns, and a straight part, that is two stationary points Everything after that has to go through these stationary points before it can go towards the snake's head, but also only these segments are not touching the ground so these are the suspectible to curve when the snake turns. After that there are going to be two additional points where the snake "stands" with its tail part like a leg behind. These two points are also stationary. So i would place a point where the snake puts its neck not its head first, and then make an additional point at a certain distance from the first, at a certain angle compared to the direction the snake went when its neck step "touched" the ground, and then pull everything through these two points first. I would also make sure that the snake does exactly two steps before it "runs out" by tuning its initial two points' distance, and the snake's length.
I watched several videos, and read a couple of blog posts, before putting this together. But you one of them was argonaut's video - good spotting. Of the techniques I looked at this one seemed the simplest to code.
Hi. This is a pretty well known technique that's been around for quite a while. I thought having a version that stepped though the programming could be useful for some viewers. To be clear almost none of the algorithms I present (or that are in most UA-cam videos) are completely original. For example, my previous video was on genetic algorithms, which go back at least to John Holland's work in the 1970's. I'm just trying to present algorithms in a way that is helpful to the viewers. I have to say that argonaut's video is very impressive, and possibly does a better job of illustrating the idea than my own - thanks for pointing it out.
1:20 oh my god this slowed down and then sped up visualization was amazing
a picture is worth a thousand words, and a video can be worth a thousand pictures :D
Thank you for the comment! Coding that example was a last minute decision. So, I’m really glad to hear it was useful.
This is all so clear to me. You should be a teacher. Thanks Terry, I always enjoy your videos.
Wow, thanks! I am a teacher, so it’s great to hear that I’m doing a decent job at it.
I think it would be really cool to combine this technique with something like Boid's algorithm and get whole flocks of creatures moving around like this!
That’s a great idea! It should give really interesting results depending on the length of the creatures.
Thank you for the video. I've been trying to figure out inverse kinematics for a long time and you helped a lot.
I was able to reproduce your Processing in Python.
I hope to eventually implement it in Godot and try to add paws to the fish.
You’re welcome. I’m glad it was helpful. Which graphics library do you use with Python? I’ve played with Godot a little bit, but mostly use Unity for game development.
@@programmingchaos8957 I use a mod in the Processing program, it's called "Python Mode for Processing", by Jonathan Feinberg
I should have guessed :) I've used the Python version myself a little bit, but I'm so used to Java in the Processing environment that when I switch languages in Processing I make all sorts of mistakes. It's like I need to use a different IDE for each language so my brain knows what language I'm using.
Amazing! Will work with you soon, for Research in machine Learning Algorithm. Thank you!
I'm glad it was helpful. You're very welcome.
They seem to all look a lot like tadpoles. That's very nice!
Thanks! You're right that there's a strong resemblance to tadpoles. I tried to lean away from the look because it's too easy to get misinterpreted as other large headed swimmy things and I didn't want to get in trouble with the UA-cam algorithm :)
@@programmingchaos8957 Yeah, hopefully the algorithm will be deterred by the eyes and rainbow colors that most of them have.
Thanks for answering man , for the enviroment,
I am going back to get the whole knowledge i can get from this video..
I hope it you get a lot out of it. I was pretty happy with how the creature movement ended up looking.
Thank you this was amazing
I’m really glad you enjoyed it. Happy programming.
going to try to implement this in 3D haha
Great idea! Let me know how it turns out.
This is a great video. I saw that you mentioned working in other languages. You might find better traction on youtube swapping out java for a more popular language/framework. For example, Javascript with p5.js. I'm not super familiar with p5 but I'm sure that it has all of the features needed to recreate this concept with it. This is just one example though. Either way, this was fun to watch.
Thanks for the comment and the suggestion. I've programmed a reasonable amount in Javascript, but haven't taken the time to work with p5.js much. I've been tempted to use C++, but installing it for graphics might be a pain for viewers.
@@programmingchaos8957Which graphics library u intend to use with c++
Nice, but at 26:36, may I suggest a simple: `(TWO_PI + angle % TWO_PI) % TWO_PI;`
Thanks for the reminder. I regularly switch between languages, not all of which have a TWO_PI or use a different convention for formatting constants. So, I find it easier to use 2*PI then to try to remember which form the constant takes. I'm curious if you know if 2*PI would be precomputed when the Java is compiled into byte-code. I couldn't find a definitive answer.
@@programmingchaos8957 As documented it is the number 6.28... and in Java there are no "#define'd constants" only "uppercase variables", so it is at worst a variable fetch. But my point is more the use of the modulo instead of iterating additions/subtractions.
@programmingchaos8957 As documented it is the number 6.28... and in Java there are no "#define'd constants" only "uppercase variables", so it is at worst a variable fetch. But my point is more the use of the modulo instead of iterating additions/subtractions.
Ah, that is a good point. My personal problem is that not all languages handle modulo with decimals (or it's a newer feature). So, in a given language I can't always remember if its valid or not - hence relying on addition/subtraction.
Hello! What sort of procedural techniques would you use to code a sidewinder snake's animation?
That's an excellent question. With the algorithm in the video movement tends to 'dampen out' whereas sidewinders maintain a fairly strong curve over their whole body. Watching some videos of them it looks like maybe all of their body 'segments' move through the same spaces/curves. So, something more like a traditional snake game snake, but with the head moving in sin() wave might be a good starting point. It's also possible that someone has already figured out the algorithm and posted it, but if so, I haven't seen it. If you make any progress on this, I'd love to hear about it.
@@programmingchaos8957 For me it looks like it is stepping with its head, or neck. Based on its trail i can see that there are always two contact points to it with the ground. This reminds me of a cork screw that is rolling with its tip that is like the snake's head region, or rather the neck of it because it keeps its head away from the ground. Also the trail of it looks like the tangent function a littlebit
Good observations. The bit about looking like a corkscrew might be a clue as to how to model it. The whole body shaped roughly like a corkscrew, but with each section progressing through the curve.
@@programmingchaos8957 Humanoid things have their feet on the ground while they are stepping too. I can imagine the place where the snake puts its neck to the first time as a humanoid foot step. Basically the segments must go through that first footprint first, and then towards the neck of the snake. After that spot there is a straight part on which the snake "stands", and then a turn which is the last stationary place of the snake's step. Each snake step consists of two turns, and a straight part, that is two stationary points Everything after that has to go through these stationary points before it can go towards the snake's head, but also only these segments are not touching the ground so these are the suspectible to curve when the snake turns. After that there are going to be two additional points where the snake "stands" with its tail part like a leg behind. These two points are also stationary. So i would place a point where the snake puts its neck not its head first, and then make an additional point at a certain distance from the first, at a certain angle compared to the direction the snake went when its neck step "touched" the ground, and then pull everything through these two points first. I would also make sure that the snake does exactly two steps before it "runs out" by tuning its initial two points' distance, and the snake's length.
for a second I thought this was a follow up from argonaut's video, the creatures are very similar! Was their video an inspiration for this exercise?
I watched several videos, and read a couple of blog posts, before putting this together. But you one of them was argonaut's video - good spotting. Of the techniques I looked at this one seemed the simplest to code.
Good, but too small for a mobile screen.
Thanks! I’d like to make a mobile version, but I don’t see a good way to handle the programming portion.
This was borrowed/stolen from the work published here 4 month ago:
ua-cam.com/video/qlfh_rv6khY/v-deo.html&
Hi. This is a pretty well known technique that's been around for quite a while. I thought having a version that stepped though the programming could be useful for some viewers. To be clear almost none of the algorithms I present (or that are in most UA-cam videos) are completely original. For example, my previous video was on genetic algorithms, which go back at least to John Holland's work in the 1970's. I'm just trying to present algorithms in a way that is helpful to the viewers. I have to say that argonaut's video is very impressive, and possibly does a better job of illustrating the idea than my own - thanks for pointing it out.