Changeset 7776 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-12-09T17:59:09+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7509 r7776 824 824 double yC = inv12*b1 + inv22*b2; 825 825 return new EastNorth(xC, yC); 826 }827 828 /**829 * Returns the coordinate of intersection of segment sp1-sp2 and an altitude830 * to it starting at point ap. If the line defined with sp1-sp2 intersects831 * its altitude out of sp1-sp2, null is returned.832 *833 * @param sp1834 * @param sp2835 * @param ap836 * @return Intersection coordinate or null837 */838 public static EastNorth getSegmentAltituteIntersection(EastNorth sp1, EastNorth sp2, EastNorth ap) {839 840 CheckParameterUtil.ensureValidCoordinates(sp1, "sp1");841 CheckParameterUtil.ensureValidCoordinates(sp2, "sp2");842 CheckParameterUtil.ensureValidCoordinates(ap, "ap");843 844 Double segmentLenght = sp1.distance(sp2);845 Double altitudeAngle = getSegmentAngle(sp1, sp2) + Math.PI / 2;846 847 // Taking a random point on the altitude line (angle is known).848 EastNorth ap2 = new EastNorth(ap.east() + 1000849 * Math.cos(altitudeAngle), ap.north() + 1000850 * Math.sin(altitudeAngle));851 852 // Finding the intersection of two lines853 EastNorth resultCandidate = Geometry.getLineLineIntersection(sp1, sp2,854 ap, ap2);855 856 // Filtering result857 if (resultCandidate != null858 && resultCandidate.distance(sp1) * .999 < segmentLenght859 && resultCandidate.distance(sp2) * .999 < segmentLenght) {860 return resultCandidate;861 } else {862 return null;863 }864 826 } 865 827
Note:
See TracChangeset
for help on using the changeset viewer.
