Calculating a Normal

This is a discussion on Calculating a Normal within the Game Programming forums, part of the General Programming Boards category; I've done a lot of reading about how to find normals, but I just don't quite get it. My understanding ...

  1. #1
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229

    Calculating a Normal

    I've done a lot of reading about how to find normals, but I just don't quite get it. My understanding so far is:

    To find the normal of triangle ABC.
    [a-b]x[b-c]

    I'm not sure how you subtract vectors.
    I'm don't understand how to find a cross product, mostly just because of the math symbols used.

    I just need someone to clarify these things for me.

    Thanks

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    So cross product, given triange a (x1, y1, z1) b (x2, y2, z2) c (x3, y3, z3), you take any two vectors, the edges, which compose it

    Either

    ab and bc
    ac and ab
    ca and cb

    And take the cross product

    So, a, b, and c represent points in space (must be space, or in 2d, z is some constant)

    Cross product of ab and bc for example is ab x bc

    ab = <x2 - x1, y2 - y1, z2 - z1>
    bc = <x2 - x3, y2 - y3, z2 - z3>

    ab x bc = <(y2 - y1)(z2 - z3), (z2 - z1)(y2 - y3), (x2 - x1)(z2 - z3) - (z2 - z1)(x2 - x3), (x2 - x1)(y2 - y3) - (y2 - y1)(x2 - x3)>

    This is my vector class implementing such operations
    http://pokepong.svn.sourceforge.net/...pp?view=markup

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    And vector subtracting for a = b - c is just
    [ ax, ay, az ] = [ bx, by, bz ] - [ cx, cy, cz ] with component-wise subtraction, so the result is
    [ bx - cx, by - cy, bz - cz ]
    Last edited by CornedBee; 10-14-2007 at 06:21 AM. Reason: Messed up my vectors
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Aw, it seems so simple now! Thanks guys
    edit:
    wait..
    ab x bc = <(y2 - y1)(z2 - z3), (z2 - z1)(y2 - y3), (x2 - x1)(z2 - z3) - (z2 - z1)(x2 - x3), (x2 - x1)(y2 - y3) - (y2 - y1)(x2 - x3)>
    was that subtraction I bolded a mistake?
    Last edited by IdioticCreation; 10-14-2007 at 12:03 PM.

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I couldn't see what you posted but I missed a subtraction sign in the first vector components

    ab x bc = <(y2 - y1)(z2 - z3) - (z2 - z1)(y2 - y3), (x2 - x1)(z2 - z3) - (z2 - z1)(x2 - x3), (x2 - x1)(y2 - y3) - (y2 - y1)(x2 - x3)>

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculating : high numbers
    By MiraX33 in forum C++ Programming
    Replies: 9
    Last Post: 06-08-2006, 11:08 PM
  2. inet_aton()... Noob needs help with sockets :|
    By Maz in forum C++ Programming
    Replies: 3
    Last Post: 11-22-2005, 03:33 PM
  3. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 12:00 AM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  5. Taking input while calculating
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 07-12-2002, 04:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21