- Timestamp:
- 2016-08-29T18:21:41+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/coor
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r10378 r10915 82 82 */ 83 83 public EastNorth interpolate(EastNorth en2, double proportion) { 84 return new EastNorth(this.x + proportion * (en2.x - this.x), 85 this.y + proportion * (en2.y - this.y)); 84 // this is an alternate form of this.x + proportion * (en2.x - this.x) that is slightly faster 85 return new EastNorth((1 - proportion) * this.x + proportion * en2.x, 86 (1 - proportion) * this.y + proportion * en2.y); 86 87 } 87 88 … … 92 93 */ 93 94 public EastNorth getCenter(EastNorth en2) { 94 return new EastNorth((this.x + en2.x)/2.0, (this.y + en2.y)/2.0); 95 // The JIT will inline this for us, it is as fast as the normal /2 approach 96 return interpolate(en2, .5); 95 97 } 96 98 -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r10914 r10915 427 427 */ 428 428 public LatLon interpolate(LatLon ll2, double proportion) { 429 return new LatLon(this.lat() + proportion * (ll2.lat() - this.lat()), 430 this.lon() + proportion * (ll2.lon() - this.lon())); 429 // this is an alternate form of this.lat() + proportion * (ll2.lat() - this.lat()) that is slightly faster 430 return new LatLon((1 - proportion) * this.lat() + proportion * ll2.lat(), 431 (1 - proportion) * this.lon() + proportion * ll2.lon()); 431 432 } 432 433 … … 437 438 */ 438 439 public LatLon getCenter(LatLon ll2) { 440 // The JIT will inline this for us, it is as fast as the normal /2 approach 439 441 return interpolate(ll2, .5); 440 442 }
Note:
See TracChangeset
for help on using the changeset viewer.