Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Gamedev Tutorial: Dot Product, Rulers, and Bouncing Balls (allenchou.net)
213 points by cjcat2266 on Jan 20, 2020 | hide | past | favorite | 13 comments


"The dot product is a simple yet extremely useful mathematical tool. It encodes the relationship between two vectors’ magnitudes and directions into a single value. It is useful for computing projection, reflection, lighting, and so much more."

I wish every programming and math tutorial started with a paragraph like this! So many times I get to the bottom of an article on a concept with an understanding of how to implement it, but no idea why I'd want to!


Game dev is also a fantastic practical application.

I struggled awfully through high school math. Then a decade later I went to go make a space shooter. I learned so much more vector math and trig in like two weekends than all of high school.


To expand further: you can use anything you've ever learned in gamedev. All of it can be useful. From physics, chemistry, biology to languages, trivia, culture etc. But what I find even more fascinating is what players of games can do with just a simple system.


The ball motion formula is less than ideal. Can be much more precise, for very small extra performance cost: https://en.wikipedia.org/wiki/Leapfrog_integration#Algorithm


Semi-implicit Euler as shown in the ball example is pretty common and usually good enough. Leapfrog has other issues with the decoupling of velocity and acceleration. For example adding in the effects of drag or anything else where the acceleration is dependent on velocity.


> and usually good enough

Usually, but for the OP's bouncing balls conservation of energy would be nice.

Another thing, "good enough" is a moving target, both games and the hardware running them improve over time.


I know this is tangential but my fav definition of inner and outer products is

Inner(x,y) = x'.y

And

Outer(x,y) = x. y'

' is adjoint


My favorite is the symmetric and the antisymmetric part of the geometric product.


My favorite is

inner: <bra|ket> outer: |ket><bra|


As a quantum physicist who has drifted into other fields, I keep returning to bra-ket [0] notation when I have to do any linear algebra calculations. Find it to be the most ergonomic notation for linear algebra, especially in product spaces.

In my experience, the key to avoiding snickers from math-types when using bra-kets is to say "dual space" [1] a couple of times.

[0]: https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notation

[1]: https://en.wikipedia.org/wiki/Dual_space


not sure why this was downvoted. QM linear algebra can be quite eye-opening and elegant


This an extremely well-written tutorial! I love it, especially from someone from a weaker math background.


[flagged]





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: