This commit is contained in:
drtshock
2014-07-01 15:10:18 -05:00
parent 5066934a95
commit 8a6a97cc90
110 changed files with 3131 additions and 1228 deletions

View File

@@ -26,7 +26,9 @@ public class FLocation {
}
public FLocation(String worldName, int x, int z) {
this.worldName = worldName; this.x = x; this.z = z;
this.worldName = worldName;
this.x = x;
this.z = z;
}
public FLocation(Location location) {
@@ -124,22 +126,31 @@ public class FLocation {
}
public double getDistanceTo(FLocation that) {
double dx = that.x - this.x; double dz = that.z - this.z; return Math.sqrt(dx * dx + dz * dz);
double dx = that.x - this.x;
double dz = that.z - this.z;
return Math.sqrt(dx * dx + dz * dz);
}
//----------------------------------------------//
// Some Geometry
//----------------------------------------------//
public Set<FLocation> getCircle(double radius) {
Set<FLocation> ret = new LinkedHashSet<FLocation>(); if (radius <= 0) { return ret; }
Set<FLocation> ret = new LinkedHashSet<FLocation>();
if (radius <= 0) {
return ret;
}
int xfrom = (int) Math.floor(this.x - radius); int xto = (int) Math.ceil(this.x + radius);
int zfrom = (int) Math.floor(this.z - radius); int zto = (int) Math.ceil(this.z + radius);
int xfrom = (int) Math.floor(this.x - radius);
int xto = (int) Math.ceil(this.x + radius);
int zfrom = (int) Math.floor(this.z - radius);
int zto = (int) Math.ceil(this.z + radius);
for (int x = xfrom; x <= xto; x++) {
for (int z = zfrom; z <= zto; z++) {
FLocation potential = new FLocation(this.worldName, x, z);
if (this.getDistanceTo(potential) <= radius) { ret.add(potential); }
if (this.getDistanceTo(potential) <= radius) {
ret.add(potential);
}
}
}
@@ -170,7 +181,12 @@ public class FLocation {
@Override
public boolean equals(Object obj) {
if (obj == this) { return true; } if (!(obj instanceof FLocation)) { return false; }
if (obj == this) {
return true;
}
if (!(obj instanceof FLocation)) {
return false;
}
FLocation that = (FLocation) obj;
return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName));