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

Threaded View

  1. #1
    Join Date
    Jan 2012
    Posts
    49

    angle math question

    Hello,

    I have a principle angle system that looks like this:


    Code:
                                 0
                                 |
                                 |
                        -90 ----------- 90
                                 |
                                 |
                               +-180
    given 2 angles angle1 and angle2, I need to write code that will determine if angle2 falls between 135 degrees and -135 degrees away from angle1. Here are some sample values:

    Code:
    angle1    range of angle2 values     
    ------------------------------------
      0              135 to -135           
    90             -135 to -45
    180             -45 to 45
    -90               45 to 135
    Does the following algorithm work in all cases?

    Code:
    int angleDistance = abs(angle1-angle2);
    if(angleDistance >= 135)
        return true;
    else
       return false;
    Thanks!
    Last edited by aseminov; August 17th, 2012 at 10:13 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
  •  





Click Here to Expand Forum to Full Width

Featured