Points equal but distance is not larger or less?
-
` pt1 = Geom::Point3d.new(-1473.34, -1459.58, 803.961)
pt3 = Geom::Point3d.new(-1473.34, -1459.58, 803.96)pt1 == pt3
truept1.distance(pt3)
0.000999999999976353pt1.distance(pt3) > 0.001
falsept1.distance(pt3) < 0.001
false` -
Ah! Because it was comparing Length classes - which has SU's tolerance builtin.
This works as expected:
pt1.distance(pt3).to_f < 0.001 true pt1.distance(pt3).to_f > 0.001 false
I wanted to compare to point with a higher tolerance than SU's tolerance.
So either I must convert to float - yet another operation, or I do:
pt1.distance(pt3) <= 0.002
-
Sure you know this, but if you're comparing distances rather than interested in the absolute distance, the fastest way will be to project a vector onto itself using scalar product.
p1.dot(p1) < p2.dot(p2)
Adam
Advertisement