- Timestamp:
- 2013-08-21T02:04:20+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/coor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java
r6165 r6166 40 40 41 41 /** 42 * Returns the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}. 43 * 44 * @param coor the specified coordinate to be measured against this {@code Coordinate} 45 * @return the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate} 46 * @since 6166 47 */ 48 protected final double distance(final Coordinate coor) { 49 return distance(coor.x, coor.y); 50 } 51 52 /** 53 * Returns the euclidean distance from this {@code Coordinate} to a specified coordinate. 54 * 55 * @param px the X coordinate of the specified point to be measured against this {@code Coordinate} 56 * @param py the Y coordinate of the specified point to be measured against this {@code Coordinate} 57 * @return the euclidean distance from this {@code Coordinate} to a specified coordinate 58 * @since 6166 59 */ 60 public final double distance(final double px, final double py) { 61 final double dx = this.x-px; 62 final double dy = this.y-py; 63 return Math.sqrt(dx*dx + dy*dy); 64 } 65 66 /** 42 67 * Returns the square of the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}. 43 68 * 44 69 * @param coor the specified coordinate to be measured against this {@code Coordinate} 45 70 * @return the square of the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate} 71 * @since 6166 46 72 */ 47 public double distanceSq(final Coordinate coor) { 48 final double dx = this.x-coor.x; 49 final double dy = this.y-coor.y; 73 protected final double distanceSq(final Coordinate coor) { 74 return distanceSq(coor.x, coor.y); 75 } 76 77 /** 78 * Returns the square of euclidean distance from this {@code Coordinate} to a specified coordinate. 79 * 80 * @param px the X coordinate of the specified point to be measured against this {@code Coordinate} 81 * @param py the Y coordinate of the specified point to be measured against this {@code Coordinate} 82 * @return the square of the euclidean distance from this {@code Coordinate} to a specified coordinate 83 * @since 6166 84 */ 85 public final double distanceSq(final double px, final double py) { 86 final double dx = this.x-px; 87 final double dy = this.y-py; 50 88 return dx*dx + dy*dy; 51 89 } -
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r6165 r6166 45 45 46 46 /** 47 * Counts euclidean distance between this and other EastNorth.47 * Returns the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}. 48 48 * 49 * @param en2 other EastNorth 50 * @return distance between this and other EastNorth 49 * @param en the specified coordinate to be measured against this {@code EastNorth} 50 * @return the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth} 51 * @since 6166 51 52 */ 52 public double distance(final EastNorth en2) { 53 final double dx = this.x-en2.x; 54 final double dy = this.y-en2.y; 55 return Math.sqrt(dx*dx + dy*dy); 53 public double distance(final EastNorth en) { 54 return super.distance(en); 55 } 56 57 /** 58 * Returns the square of the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}. 59 * 60 * @param en the specified coordinate to be measured against this {@code EastNorth} 61 * @return the square of the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth} 62 * @since 6166 63 */ 64 public double distanceSq(final EastNorth en) { 65 return super.distanceSq(en); 56 66 } 57 67 -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r6162 r6166 27 27 */ 28 28 public class LatLon extends Coordinate { 29 30 29 31 30 /** … … 298 297 299 298 /** 300 * Counts euclidean distance between this and other LatLon.299 * Returns the euclidean distance from this {@code LatLon} to a specified {@code LatLon}. 301 300 * 302 * @param ll2 other LatLon 303 * @return distance between this and other LatLon 304 */ 305 public double distance(final LatLon ll2) { 306 final double dx = this.x-ll2.x; 307 final double dy = this.y-ll2.y; 308 return Math.sqrt(dx*dx + dy*dy); 309 } 310 301 * @param ll the specified coordinate to be measured against this {@code LatLon} 302 * @return the euclidean distance from this {@code LatLon} to a specified {@code LatLon} 303 * @since 6166 304 */ 305 public double distance(final LatLon ll) { 306 return super.distance(ll); 307 } 308 309 /** 310 * Returns the square of the euclidean distance from this {@code LatLon} to a specified {@code LatLon}. 311 * 312 * @param ll the specified coordinate to be measured against this {@code LatLon} 313 * @return the square of the euclidean distance from this {@code LatLon} to a specified {@code LatLon} 314 * @since 6166 315 */ 316 public double distanceSq(final LatLon ll) { 317 return super.distanceSq(ll); 318 } 319 311 320 @Override public String toString() { 312 321 return "LatLon[lat="+lat()+",lon="+lon()+"]";
Note:
See TracChangeset
for help on using the changeset viewer.