- Timestamp:
- 03/17/20 10:43:15 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/core/bounds/AxisAlignedBoxBounds.java
r1258 r1523 5 5 import org.expeditee.core.Line; 6 6 import org.expeditee.core.Point; 7 import org.expeditee.gui.DisplayController;8 7 9 8 /** … … 347 346 } 348 347 } 349 348 349 public Point distanceFrom(AxisAlignedBoxBounds other) { 350 boolean left = other.getMaxX() < this.getMinX(); 351 boolean right = this.getMaxX() < other.getMinX(); 352 boolean top = this.getMaxY() < other.getMinY(); 353 boolean bottom = other.getMaxY() < this.getMinY(); 354 355 if (top && left) { 356 Point thisP = new Point(this.getMinX(), this.getMaxY()); 357 Point otherP = new Point(other.getMaxX(), other.getMinY()); 358 return Point.difference(thisP, otherP); 359 } else if (left && bottom) { 360 Point thisP = new Point(this.getMinX(), this.getMinY()); 361 Point otherP = new Point(other.getMaxX(), other.getMaxY()); 362 return Point.difference(thisP, otherP); 363 } else if (bottom && right) { 364 Point thisP = new Point(this.getMaxX(), this.getMinY()); 365 Point otherP = new Point(other.getMinX(), other.getMaxY()); 366 return Point.difference(thisP, otherP); 367 } else if (right && top) { 368 Point thisP = new Point(this.getMaxX(), this.getMaxY()); 369 Point otherP = new Point(other.getMinX(), other.getMinY()); 370 return Point.difference(thisP, otherP); 371 } else if (left) { 372 return new Point(this.getMinX() - other.getMaxX(), 0); 373 } else if (right) { 374 return new Point(other.getMinX() - this.getMaxX(), 0); 375 } else if (top) { 376 return new Point(0, other.getMinY() - this.getMaxY()); 377 } else if (bottom) { 378 return new Point(0, this.getMinY() - other.getMaxY()); 379 } else { 380 return new Point(0, 0); 381 } 382 } 383 350 384 /** Gets the bounds that is linearly-interpolated between the two given bounds. */ 351 385 public static AxisAlignedBoxBounds lerp(AxisAlignedBoxBounds a, AxisAlignedBoxBounds b, float t)
Note:
See TracChangeset
for help on using the changeset viewer.