And me not even having a firm grasp on the basics of geometry is really biting me in the ass right now.
One of the things I’m making for the brojam this month (wow I just made that name up and it flows really well) is a planet gravity simulator. It’s pretty cool, watching little “comets” fly around “planets”, trying to escape the pull of their gravity. I can make ’em collide, but just making them come to a full stop when they come into contact with a planet is kind of boring. It’d be way cooler if they bounced off, giving them a chance to continue their flight. The collision detection part here is super easy, but it’s the bouncing that gets me.
If the surface they were bouncing off was either completely horizontal or vertical, then making them bounce would be easy. You’d just invert their velocity in whatever direction the object they hit is in. So say a ball bounces off the floor, you just invert its Y-axis, easy as that. Thing is, they’re bouncing off of spheres, which means there’s a theoretically infinite amount of ways to reflect the comets on impact. I thought I figured out an easy way to compute the mutations you’d need to apply to the comet’s velocity, but apparently it doesn’t really work that way.
I found a bunch of good resources on this subject, but they’re all way too abstract for me. I lack proper knowledge on the terminology used, and sometimes they refer to things I know by name, but have no idea how to implement. Since this is more of a learning experience, I don’t want to use an external library for these calculations, but damn, being stuck on the same problem and knowing you can’t solve it because you simply can’t understand the solution is mighty frustrating.
Maybe I should head back to Khan Academy and follow the geometry courses there. Last time I did the pacing was a bit slow for me, but eh, I should probably just force myself to go through that if I want to fully master geometry. Pff.
Well, the final quarter of the school year starts tomorrow. Apparently we’re going to be programming in C#, which should introduce some interesting new stuff Java doesn’t have.