My dad and my physics teacher have (independently) advised me, as a CS major, to minor or double-major, in physics.
Do you think this will really help me get ahead? I want to end up doing something with computer/video games, not writing scientific software, so I think basic general college physics (required for CS major already) is enough.
Name:
Anonymous2007-05-25 5:53 ID:Q9GrRFe8
Implementing physics in programs is fuck easy. Let me illustrate:
Each object has an x, y, and z coordinate. Per frame it exists in a particular x,y,z coordinate. To model forces acting on that object, we need two attributes for each coordinate: current velocity (v), and change in velocity per frame aka acceleration (a).
For each frame, using x as an example, do this:
x.v = x.v + x.a
x = x + x.v
When forces act on an object, you have to modify a and v accordingly. Velocites are reduced by division, and directions are reversed by a sign change. So, say object A and B collide, you can model that like this:
A.[coordinate].v = - (A.[coordinate].v / 1.5)
and same for B
You might want to divide by a factor dependent on the objects weight or mass, so you could define that as well, a w or whatever.
Gravity is easy too. Just do something like this per frame
[object].y.v = [object].y.v + .05
for .05 substitue a weight factored value or other value that works depending on the types of objects