5.Over-constrained Code (1)§
Consider the situation where we have two points. We want to know which quadrant the second point (b) is in w.r.t. the first point (a):
if ((b.x < a.x) && (b.y < a.y)) doNW(); else if ((b.x < a.x) && (b.y >= a.y)) doSW(); else if ((b.x >= a.x) && (b.y < a.y)) doNE(); else if ((b.x >= a.x) && (b.y >= a.y)) doSE();
This has the virtue of being quite logical and clear. However, it has some problems.