Results 1 to 3 of 3

Thread: How to obtain normals?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2000
    Posts
    5

    How to obtain normals?

    I've got a simple question (and let's hope the answer will also be simple).
    Take 3 vertex that form a triangle.
    Vertex1=(1,1,1)
    Vertex2=(2,2,2)
    Vertex3=(3,3,3)
    What's the formula to obtain the normal of this plane? Thanks in advance and sorry for my bad english (i'm from Quebec)...

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: How to obtain normals?

    Hello

    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)

    Bob

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2000
    Posts
    5

    Re: How to obtain normals?

    Thanks! Exactly the kind of answer i was waiting for!

Similar Threads

  1. How to obtain intersection with a plane
    By Giampaolo Bellini in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-27-2007, 09:12 AM
  2. Is there any way to obtain the data by OpenGL?
    By Rong Yao in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-21-2007, 03:46 PM
  3. Obtain vendor?
    By capedica in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-04-2005, 02:29 AM
  4. Where obtain OpenGl 1.2 (dll, lib, h)?
    By martinzwigl in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-07-2001, 08:47 AM
  5. How do I obtain the projection matrix and the depth value?
    By ZhugeLiang in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-17-2000, 09:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean