Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: A perpendicular to a vector

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    France
    Posts
    10

    A perpendicular to a vector

    Hi,
    I'm having a problem with skeleton bones. I would like to find a perpendicular to a bone.
    Since I only have 2 points (pivot point and end point) what is the correct method to get a perpendicular (starting from pivot point in any direction).
    I thought I could use a cross product to get a normal (which is perpendicular) but for this I need a third point, and I don't see which.
    Or is there any other way ?
    Thanks,
    Yarp

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    317

    Re: A perpendicular to a vector

    In 3D it is not possible to construct perpendicular vector to other vector. There is too much of them (unlimited). Only perpendicular plane exists in 3D.

    In 2D, the p. vector is [y, -x]

  3. #3
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: A perpendicular to a vector

    If you need that for visualisation purposes, then your best bes is eye vector.

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2003
    Location
    New York
    Posts
    194

    Re: A perpendicular to a vector

    Yarp, mfort is correct that the set of all perpendicular vectors to a given input vector forms a uniform perpendicular disc, not a single vector.

    But your case is special. In the case of bones, you generally have a parent bone and a child bone. You can simply take the cross product of the parent bone vector and the child bone vector to produce one vector that is perpendicular to both. This will essentially be the axis of rotation for that joint, or at least the axis of rotation to go from one vector to the other. And if you know that axis ahead of time, then you're done.

    If you want to find the "normal" of this joint, one way would be to cross that axis vector with each of the two bone direction vectors and average the two results.

    Or, just crossing the axis with the child bone gives you that bone's most "visually appealing" perpendicular vector.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    France
    Posts
    10

    Re: A perpendicular to a vector

    Thank you all for your quick answer. Sure I understand there is not a single perpendicular to a vector. So is there a way to construct that disc from which I could extract 1 single vector ?

    Cyranose, your idea is good but the problem with Bones is that they sometimes have the same alignement (take a snake for example) in which case this won't work.

    My purpose is to generate a mesh around that skeleton in order to visualize it.

  6. #6
    Senior Member Regular Contributor
    Join Date
    May 2003
    Location
    New York
    Posts
    194

    Re: A perpendicular to a vector

    You can check the magnitude of the cross product in the method I suggested. If it's too small, the bones are close to parallel. In that case, or in general, you can use what I _think_ k_szczech meant, which is to cross the eye vector (or the up vector, if you want) with the bone direction to produce a single vector perpendicular to both.

    BTW, that disc can be treated as if it was a plane with a finite boundary at r = 1 from the bone's position. The disc has a normal, just as a plane would. Basic planar math applies with the boundary in mind.

  7. #7
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: A perpendicular to a vector

    cross the eye vector (or the up vector, if you want)
    No, not the "up" vector. I meant the "forward" vector of camera. This will produce one axis, and vector perpendicular to this axis and the bone will produce another axis. Third axis is the bone itself.
    Now you can transform any geometry into this bone's space. Note that this geometry will rotate around bone depending on camera view. If it's a cylinder it's no problem.
    Or you could just skip second axis and render symbol of bone (an arrow for example) in 2D.

    If you want some more fancy geometry then you should build transformation matrices for every bone (I assume your bones are organized as a tree).

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    France
    Posts
    10

    Re: A perpendicular to a vector

    Yes, I was thinking to the last solution you suggest (using transformation matrix). Since I cannot make sure all skeletons will face the camera I think it is safer.

    Thank so much for your explanations, it helped me a lot see what I have to do.

  9. #9
    Senior Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: A perpendicular to a vector

    I just want to add that in computer animation you often directly define a perpendicular vector in the form of a rotation axis.
    You even directly use alignment nodes to make sure things like knees point in the right way.

  10. #10
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    France
    Posts
    10

    Re: A perpendicular to a vector

    Yes, that's what I did in the end.
    I compute the angle between a bone and the X, Y and Z axis. The one with the smaller angle gives the rotation axis, the one with the larger is the perpendicular axis. So I just rotate around 1 axis, it is simple and works fine.

    btw What are alignment nodes ?

Page 1 of 2 12 LastLast

Similar Threads

  1. Finding a Perpendicular Vector
    By PickleWorld in forum OpenGL: GLSL
    Replies: 6
    Last Post: 09-01-2009, 03:16 PM
  2. point perpendicular to a vector question
    By brett01 in forum OpenGL: General
    Replies: 1
    Last Post: 08-13-2009, 07:40 PM
  3. Perpendicular Polygons
    By orendavd in forum OpenGL: General
    Replies: 5
    Last Post: 03-06-2008, 06:51 AM
  4. calculating a plane perpendicular to the view vector
    By trout in forum OpenGL: General
    Replies: 2
    Last Post: 08-12-2004, 11:31 AM
  5. Perpendicular
    By Gelero in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 08-31-2001, 09:39 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