1

I have two vectors forming a specific angle that denotes what is "visible", represented as the blue angle in the following picture.

The red angle represents an "occluding angle" that blocks incoming light.

I need to efficiently calculate the violet angle, which represents the percentage of the visible light against the occluding angle, which creates four possible cases depicted as partially occluded (one or two sides) fully occluded or no occlusion at all.

I've failed to find an efficient algorithm to do this very specific task, considering that the blue angle could be as big a just PI, but the occluding angle may be as much as 2PI, placed anywhere inside the circle

enter image description here

Edit: both angles are specified from 4 normalized vectors, it's not strictly needed to work with angles at all, since I just need to know what percentage of the area/angle between the blue vectors is occluded by the red vectors

Row Rebel
  • 267
  • 3
  • 11
  • Do you only need the value of the angle (or sum of values) or you also need to know how is it rotated? – Jacopo Dec 19 '16 at 16:56
  • Since I just need to know the percentage of visible light that's occluded, knowing only the violet value should suffice. In case of no occlusion it should actually be the blue angle itself – Row Rebel Dec 19 '16 at 16:58

1 Answers1

3

To determine whether angular segments do intersect and intersection type, you can use approach described in my answers here

a1 and a2 are ends of the first sector, b1 and b2 are ends of the second sector, ma and mb are bisectors, da and db are half-angles:

da = (a2 - a1)/ 2  
db = (b2 - b1)/ 2  
ma = (a2 + a1)/ 2  
mb = (b2 + b1)/ 2  
cda = Cos(da)
cdb = Cos(db)

To check whether intersection exists and what kind of intersection takes place, find 4 boolean values

 BStartInsideA = (Cos(ma - b1) >= cda)
 BEndInsideA  =  (Cos(ma - b2) >= cda)
 AStartInsideB = (Cos(mb - a1) >= cdb)
 AEndInsideB =   (Cos(mb - a2) >= cdb)

Linked answer discusses also problems of normalization of weird-defined arcs (perhaps not important for your case) and getting of binary code characterizing intersection type (important - in your case it is excluded interval)

Community
  • 1
  • 1
MBo
  • 77,366
  • 5
  • 53
  • 86