Solve Angle C: Is it Between A & B?

  • Context: Undergrad 
  • Thread starter Thread starter Narf the Mouse
  • Start date Start date
  • Tags Tags
    Angle Mathematical
Click For Summary

Discussion Overview

The discussion revolves around solving the problem of determining whether an angle C lies between two other angles A and B, specifically in the context of a line of sight algorithm for a roguelike game. The focus is on handling angles that span across the 0/360-degree boundary and ensuring consistent results in the algorithm.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes the need to handle angle ranges such as between 45 and 225 degrees and vice versa in a single equation for programmatic efficiency.
  • Another participant suggests a simple condition of x > 45 and x < 225 as a potential solution, though this may not address the full complexity of the problem.
  • A participant elaborates on the algorithm's function, explaining how it generates blocking angle ranges based on encountered tiles and how it determines visibility based on these ranges.
  • The issue arises when the algorithm misinterprets the blocking angle when it crosses the 0/360-degree threshold, leading to incorrect visibility determinations.
  • One participant mentions a temporary solution that divides the problem into two halves but expresses difficulty in finding a comprehensive solution online.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on a definitive solution to the problem. There are multiple approaches suggested, but the discussion remains unresolved regarding the best method to handle the angle calculations.

Contextual Notes

The discussion highlights limitations in the current algorithm's handling of angles, particularly concerning the treatment of angles that wrap around the 0/360-degree point. There may be unresolved mathematical steps in determining the correct visibility based on blocking angles.

Narf the Mouse
Messages
11
Reaction score
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


No idea what you are asking for.

x > 45 and x < 225 does the trick.
 


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.
 


How are you "given" the angle?
 


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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
5
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
Replies
2
Views
3K
Replies
3
Views
2K
  • · Replies 31 ·
2
Replies
31
Views
4K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K