(I)TraceEntry: Add convenience method isInside for coordinates.

This commit is contained in:
asofold 2018-06-24 10:48:48 +02:00
parent 481d2c060f
commit 85bb769b73
1 changed files with 21 additions and 1 deletions

View File

@ -52,6 +52,16 @@ public class LocationTrace {
public long getTime();
/**
* Convenience method.
*
* @param x
* @param y
* @param z
* @return
*/
public boolean isInside(double x, double y, double z);
}
public static class TraceEntry implements ITraceEntry {
@ -60,7 +70,10 @@ public class LocationTrace {
/** We keep it open, if ticks or ms are used. */
private long time;
/** Coordinates. */
/**
* Coordinates, box bottom center position with margins to the sides and
* to top.
*/
private double x, y, z, boxMarginHorizontal, boxMarginVertical;
/** Older/next. */
@ -114,6 +127,13 @@ public class LocationTrace {
return time;
}
@Override
public boolean isInside(final double x, final double y, final double z) {
return y >= this.y && y <= this.y + this.boxMarginVertical
&& Math.abs(x - this.x) <= this.boxMarginHorizontal
&& Math.abs(z - this.z) <= this.boxMarginHorizontal;
}
}
public static final class TraceEntryPool extends AbstractPool<TraceEntry> {