/** * Return orientation of line relative to east. * <p> * * @param exact If false the atan gets calculated faster, but it might contain small errors * @return Orientation in interval -pi to +pi where 0 is east */ public double calcOrientation(double lat1, double lon1, double lat2, double lon2, boolean exact) { double shrinkFactor = cos(toRadians((lat1 + lat2) / 2)); if (exact) return Math.atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); else return atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); }
/** * Return orientation of line relative to east. * <p> * * @param exact If false the atan gets calculated faster, but it might contain small errors * @return Orientation in interval -pi to +pi where 0 is east */ public double calcOrientation(double lat1, double lon1, double lat2, double lon2, boolean exact) { double shrinkFactor = cos(toRadians((lat1 + lat2) / 2)); if (exact) return Math.atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); else return atan2(lat2 - lat1, shrinkFactor * (lon2 - lon1)); }