Skip to main content
GameDev.net gamedev.net
🔒 Locked

calculating the normal vector?

Started by wazoo69 Oct 17, 2000 at 9:34 AM 6 replies 700+ views
Original Post
wazoo69
wazoo69
Hey all, I''ve gone and totally forgotten how to calculate the normal vector of a plane.. I know that a plane is composed of at LEAST 3 points right?, and I know that the normal vector is perpendicular to the plane....I also know that if the dot-product (or is it cross-product?) is zero then our vector is perpendicular...right? Am I on the right track, or on crack? if anyone could point me in the right direction, I''d REALLY be happy...;0) thanks, Wazoo
Ridcully
Ridcully
it''s really easy. just take the crossproduct of two linear independent vectors that lie in the plane, normalize it, and you got a normal!

to obtain two vectors from three points that are in the plane, do:

v1 = p1 - p2
v2 = p1 - p3

rid
Marlin Rowley
Marlin Rowley
Well, that''s a normal to the plane alright, but that''s not the true normal. Of course, to get the true normal, you''ll have to learn about gradients.


-M
--Marlin R. Rowley - ProgrammerBlue Sky Studios20th Century Fox, http://www.blueskystudios.com
Dave007
Dave007
If you dont know how to do this
so...

void normalizedcross(GLfloat* u, GLfloat* v, GLfloat* n)
{
float l;

n[0] = u[1] * v[2] - u[2] * v[1];
n[1] = u[2] * v[0] - u[0] * v[2];
n[2] = u[0] * v[1] - u[1] * v[0];

l = (GLfloat)sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
n[0] /= l;
n[1] /= l;
n[2] /= l;
}

this is the source I''m using. I hope it will hepl you.

Dave007
dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System
wazoo69
wazoo69
Thanks 007, that''ll help a lot

mmmmmmmm openGL source code...

and Marlin, although gradients sound interesting, I''d have to venture that a "true" normal sounds too intense for my goal of
drawing a couple of bricks to form a wall..

But thanks, Marlin I do appreciate the interest..

happy gaming!! er happy mathing!!

Wazoo



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.