public boolean probablyHasIntersection(final AngleRange p_other) {
if (Float.isNaN(m_center) || Float.isNaN(p_other.m_center)) {
return false;
}
final float l_maxDiff = m_range + p_other.m_range;
final float l_diff = FastMath.abs(GeoMath.getShortestAngleDiff(m_center, p_other.m_center));
return l_diff <= l_maxDiff+ MS_FLOATING_POINT_TOLERANCE;
}
it works in many cases, but fails in a few. anglerange is a direction (like 45 degrees) and a left/right range (45 degrees in my case). i'm trying to check if two ranges overlap each other, but it seems that's not possible. i ran into a case where i two ranges did overlap but the float decided to be not precise enough, so i added + MS_FLOATING_POINT_TOLERANCE - and now i ran into a case where i need high accuracity and + MS_FLOATING_POINT_TOLERANCE causes the method to return true when nothing overlaps. (m_center is the direction)
If that is not enough significant digits then you may have to use a String (or custom) object to hold the entire value (before it gets to a float). Of course you would have to implement the addition of two strings of numbers but then you would only be limited by RAM (and FPS of course). <-- almost perfect solution, just rather brute-forceish (close to how BigDecimal works)
You may also be dealing with floating-point errors there is NO 0.1 in binary, only an approximation (there is no spoon :P). Heres an okay article discussing it