Solve Angle C: Is it Between A & B?

In summary, the conversation was about a line of sight algorithm for a roguelike game. The problem was with handling blocking angles between 45 and 225 degrees, as well as between 225 and 45 degrees going the other way. This had to be handled in the same equation for consistency, but the algorithm was having trouble with 0/360 angles. The solution mentioned was to split the problem into two halves, but the person was still searching for a complete solution.
  • #1
Narf the Mouse
11
0
...including cases such as between 45 and 225 degrees and between 225 and 45 degrees going the other way.

Which, for programmatical reasons, must all be handled in the same equation.

It's either that, or I re-work my roguelikes' LOS aglorithm to handle everything in 90 degree increments.

Save me a bunch of re-writing?

Thanks.
 
Mathematics news on Phys.org
  • #2


No idea what you are asking for.

x > 45 and x < 225 does the trick.
 
  • #3


Narf the Mouse said:
...including cases such as between 45 and 225 degrees and between 225 and 45 degrees going the other way.

Which, for programmatical reasons, must all be handled in the same equation.

It's either that, or I re-work my roguelikes' LOS aglorithm to handle everything in 90 degree increments.

Save me a bunch of re-writing?

Thanks.

Please Explain your problem clearly.
 
  • #4


How are you "given" the angle?
 
  • #5


More clearly, it's for a line of sight algorithm for a roguelike. If the algorithm encounters a blocking tile, it generates a blocking angle range - minimum and maximum - produced by said tile. Thereafter, anything which is entirely obscured by said angle - Anything whos corner and middle angles are all inside the blocking angle range - Is naturally not visible.

I also compile all intersecting blocking angles, so as to reduce overhead.

The problem comes with a blocking angle from, say, 45 to 225 or vice-versa, by way of 0/360 instead of 180. That is to say, clockwise from 45 to 225. The algorith tends to think that 45 to 225, counter-clockwise, is blocked.

The conflict comes because the same algorithm must be used for all angles to obtain consistent results.

I've hacked a solution by spitting it into two halves, but I've been unable to find a complete solution on google.
 

FAQ: Solve Angle C: Is it Between A & B?

1. How do you determine if angle C is between angles A and B?

To determine if angle C is between angles A and B, you need to compare the measures of angles A, B, and C. If angle C's measure is greater than angle A's measure and less than angle B's measure, then angle C is between angles A and B.

2. What is the range of values for angle C if it is between angles A and B?

If angle C is between angles A and B, then its measure will be greater than angle A's measure and less than angle B's measure. Therefore, the range of values for angle C will be between the measures of angles A and B.

3. Can angle C be equal to angles A or B and still be between them?

No, if angle C is equal to angle A or angle B, then it is not considered to be between them. In order for angle C to be between angles A and B, its measure must be greater than angle A's measure and less than angle B's measure.

4. What is the importance of knowing if angle C is between angles A and B?

Knowing if angle C is between angles A and B can help in solving geometric problems involving the relationships between angles. It can also help in determining the position of a point relative to two other points, where the angles formed by the three points are angles A, B, and C.

5. Can angle C be outside of angles A and B and still be between them?

No, if angle C is outside of angles A and B, then it is not considered to be between them. In order for angle C to be between angles A and B, its measure must be greater than angle A's measure and less than angle B's measure.

Back
Top