CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Jan 2012
    Posts
    49

    compass angle prediction question

    Hello,

    In a cartesian coordinate system, I want to be able to predict a compass angle of an object. So I have a base position of (0,0) and then a distance and compass angle to an object. This object also has a heading and a speed. How can I predict the new compass angle of the object with that information?

    my coordinate system is like this:

    Code:
                                           0 y
                                           |
                                           |
                                  270-------------- 90 x
                                           |
                                           |
                                          180

    I think the first step would be to compute the cartesian coordinates of the object:

    float degs_to_rads = 3.141592653589793 / 180.0;
    x = distance * sin(angle*degs_to_rads);
    y = distance * cos(angle*degs_to_rads);

    then the next step would be to compute the predicted x and y from the speed and heading of the object:

    predictedx = ??
    predictedy = ??

    then finally convert back to an angle, and distance:

    newDistance = sqrt(predictedx^2 + predictedy^2);
    newAngle = atan2(predictedy, predictedx);

    Can anyone help me fill in the blanks?? Are my other things correct?

    Thanks!
    Alex
    Last edited by aseminov; April 16th, 2012 at 02:56 PM.

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