Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Direction and vector

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    110

    Direction and vector

    hello.
    I'm a beginner.
    How i can calculate the direction vector if I have two point A and B?
    I'm in a tree dimensional space with opengl then A={1,1,0} and B={2,2,1} for example.
    Is sufficent do B - A ? or is different A - B?
    The direction is a 3d vector?
    Thanks.

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171

    Re: Direction and vector

    To obtain a direction, calculate A-B, then normalise the result.
    The sign(s) of the resultant direction vector is really telling you if your direction is A-->B or B-->A.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Direction and vector

    It depends if you go from A to B or from B to A

    A to B is B-A

    Depending on the case, direction vector must be normalized, but not sure it applies to your case.

Posting Permissions

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