View Full Version : How to obtain normals?
03-14-2000, 05:01 AM
I've got a simple question (and let's hope the answer will also be simple).
Take 3 vertex that form a triangle.
What's the formula to obtain the normal of this plane? Thanks in advance and sorry for my bad english (i'm from Quebec)...
You can calculate the normal by using cross products.
p1, p2 and p3 is your three points in space.
v1 is a vector from p1 to p2
v2 is a vector from p1 to p3
n is the normal calculated by using crosspruduct, v1 x v2.
v1.x = p2.x - p1.x
v1.y = p2.y - p1.y
v1.z = p2.z - p1.z
v2.x = p3.x - p1.x
v2.y = p3.y - p1.y
v2.z = p3.z - p1.z
n.x = (v1.y * v2.z) - (v2.y * v1.z)
n.y = (v1.z * v2.x) - (v2.z * v1.x)
n.z = (v1.x * v2.y) - (v2.x * v1.y)
You have to be carefull with how you cross the two vectors. If you cross them 'in the wrong order', your normal will be pointing the wrong way. You might have to swap v1 and v2. (v1 x v2) != (v2 x v1)
03-14-2000, 05:43 AM
Thanks! Exactly the kind of answer i was waiting for!
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.