# How to determine Normal Vector of two colliding edges?

1. Sep 27, 2007

### danong

I am writing a physics simulation about the collision and reaction of the Rigid Body.
And now i have problem in determining the normal vector of two colliding edges.

For example,
I have 2 rectangulars ( whether or not it's of same size, anything can happens ),
and under some situations, they rotate and translate.
And finally, they come to contact each other with their edges.
How do i determine their refraction vector / normal vector correspondingly?

Just as shown as below :
/A/\B\

2. Sep 27, 2007

### ice109

just attach a coordinate system to one of the "rectangulars", the line perpendicular to each face is the normal. of course you can do that for each "rectangular" but to talk about them both at the same time is pointless.

if you don't understand what im saying then just imagine that one of them is stationary, that it has a normal perpendicular to each face, and that the other block is approaching it.

hopefully you know how to code that because i don't but i would be interested in seeing your program+source

3. Sep 27, 2007

### danong

but sry, i'm having problem in edge normal not face normal.
or rather it would be vertices versus vertices normal.
hope it's clear =)

4. Sep 27, 2007

### daniel_i_l

For an edge edge collision you find two points, one on the first edge and one on the second one so that the distance between them is minimal (it's easier than it sounds). The vector between those points is the collision normal.
But by the way, how do you check to see if you have an edge-edge collision? When I implemented something like this a while ago I used the SAT (google it) to tell if boxes where colliding. The cool thing is that after checking for collision you can use the collision axis (you'll read about that when you google for SAT) to get the collision normal for free.

5. Sep 27, 2007

### ice109

that is just the line orthogonal to both vertices. i actually just solve this problem recently. but it doesn't make sense to me as far as using it to apply some snell's law of relfection analogue or something

6. Sep 27, 2007

### danong

Yes, u guys are so right, it reminds me of the basic principle of normal vector.
It's the matter of vector of colliding points.
I got a proof from here:
http://www.cescg.org/CESCG-2000/PSovis/index.html

Btw, i found a new interesting & difficulty of implementing this,
that's how to actually find the difference of two colliding points seem they are actually the same exact point.
Well, umm my guess for my own way would be detecting them in a small increment of timer and when they come close enough, for a measurement of about < 0.1 distance, then i assume it's colliding.
Well that's the computing way =/
I'm not dealing with 3D simulation anyway, just my first implementation on rigid,
and i'm writing it on flash as it's just for my trial.
Will post it after i got it implemented and try for a 3d version with c++.
Bravo!

7. Oct 9, 2007

### danong

As promised, i've done my research and had applied it.
http://www.geocities.com/papaonn/RigidBodyDynamic.swf
It's just my first trial and i didn't do a proper accurate collision detection,
so if the simulation get stucked, just simply click reset button to restore it.

Last edited: Oct 9, 2007