Changeset 1076 in josm for trunk/src/org/openstreetmap/josm/data/coor
- Timestamp:
- 2008-11-13T19:41:48+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r655 r1076 28 28 29 29 public EastNorth interpolate(EastNorth en2, double proportion) { 30 return new EastNorth(this.x + proportion * (en2.x - this.x),this.y + proportion * (en2.y - this.y)); 30 return new EastNorth(this.x + proportion * (en2.x - this.x), 31 this.y + proportion * (en2.y - this.y)); 31 32 } 33 34 /** 35 * Returns the heading, in radians, that you have to use to get from 36 * this EastNorth to another. Heading is mapped into [0, 2pi) 37 * 38 * @param other the "destination" position 39 * @return heading 40 */ 41 public double heading(EastNorth other) { 42 double hd = Math.atan2(other.east() - east(), other.north() - north()); 43 if(hd < 0) hd = 2 * Math.PI + hd; 44 return hd; 45 } 46 47 public EastNorth sub(EastNorth en) { 48 return new EastNorth(en.east() - east(), en.north() - north()); 49 } 50 51 /** 52 * Returns an EastNorth representing the this EastNorth rotatedaround 53 * a given EastNorth by a given angle 54 * @param pivot the center of the rotation 55 * @param angle the angle of the rotation 56 * @return EastNorth rotated object 57 */ 58 public EastNorth rotate(EastNorth pivot, double angle) { 59 double cosPhi = Math.cos(angle); 60 double sinPhi = Math.sin(angle); 61 double x = east() - pivot.east(); 62 double y = north() - pivot.north(); 63 double nx = cosPhi * x + sinPhi * y + pivot.east(); 64 double ny = -sinPhi * x + cosPhi * y + pivot.north(); 65 return new EastNorth(nx, ny); 66 } 32 67 33 68 @Override public String toString() { 34 69 return "EastNorth[e="+x+", n="+y+"]"; 35 70 } 71 72 /** 73 * Compares two EastNorth values 74 * 75 * @return true if "x" and "y" values are within 1E-6 of each other 76 */ 77 public boolean equalsEpsilon(EastNorth other, double e) { 78 return (Math.abs(x - other.x) < e && Math.abs(y - other.y) < e); 79 } 36 80 }
Note: See TracChangeset
for help on using the changeset viewer.