mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Add Euclidean Distance calculation method from coords
This commit is contained in:
parent
f526f369c4
commit
72ea92ffb3
@ -36,8 +36,13 @@ public class RadiationDetector extends HardwareModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find tiles between two given coordinates.
|
* Finds the tiles between the two tiles located at the given coordinates. The
|
||||||
|
* tiles located at the coordinates are not included in the list.
|
||||||
*
|
*
|
||||||
|
* @param x0 x-coordinate of first point
|
||||||
|
* @param y0 y-coordinate of first point
|
||||||
|
* @param x1 x-coordinate of second point
|
||||||
|
* @param y1 y-coordinate of second point
|
||||||
* @return List of tile coordinates. An empty list indicates tiles are next to
|
* @return List of tile coordinates. An empty list indicates tiles are next to
|
||||||
* each other.
|
* each other.
|
||||||
*/
|
*/
|
||||||
@ -95,6 +100,19 @@ public class RadiationDetector extends HardwareModule {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the Euclidean Distance between two coordinates.
|
||||||
|
*
|
||||||
|
* @param x0 x-coordinate of first point
|
||||||
|
* @param y0 y-coordinate of first point
|
||||||
|
* @param x1 x-coordinate of second point
|
||||||
|
* @param y1 y-coordinate of second point
|
||||||
|
* @return distance between two points
|
||||||
|
*/
|
||||||
|
public double getDistanceOfCoords(int x0, int y0, int x1, int y1) {
|
||||||
|
return Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2));
|
||||||
|
}
|
||||||
|
|
||||||
public RadiationDetector(ControllableUnit unit) {
|
public RadiationDetector(ControllableUnit unit) {
|
||||||
super(null, unit);
|
super(null, unit);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user