Ignore:
Timestamp:
2016-08-29T18:21:41+02:00 (8 years ago)
Author:
michael2402
Message:

Trim interpolate in EastNorth/LatLon for performance and add comment explaining it. Added unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r10914 r10915  
    427427     */
    428428    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());
    431432    }
    432433
     
    437438     */
    438439    public LatLon getCenter(LatLon ll2) {
     440        // The JIT will inline this for us, it is as fast as the normal /2 approach
    439441        return interpolate(ll2, .5);
    440442    }
Note: See TracChangeset for help on using the changeset viewer.