# Impulse Physics confusion...

This topic is 4205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ello, everyone. So I'm about to start programming a simple (2d) physics example. While I have worked with physics engines before, and know basically what's happening and when, This is my first time programming my own. I'd like to use impulse based physics, and for starters I'm only going to implement spheres. From there I'll add custom convex shapes (defined by a list of points). Most likely I'll use a seperating axis method for my collision detection. So here's my confusion. 1.) Assuming I'm using impulse physics, and all convex shapes, how many collision points would an object have (min, max)? I've seen examples where 2 objects are overlapping, and the collision point is somewhere inside the overlap. I've also seen examples where 2 points are located either both on the overlapping edges, or one inside the overlap and another on the edge. 2.) I just need to learn a lot more about impulse based physics. Anyone?

##### Share on other sites
1) you shouldn't have more than 2 collision points (for when two edges are colliding). However, generating these contact points is usually a pain (unless you're using spheres as you said). What I try to do is for each colliding "point," to have a colliding point on each body. Basically, each contact point will have a point on body 1, a point on body 2, and the collision normal. This makes it so that your impulse calculations are physically correct. Besides, you can always find the midpoint of these two points to get the average contact point for both bodies.

2) An impulse is basically a bunch of force applied over a very short time (the duration of the collision). In physics terminology, it is the integral of the force between the objects over the time that they collide. This is really only a formal definition though, but it is helpful to realize that the units of impulse will be the same as that of momentum (kg*m/s).

Impulse is represented by the symbol J, and it is a vectoral quantity in the direction of the collision normal vector. In order to find the impulse vector, you must find its magnitude, and then multiply that by its direction (the collision normal). You then apply the impulse to each object, negating the second impulse (because it is in the opposite direction).

Chris Hecker does an excellent explanation of this concept (along with equations) at his web page: http://chrishecker.com/Rigid_Body_Dynamics

##### Share on other sites
in 2D, if you use the SAT, there are only two types of collisions.

point-edge
edge-edge

point-edge brings ONE pair of contact points
edge-edge brings TWO pair of contact points

for edge-edge, the calculation of the contact points is relatively easy in 2D. If you draw a small example on paper, it's quite straight forward.

Here is a simple procedure to get bouncing stuff quickly.

1) Perform a SAT test between shapes
2) The SAT test should give you two things
- distance of intersection
- Direction of intersection
3) Using the direction, find the supporting feature on both objects
will give you either an edge, or a point
4) using the supporting features, calculate the contact point
- if you have an edge as a S.F. on A, and an edge as a S.F. on B, then you need
to do some basic 'clipping' to find the portion of the edges that overlap.
- if you have an edge-point, then it's simply projecting the point onto the
other edge.
- point-point should not occur, unless you have a bug. noneless, it's easy
enough to process (the support points are the contact points).
5) since static SAT finds intersections, the objects will apready be intersecting
when a collision is found.
- using the direction and distance of intersection, push the objects apart.
6) Using rigid body dynamics, apply impulses at the contact points.
- Note that if you have a two contact pairs, It should be better to apply them at the same time, not one after the other.
- i.e. accumulate the impulses for each contact pairs and then apply the impulse to change the momentum.

##### Share on other sites
Oliii, do you have your physics examples back online yet?

I'm really missing that source code...

btw, Aressera, Thanks for the link, I've been trying to find that for a while now!

##### Share on other sites
SAT stuff

Physics

Physics is based on Chris Hecker tutorials. just shown in context.

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633756
• Total Posts
3013707
×