Uses of distanceSq may be giving unexpected results
BlueAgent opened this issue ยท 0 comments
Vector3i#distanceSq(Vector3i other)
actually gets the squared distance between this + (0.5, 0.5, 0.5)
and other
.
This is because it uses Vector3i#distanceSq(double x, double y, double z, boolean useCenter)
but calls it with useCenter = true
.
Was going to PR this but it turns out that the method is used in many places including one section in ObserverLib and I wasn't 100% sure of the side effects of such a change so I decided to open this issue instead.
The distance calculation is not consistent both ways and is actually not what we're expecting (I think).
Example:
A = (0, 0, 0)
B = (1, 0, 0)
A.distanceSq(B) == 0.75 (expected 1)
B.distanceSq(A) == 2.75 (expected 1)
Maybe to fix this, either a helper function for Vector3i
(which BlockPos extends from), or using Vector3i#distanceSq(double x, double y, double z, boolean useCenter)
with useCenter = false
.
Video Demonstration of the issue (it's printing the distance instead of distanceSq though).