# Calculate angles between two other angles

I am trying to implement a FOV for my light casting algorithm. In the diagram below each white line represents a ray cast from a std::vector<float> of normalized radians. How can I only include angles which lie between the two green lines? (The FOV min and max). • Do you mean how do you filter the vector of ints to be between the two radians values of the fov? – Steven Oct 18 '15 at 18:50
• Yes. Or filter before they are even placed into the vector. – fatnic Oct 18 '15 at 18:53
• What units are the radians in? They are not floats so what are they? What do you mean normalized radians if they are ints – Steven Oct 18 '15 at 18:55
• Sorry. Yes, they are floats. I'll edit my question now. – fatnic Oct 18 '15 at 18:55
• Is there a way of making the first green line 0 then seeing if the angle of the other lines aren't greater than the second green line? – fatnic Oct 18 '15 at 18:56

I found this which works pretty well.

bool angleBetween(float _angle, float _min, float _max)
{
float angle = std::fmod(360 + (rad2deg(_angle)), 360);
float min = std::fmod(3600000 + rad2deg(_min), 360);
float max = std::fmod(3600000 + rad2deg(_max), 360);

if(min < max)
return (min <= angle && angle <= max);

return (min <= angle || angle <= max);
}

• It seems like it would be simpler to compare the radian values instead of converting to degrees first. – shade4159 Oct 19 '15 at 4:59