CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2001
    Posts
    1,029

    given a startPoint, range and bearing, can I calculate the other point?

    I want to calculate the other point in a Cartesian Coordinate system. How can I do that?

    Thanks!
    Last edited by lab1; April 26th, 2011 at 02:49 PM.

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: given a startPoint, range and bearing, can I calculate the other point?

    Could you define the terms a little more ?

    1) By "range", do you mean "distance" ?

    2) by "bearing" , do you mean direction, and if so, what is your input ? An angle ?
    Directional unit vector ?

    3) 2D or 3D ?

  3. #3
    Join Date
    Apr 2001
    Posts
    1,029

    Re: given a startPoint, range and bearing, can I calculate the other point?

    So would this algorithm be correct:

    X2=X1+(cos(angle)*distance)
    Y2=Y1+(sin(angle)*distance)

    Thanks!
    Last edited by lab1; April 26th, 2011 at 02:48 PM.

  4. #4
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: given a startPoint, range and bearing, can I calculate the other point?

    Yes, it is correct.

  5. #5
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Re: given a startPoint, range and bearing, can I calculate the other point?

    There are some widely published equations that will give you what you are looking for... here are the 3D ones

    Code:
    sx = (sin(theta_xz) * r * cos(theta_yz)) + cx
    sy = (r*sin(theta_yz) ) + cy;
    sz = (cos(theta_xz) * r * cos(theta_yz)) + cz
    sx, sy, sz are the coordinates you are trying to calculate. cx, cy, cz are the coordinates you are at, r is euclidean distance (range in your terms). theta_xz is the angle in the xz plane (sweeping from z to x), and theta yz is the angl in the yz plane (sweeping from z to y).

  6. #6
    Join Date
    Apr 2001
    Posts
    1,029

    Re: given a startPoint, range and bearing, can I calculate the other point?

    Thanks!
    Last edited by lab1; April 26th, 2011 at 02:48 PM.

  7. #7
    Join Date
    Apr 2008
    Posts
    118

    Re: given a startPoint, range and bearing, can I calculate the other point?

    I suspect that the problem is you're using degrees as your unit of angle, which is not what the cos function is intended for.

    http://www.cplusplus.com/reference/clibrary/cmath/cos/

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

Featured