Solving a Tough Angle Problem: Comparing Cases A and B

  • Thread starter Jake
  • Start date
  • Tags
    Angle
In summary, the conversation discussed a problem involving measuring angles between lines in different cases. The solution proposed was to use inverse tangent or arctan function to calculate the angle between the horizontal and the segment. This angle can then be adjusted based on the signs of dx and dy to determine the "real" angle in the range of 0 to 180 degrees or 0 to -180 degrees. A C program was suggested to experiment with these concepts.
  • #1
Jake
90
0
This is a tough angle problem (For me),

In the diagram below, I have two cases, A and B. In each case, when I sequentially compare the black, blue, and then green lines to the previous line, in each case you end up with the following angles: ~30 and ~30. Yet clearly the spatial relationships of the lines in cases A and B are different!

So how could I measure lines sequentially, so I can build up a relationship of 360 degree angles between the lines?

refering to the image, case A would rightfully measure ~30 degrees then ~330 degrees. case B would measure ~30 and ~30 again.

Hope that made sense.

Thanks!
 

Attachments

  • anglecompare.jpg
    anglecompare.jpg
    2.4 KB · Views: 370
Last edited:
Mathematics news on Phys.org
  • #2
Have you ever thought about using +ive and negative numbers to represent your angles. For example +ive for a counter-clockwise angle and -ive for a clock-wise angle?
 
  • #3
It might be useful to measure the angle of each next segment with respect of the prolongation of the previous; in the attached image, the green line would be measure against the dotted line. An angle of 0 would represent the next segment continuing in exactly the same direction; a positive angle would be a left (counter-clockwise) turn, negative angles for right (clockwise). This is useful if you want to accumulate the total change of orientation as the line progresses: you would only need to sum the angles.
 

Attachments

  • line.jpg
    line.jpg
    1 KB · Views: 401
  • #4
Uart and Dodo, both your insights are correct, I need to compare which "side" the new line is on relative to the old one. However, the current problem is I have no way of deciding which side is the one which will measure greater than 180 degrees, and which one less, based on what the previous angle measurement was. I just don't know how to mathematically relate a side of a line to either the >180 or <180 degrees.

Thanks again :)
 
  • #5
Exactly what data do you have? The coordinates of the endpoints of the segments, for example?
 
  • #6
Yep Dodo, a sequential list of all points, including knowing what the 'first' and 'last' points are. Each point is both the beginning and end of a 'line' (unless its the first or last point of course)
 
Last edited:
  • #7
Then you have everything you need.

Most calculators (or programming languages in a computer) will have an inverse tangent, tan^-1, or arctan, function. Let P and Q be the endpoints of some segment; and let dx = Qx-Px, and dy = Qy-Py. Then, in theory, arctan(dy/dx) gives you the angle between that segment and the horizontal, possibly in the range -90...+90.

In practice, you would use the signs of dx and dy to complete your choice of angle. In practice, you would avoid vertical segments (where dx=0), to avoid a zero division. You can accomplish both things by using the following trick: choose the maximum of |dx| and |dy| (where |dx| means the absolute value of dx, the magnitude of dx without considering the sign), and calculate the arctan(dy/dx) if |dx| is bigger, or arctan(dx/dy) if |dy| is bigger. Then transform the angle you get into the "real" one, according to the choice you made, and according to the signs of dx and dy. This "real" angle is usually chosen positive from 0 to 180 (the region above the X axis), or negative from 0 to -180.

There are 8 possible cases you have to consider (dx positive or negative, dy positive or negative, |dx| bigger or smaller than |dy|) which correspond to the 8 octants of the whole circle (the 8 pieces of the circle in 45-degrees steps). Give some thought to what happens on each of the 8 cases, and come back with more question at whichever point you get stuck, if at all.

Here is an example: for points P=(105, 106) and Q=(108, 102), you have dx = 3, dy = -4. Now, since the absolute value of -4 (which is 4) is greater than the absolute value of 3 (which is the same 3), we choose to calculate the angle arctan(dx/dy) = arctan(3/-4) = -36.87 degrees (aprox.). Since your choice was to invert dx and dy (and divide by dy, when the "theoretical" formula divided by dx instead), you are really calculating, loosely speaking, the angle with respect to the vertical (you have to imagine interchanging the x and y axis). I have attached a picture; there you can see the -36.87 angle, and the final, "real" angle which in this case is -90 + 36.87 = -53.13 degrees (I hope the picture illustrates why). Minus 53.13, because it is under the X axis.

Of course, once you have a (signed) angle for each individual segment, a simple subtraction will give you the relative, signed angle differences.
 

Attachments

  • angle.jpg
    angle.jpg
    3.6 KB · Views: 341
Last edited:
  • #8
Alright, I think that sounds like it will work. However, being a self-taught computer science and non-math guy, I can't conceptually understand everything you said :biggrin: I understand enough to implement it in software (C++) however, except for this one aspect:

Then transform the angle you get into the "real" one, according to the choice you made, and according to the signs of dx and dy. This "real" angle is usually chosen positive from 0 to 180 (the region above the X axis), or negative from 0 to -180.

I hope I can pick your brain to understand this last bit. When you say the "according to the choice you made", are you referring to choosing to divide by dx or dy, this is automatic isn't it, based on just which one is bigger (in absolute terms)? If not, how do I make this choice? Secondly you also said "and according to the signs of dx and dy"; how do I do this deciding based on the signs of dx or dy, in order to further decide the "real" angle, in terms of +/-180 degrees?

In any case, I greatly appreciate all help rendered up to this point :)
 
  • #9
Well, I know you need help, but I really didn't want to do all the work myself. I propose the following experiment:

Write a C program that accepts two floating-point values, a, b, and calculates the value of 180 * atan(a/b) / M_PI, where M_PI is the 'pi' constant (3.14159...) that you get for free when you #include <math.h>. The purpose of multiplying by 180 and dividing by pi is, of course, to convert the value returned by atan, from radians to degrees.

Now, the red dots in the attached picture are possible values of dx, dy. Try running your program, choosing (by hand) a=dx and b=dy when dy is bigger in absolute value, and a=dy, b=dx on the contrary. Get sure to try dx, dy values on each of the 8 octants, which I have drawn for your ease of use. You can start with the big red dot in the picture, which corresponds to the example at the bottom of my previous post.

In each case, you'll notice that you get angles with respect to the horizontal (green) X axis when dividing by dx, and angles with respect to the vertical (red) Y axis when dividing by dy. And your final goal is to pick a formula (typically, one of 90 + angle, -90 - angle, 180 + angle, of just the angle) that converts, for each of the 8 cases, from the output of the program to the angle you want (I suggest You Want an angle with respect to the right half of the X axis, as in the picture of the previous post).

Please try the above, and let me know if/when you have further problems.
 

Attachments

  • axes.gif
    axes.gif
    834 bytes · Views: 435

1. How do you determine the correct angle in a tough angle problem?

The correct angle in a tough angle problem can be determined by using mathematical principles such as the Law of Sines or the Law of Cosines. These principles can help you find missing angles or sides in a triangle, which can then be used to solve the tough angle problem.

2. What is the difference between Case A and Case B in a tough angle problem?

Case A and Case B refer to different scenarios in a tough angle problem. In Case A, you may have all the necessary information to solve the problem, while in Case B, you may have some missing information that requires a different approach to solve the problem.

3. Can I use trigonometry to solve a tough angle problem?

Yes, trigonometry can be used to solve tough angle problems. Trigonometric functions such as sine, cosine, and tangent can be used to find missing angles or sides in a triangle, making it a useful tool in solving tough angle problems.

4. What are some common mistakes to avoid when solving a tough angle problem?

Some common mistakes to avoid when solving a tough angle problem include misapplying mathematical principles, not carefully reading the problem, and not double-checking your calculations. It is important to approach the problem systematically and check your work to ensure accuracy.

5. How can I practice and improve my skills in solving tough angle problems?

The best way to practice and improve your skills in solving tough angle problems is to do practice problems and worksheets. You can also seek help from a tutor or join a study group to gain a better understanding of the concepts and techniques involved in solving these problems.

Similar threads

Replies
7
Views
969
Replies
1
Views
1K
  • General Math
Replies
1
Views
1K
  • General Math
Replies
6
Views
3K
Replies
3
Views
569
Replies
30
Views
7K
Replies
4
Views
2K
  • General Math
Replies
4
Views
2K
Replies
1
Views
1K
  • Poll
  • General Math
Replies
1
Views
2K
Back
Top