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 4 of 4

Thread: Angle between two points

  1. #1
    Junior Member Newbie
    Join Date
    May 2006
    Posts
    1

    Angle between two points

    Hi there.
    Can you help me?

    I got two points(X,Y,Z) A and B in space.

    How can I find the look vector from A to B grom a given moment?

    I mean, at zero frame, "A" got no rotation at all.
    And at frame 10, for example, "B" move 10 units on -X. How can I calculate the angle I have to rotate in "A" to continue viewing the "B" coordinate ?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jul 2003
    Location
    Bangalore, Karnataka, India
    Posts
    123

    Re: Angle between two points

    Dear Guilhereme,

    1. lookAtVector = pointB - pointA
    2. I am not sure But try this
    a. value = ((pointB.x - 10)/lookAtVector.z)
    b. angle = arctan(value);

    Rajesh.R
    IRIS,CAIR,
    Bangalore - 1

  3. #3
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: Angle between two points

    search for 'The Matrix and Quaternions FAQ'
    Q39. How do I generate a rotation matrix to map one vector onto another?

    although How can I find the look vector from A to B grom a given moment?
    is simple A-B perhaps normalize the result

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: Angle between two points

    The vector from A to B is B-A. It's always target minus source

Posting Permissions

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