I am trying to figure out whether the angle is located between two other angles. I am trying to make it a simple task, but any of my techniques will work for all possible values of angles.
Can you help me in determining if an angle is located between 2 other angles? above In the picture; I use the green dot as the central point, then I set the angle of each line at a green dot. I then calculate the angle of the black point at the green dot. I am trying to check that the angle of black dot dissection is angles of 2 lines. Note: in my case; An angle (target angel) is said to lie between 2 other angles if the difference between 2 angles is & lt; The 180 degree and the target angle is located in the cave created by those 2 angles. The following code should work, but it fails for them (who lie between the angles): I did not try any other technique that works:
- is_angle_between (150, 190, 110)
- is_angle_between ( 3, 41, 345) bool is_angle_between (int target, int angle1, int angle2) {int rAngle1 = ((iTarget - iAngle1)% 360 + 360)% 360; Int rAngle2 = ((iAngle2 - iAngle1)% 360 + 360)% 360; Return (0 <= rAngle1 & amp; rAngle1 & lt; = rAngle2); } // example usage_jail_betin (3, 41, 345);
bool is_angle_between (int target, int angle1, int angle2 ) {// Become angle to angle2 from angle1 & lt; = 180 degree int rAngle = (angle2 - angle1)% 360 + 360)% 360; if (rg> = 180) std :: swap (angle1, angle2 ); // Check if it passes zero if return (angle 1 <= angle2) return target> gtle1 & amp; target = l =; angle2; return another target gt; = angle1 || Goal & lt; = angle2;}
Comments
Post a Comment