Jump to content

  • Log In with Google      Sign In   
  • Create Account

HamiltonLagrange

Member Since 25 Feb 2012
Offline Last Active Sep 23 2012 04:57 PM

#4916862 What do I need to know to make a simple physics engine?

Posted by HamiltonLagrange on 26 February 2012 - 06:37 PM

Say that you have a triangular pixel:
0 (1)


0 (2) 0 (3)

You need to find the normal of the pixel to use in collision detection, to see what angle an object is coming in from. You can create Two Vectors by taking the difference in the coordinates of the vertices:

0 (1)
a ^
/
0 (2) ------> 0 (3)
b

Take the cross product between "a" and "b" to find a normal (there are two of them).
N = a x b --------> Why?

The cross product has an interesting property which you are exploiting: the cross product between two vectors is always perpendicular (orthogonal) to the two source vectors.

Also: N = a x b = |a| |b| sin(x) x is the angle between the two vectors. You can exploit this too. This also means that if two vectors are parallel to each other, their cross product is zero.


Dot Product:

a * b = |a| |b| cos(x) x is still the angle between the two vectors. This means that if "a" and "b" are perpendicular to one another, their cross product is zero.

These are usually the geometric relations you exploit.


You care about Normals when you're dealing with regular kinematics. If you want to figure out how particles reflect or bounce when they hit a surface; you need to know the direction of the normal for the floor, this determines how the particles get deflected.

Something else: I haven't toyed around with this very much... however, it should be possible that instead of doing tradtional collision detection; you could use fields between the floor and the particles. You could design it such that a field is weak at a distance, but when the particles get very close to the source of the field, they interact; and you can have this dictate the physics of the system.

This idea either isn't used because no one has thought of it before... which is unlikely. Or it isn't used because it may be taxing on the poor cpu... which is more likely.

That's the only nugget I'm giving you tonight. You're bright; you'll figure it out. ;)


PARTNERS