You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is simple optimization to avoid computing Math.sqrt during finding minimal distance.
Suggested method can be used for example in LineSegment, Triangle, InteriorPointPoint, InterirorPointLine, , LineString::equalsExact(Geometry other, double tolerance)
public double distanceSq(Coordinate c) {
double dx = x - c.x;
double dy = y - c.y;
return dx * dx + dy * dy;
}
public double distance3DSq(Coordinate c) {
double dx = x - c.x;
double dy = y - c.y;
double dz = z - c.z;
return dx * dx + dy * dy + dz * dz;
}
The text was updated successfully, but these errors were encountered:
I didn't make any benchmarks. It's just very simple micro optimization used in games. Computing min distance is O(n). And we can compute Math.sqrt only once.
This is simple optimization to avoid computing Math.sqrt during finding minimal distance.
Suggested method can be used for example in LineSegment, Triangle, InteriorPointPoint, InterirorPointLine, , LineString::equalsExact(Geometry other, double tolerance)
The text was updated successfully, but these errors were encountered: