Skip to content

Commit

Permalink
[#819] Geom getDistance of two Point added.
Browse files Browse the repository at this point in the history
  • Loading branch information
DjThunder committed Aug 13, 2024
1 parent 75100ed commit a0e6d1c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lionengine-core/src/main/java/com/b3dgs/lionengine/geom/Geom.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ public static boolean same(Localizable a, Localizable b)
return Double.compare(a.getX(), b.getX()) == 0 && Double.compare(a.getY(), b.getY()) == 0;
}

/**
* Get distance of two points.
*
* @param a The first point (must not be <code>null</code>).
* @param b The second point (must not be <code>null</code>).
* @return The distance between them.
* @throws LionEngineException If invalid argument.
*/
public static double getDistance(Point a, Point b)
{
Check.notNull(a);
Check.notNull(b);

final double x = b.getX() - a.getX();
final double y = b.getY() - a.getY();

return StrictMath.sqrt(x * x + y * y);
}

/**
* Private constructor.
*/
Expand Down

0 comments on commit a0e6d1c

Please sign in to comment.