Coding Math: Episode 12 - Edge Handling

preview_player
Показать описание
Today we look at four different strategies to use when an object goes off the screen.

Рекомендации по теме
Комментарии
Автор

I actually simulated all these physics in a program I made, including particles bouncing off each other. But I didn't use any Trig at all. I just did the basic math of accelerating the X and Y values appropriately. Knowing the trig makes these calculations so much simpler!

kevnar
Автор

Here is a suggestion for a video: Collisions. For example cover elastic and inelastic collisions and how you'd simulate them in a program. Maybe create some particles and then have them crash together... like in pool. Thanks for the awesome videos!

robl
Автор

"Copy it into floppy disks and send it to Youtube" that's funny haha

habbo
Автор

That joke at the end really got me off. :D

thanatosofthefuture
Автор

Your wrapping version simulates a world that is 2*R larger in both directions than the canvas, a proper wrapping would be where the screen and the world is equal in size. So it looks better if you keep the comparisons on the cent of the circle, but you add more circles whenever the particle is closer than R to an edge, when close to a corner, this would mean drawing 4 circles in each corner of the screen.

alekmoth
Автор


8:10 Would the complicated math be to do the math of the next frame to get the collision before it happens (depending on Mass and Velocity squeeze the object for that collision frame, then continue the reflect/bounce code ?) But I guess this would double the math done on any colision detecting object unless it could be cached.

jim_o
Автор

He said that the bouncing edge effect was not physically accurate. Is that just because in real life there is friction or did he just mean that the location of collision was causing issues (we are only approximating the collision point)? Reversing the x and y velocities when the ball hits its respective edge (assuming we calculate where the actual collision point is) similar to how he mentioned in the video simulates what would happen in a world without friction and where collisions are completely elastic right? Or is there something else that happens in real physics that I am unaware of?

sciboy
Автор

"copy it onto floppy disks and mail it up to youtube" lmao

johnjohnson
Автор

Regarding the regen_extra.js, , does the iteration go like this:

1st - if pushes one particle
2nd - for loop renders the particle
... till the length is met in the if statement ?

Is it hard to code a time frame between each particle ?

Thanks for this great series!

_rkrd
Автор

Oh... as a quick mod to the bouncing ball in episode 3, I made it move side to side, flipped the bottom half of the sine wave, and fixed the edge handling without any of the fun particle stuff, almost identical to the bouncing ball in this video. Accidentally skipped 9 episodes, apparently. Oops!

Proactivity
Автор

it's impossible to follow what you do in this video

eotikurac