ok I have a problem with rounding errors on floats which I think is
unavoidable. Just as specific background this is happening for me on tests
of vectors (lines) intersecting with bounding boxes (ie oblongs, axis
aligned). Two code snippets shows the core of the maths..
front_n = (x_front - s.X) / v.X
ripY = s.Y + front_n*v.Y
ripZ = s.Z + front_n*v.Z
if (front_n > 0) && (ymin <= ripY && ripY <= ymax) && (zmin <= ripZ && ripZ
<= zmax) {
...
etc
and so on eg :
back_n = (x_back - s.X) / v.X
ripY = s.Y + back_n*v.Y
ripZ = s.Z + back_n*v.Z
if (back_n > 0) && (ymin <= ripY && ripY <= ymax) && (zmin <= ripZ && ripZ
<= zmax) {
...
etc
where xmin, ymin etc represent the boundaries of the box, anything .X , .Y
etc is one component of a 3d vector, and anything suffix _n is a scalar.
All are floats
One of the two boundaries (front or back face) is occasionally skipped ..
The issue occurs obviously (?) when the vector intersects and crosses the
box close to or on and edge/corner are reached. It's rare, and clearly (?)
switching to float64 makes it less rare, but doesn't solve the problem. I
considered multiplying out the divides but that greatly complicates the
boundary conditions, and I don't think it actually solves the problem.. I
think using a 'delta' in the boundaries just kicks the same problem down
the road.
(I've got a simple workaround that doesn't solve the core problem..)
*I think I need to truncate the accuracy of the float to 22 bits* - so the
*question
is really about guard and round bits* etc - we got anything supporting that
in go ? It looked like I would have to use pkg unsafe
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.