Results 1 to 9 of 9

Thread: How do I generate 2 vectors that are paralell to 1?

  1. #1

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    Arrow How do I generate 2 vectors that are paralell to 1?

    Okay, I need to generate 2 vectors that are perpendicular to each other and one that is already given ie. a normal. I've given it some thought and this is what I came up with: Let's say you have 3 vectors that are perpendicular to each other, a=<1,0,0>, b=<0,1,0>, c=<0,0,1>. Now all you have to do is rotate a to were it equals the normal in question, and rotate b and c to keep them perpendicular. So it all basicaly boils down to this: Find x, y, and z angles and rotate a by that angle so that it faces the same direction as the normal. Also, will someone care to explain 3D rotation using matices to me ?
    Last edited by Cuallito; May 1st, 2001 at 07:56 PM.
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I think you mean perpendicular, not parallel.

    Matrices aren't my strong point, so I'll leave it to someone else.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    A vector is perpendicular to a plane, in which all vectors are parallell. You can use the cross product for any direction. 3d rotation is quite simple if you have a 4x4 or 3x3 matrix. You have an amount of transformation matrices which you multiply with an absolute matrix to give a rotated transformation. i have some links for you:

    http://www.geocities.com/siliconvall.../matrices.html
    http://www.eng.iastate.edu/me516/not...ec20/index.htm
    http://www.manning.com/Lussier/Chapter3.html
    http://www.geocities.com/siliconvall...6/cam_matr.txt
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    Ill make myslef more clear....

    All I need to do is find the 2 vectors that are perpendicular to vector n.
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    you have to be more specific than that, or pick a random vector as a partner for the crossproduct.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    ok

    I mean ALL 3 VECTORS have to be perpendicular to each other.
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    the vectorproduct of them should give you the third vector, all perpendicular to each other.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Lively Member
    Join Date
    May 2000
    Posts
    84
    current vector: u

    For your second vector choose any vector that is not parallel to u.
    This vector will constist of two parts. One parallel to u and one perpendicular to u.

    second vector: v = v1 + v2
    where v1 is the parallel component and v2 is the perpendicular component.

    The parallel component can be found using the following equation (note a period "." will indicate the use of the dot product)

    v1 = [(v.u)/(u.u)] * u

    You can then find the perpendiculat vector

    v2 = v - v1

    The third vector can be found using the cross product between u and v2.

    w = u x v2

    you now have three perpendicual vectors u, v2 and w. For a useful basis simply unitize the vectors (set the length to 1).

    Unit u = u / sqrt(u.u)

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    that's another solution, and yeah i forgot to mention the picked vector should not be parallell to the original
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width