
Why does the line clipper add a tiddly amount (d) in these expressions?
double d = 0.00001; if (t[0] > 0) ends[0] = new Coord((int) (y0 + t[0] * dy + d), (int) (x0 + t[0] * dx + d));
if (t[1] < 1) ends[1] = new Coord((int)(y0 + t[1] * dy + d), (int) (x0 + t[1] * dx + d));
It for rounding to the nearest map unit. I remember I was just adjusting it until I got something that worked, but can't quite remember what the problem I was solving was.
If I'd thought about it more I would have said that the correct value would be:
360/(2 * 2^24)
which comes to 0.000010728, so perhaps close enough.
Sorry for my answer from yesterday, there is a fault in it. I've thought about it again and think your explanation is wrong. In this case the rounding by 0.0001 makes no sense, as the x and y values are already in internal units, not in degrees. So if you want to round the values, you have to add/subtract 0.5!