views:

225

answers:

2

For a 3D game engine I'm working on I need to calculate if two 3D triangles are on the same plane to display it accordingly. How do I calculate the angles of a triangle in 3D space?

Would calculating a surface normal and comparing those ever give me 2 equivalent normals?

+2  A: 

Why do you want to do that? What is the number of triangle you expect to test? It seems a little bit complex for a real time rendering algorithm!

Anyway:

Compute the normal n of the triangle. Then compute the plane equation: a.x + b.y + c.z + d = 0 with (a,b,c) being your triangle normal and d = - dot(n,P) (P is one of your triangle vertex). Do the same for the second triangle.

The two planes are the same if the four valuesabcd are equals or opposite (all together).

tibur
This will be very sensitive to all possible roundoff errors.
Alexandre C.
@Jenko "Send me teh codez" because you're not a math expert? Frankly, if you're writing a 3D engine, you ought to know a little about the math used to create the engine. Otherwise, you're just copying and pasting other's solutions without really knowing if they actually address what you're trying to accomplish.
Michael Todd
If you get frightened by the word *vector* or *matrix*, you should at least read some 3D math tutorials like the following one, or you will never success in writing your 3D engine. http://chortle.ccsu.edu/VectorLessons/vectorIndex.html
tibur
+2  A: 
Alexandre C.
Is that roughly equivalent to a principal component analysis?
tibur
@tibur: it *is* a principal component analysis
Alexandre C.