# Normal n of surface to calculate impulse

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

## Recommended Posts

Hi,

I'm trying to use the equation from Wikipedia (http://en.wikipedia....lision_response) to find the impulse of a collision. How do i find the surface normal n, which is a unit vector?

##### Share on other sites
One easy way to get the normal of any 3D surface, is to create two vectors from three points on the surface. When you have the two vectors simply take the cross product of them, and normalize it.

In 2D you'll get the normal by creating a vector from two points (a and b) on the surface. Then find the orthogonal vector and normalize it:
v = (b.x - a.x, b.y - a.y)
ortho = (-v.y, v.x)
n = normalize(ortho)

##### Share on other sites
Ideally, you will use Vertex normals (take a weighted average of the normals of all adjacent triangles sharing the vertex at that point). This is easier to calculate if the surface is on a regular grid. For polygon soup you may not know all of the triangles that share that vertex.

If it is as a parametric surface, the normal at u,v is (basically) the cross product of the vectors: (u,v)->(u+delta,v) and (u,v)->(u,v+delta) where delta is the tolerance, normally based on the surface sample resolution.

But for starters, just use the polygon normal (normalized cross product of two edges of the nearest triangle). Edited by Catmull Dog

##### Share on other sites
I apologize for the late reply.

I am now calculating the normal to the surface by finding the velocity of the contact point and then normalizing that velocity. This does seem to give me the normal for that surface of contact. Is this right?

##### Share on other sites

I am now calculating the normal to the surface by finding the velocity of the contact point and then normalizing that velocity. This does seem to give me the normal for that surface of contact. Is this right?

No. The normal doesn't depend on the velocities etc of the colliding shapes, just their shapes.

Also - you're not looking for the "surface normal" - a property of just on of the contacting surfaces. You need to contact normal, which is a property of both surfaces.

You need to explain in more detail what you're trying to do. Giving a complete answer for the 3D case will be a waste of time and largely irrelevant if you're just concerning yourself with circles in 2D. However, the general result is: the contact normal you're looking for is the direction of the reaction forces in the case of zero friction (yes, that only helps when you know the answer... but by imagining what would happen in the zero friction case you might be able to work out what the normal must be).

For some contacts this is trivial - e.g. for a sphere/circle it will always be in the radial direction. For a contact with a face in 3D (whether a box or part of a triangle mesh etc) it will always be normal to the face. For an edge in 2D it will always be normal to the edge (you can think of a circle being made up of an infinite number of edges).

Basically in 2D, where you only have edges and corners, you need to consider only edge-corner contacts, which are trivial. You can ignore corner-corner contacts, and edge-edge contacts can be converted to two edge-corner contacts.

In 3D you have to deal with faces, edges and corners. Anything contacting a face results in the face's normal. If two edges contact take the cross product of the edges. Ignore corner-corner and corner-edge contacts.

If you already have the shapes penetrating, then a reasonable option is to take the direction that minimises the overlap/penetration distance. Edited by MrRowl

1. 1
2. 2
3. 3
4. 4
frob
14
5. 5

• 16
• 13
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632168
• Total Posts
3004543

×