public String formatRad( String componentFormat ) { return String.format( componentFormat + "," + componentFormat, getLatRad( ), getLonRad( ) ); }
/** * Converts from LatLon to a point on the unit sphere (ECEF-r). * <p> * Deliberately non-static, to allow overriding. */ protected Vector3d latLonToPointOnUnitSphere( LatLonGeo latLon ) { double latRad = latLon.getLatRad( ); double lonRad = latLon.getLonRad( ); Vector3d pointOnUnitSphere = new Vector3d( Math.cos( latRad ) * Math.cos( lonRad ), Math.cos( latRad ) * Math.sin( lonRad ), Math.sin( latRad ) ); return pointOnUnitSphere; }
@Override public Vector2d project( LatLonGeo llg ) { double lonDeg = llg.getLonDeg( ); double latRad = llg.getLatRad( ); double x = ( lonDeg + 180 ) / 360 * zoomFac; double y = ( 1 - Math.log( Math.tan( latRad ) + 1 / Math.cos( latRad ) ) / PI ) / 2 * zoomFac; return new Vector2d( x, y ); }
/** * Computes the great circle distance between the specified points using the * Haversine formula. */ public static double greatCircleDistance( LatLonGeo from, LatLonGeo to, double radius ) { return greatCircleDistance( from.getLatRad( ), from.getLonRad( ), to.getLatRad( ), to.getLonRad( ), radius ); }
/** * Computes the great circle distance between the specified points using the * Haversine formula. */ public static double greatCircleDistance( LatLonGeo from, LatLonGeo to, double radius ) { return greatCircleDistance( from.getLatRad( ), from.getLonRad( ), to.getLatRad( ), to.getLonRad( ), radius ); }
/** * Computes the initial azimuth along the shortest great circle path * connecting the two specified points. * * @param from origin * @param to destination */ public static double greatCircleAzimuth( LatLonGeo from, LatLonGeo to ) { final double lat1 = from.getLatRad( ); final double s1 = Math.sin( lat1 ); final double c1 = Math.cos( lat1 ); final double lat2 = to.getLatRad( ); final double s2 = Math.sin( lat2 ); final double c2 = Math.cos( lat2 ); final double lon1 = from.getLonRad( ); final double lon2 = to.getLonRad( ); final double dLon = lon2 - lon1; final double sdLon = Math.sin( dLon ); final double cdLon = Math.cos( dLon ); final double theta = Math.atan2( sdLon * c2, c1 * s2 - s1 * c2 * cdLon ); return Azimuth.fromNavRad( theta ); }
@Override public Vector2d project( LatLonGeo latLon ) { double lon = latLon.getLonRad( ); double lat = latLon.getLatRad( ); double x = Angle.normalizeAnglePi( lon - originLon ); double y = log( ( sin( lat ) + 1 ) / cos( lat ) ); return new Vector2d( x, y ); }
/** * Computes the initial azimuth along the shortest great circle path * connecting the two specified points. * * @param from origin * @param to destination */ public static double greatCircleAzimuth( LatLonGeo from, LatLonGeo to ) { final double lat1 = from.getLatRad( ); final double s1 = Math.sin( lat1 ); final double c1 = Math.cos( lat1 ); final double lat2 = to.getLatRad( ); final double s2 = Math.sin( lat2 ); final double c2 = Math.cos( lat2 ); final double lon1 = from.getLonRad( ); final double lon2 = to.getLonRad( ); final double dLon = lon2 - lon1; final double sdLon = Math.sin( dLon ); final double cdLon = Math.cos( dLon ); final double theta = fastAtan.atan2( sdLon * c2, c1 * s2 - s1 * c2 * cdLon ); return Azimuth.fromNavRad( theta ); }
/** * Returns a newly constructed <code>LatLonGeo</code> with a * new altitude but same latitude and same longitude as the current * <code>LatLonGeo</code>. * * @param altitude altitude of the newly constructed <code>LatLonGeo</code> */ public LatLonGeo withAltitude( double altitude ) { return new LatLonGeo( getLatRad( ), getLonRad( ), altitude, true ); }
@Override public LatLonRect toLatLonRect( LatLonGeo from ) { return toLatLonRect( from.getLatRad( ), from.getLonRad( ), from.getAltitude( ) ); }
final double lat = from.getLatRad( ); final double cosLat1 = Math.cos( lat ); final double sinLat1 = Math.sin( lat );
public LatLonRect toLatLonRect( LatLonGeo from ) { return SpheroidUtil.toLatLonRect( from.getLatRad( ), from.getLonRad( ), from.getAltitude( ), this ); }
final double lat = from.getLatRad( ); final double cosLat1 = Math.cos( lat ); final double sinLat1 = Math.sin( lat );
/** * Projects a geodetic latitude onto a geocentric latitude * using a ray through the center of the spheroid. See * {@link SpheroidUtil#geodeticToGeocentric(double, double)}. */ public LatLonGeo toGeocentricLatitude( LatLonGeo llg ) { final double latRad = llg.getLatRad( ); final double lonRad = llg.getLonRad( ); final double newLatRad = SpheroidUtil.geodeticToGeocentric( latRad, eccentricitySquared ); return LatLonGeo.fromRad( newLatRad, lonRad, llg.getAltitude( ) ); }
/** * Projects a geocentric latitude onto a geodetic latitude * using a ray through the center of the sphere. See * {@link SpheroidUtil#geocentricToGeodetic(double, double)}. */ public LatLonGeo toGeodeticLatitude( LatLonGeo llg ) { final double latRad = llg.getLatRad( ); final double lonRad = llg.getLonRad( ); final double newLatRad = SpheroidUtil.geocentricToGeodetic( latRad, eccentricitySquared ); return LatLonGeo.fromRad( newLatRad, lonRad, llg.getAltitude( ) ); }
/** * Computes the (east,north,up) representation of an ECEF-r point * given the underlying projection plane's point of tangency. * * @param point ECEF-r point to be transformed to (east,north,up) coordinates * @param refPoint local tangent plane point of tangency * @return (x,y,z) which correspond to (east, north, up) in system units */ public Vector3d toEnu( LatLonRect point, LatLonGeo refPoint ) { LatLonRect refPointRect = refPoint.toLatLonRect( this ); // catastrophic cancellation: cleverness needed to maintain precision final double dx = point.getX( ) - refPointRect.getX( ); final double dy = point.getY( ) - refPointRect.getY( ); final double dz = point.getZ( ) - refPointRect.getZ( ); final double sinLat = Math.sin( refPoint.getLatRad( ) ); final double cosLat = Math.cos( refPoint.getLatRad( ) ); final double sinLon = Math.sin( refPoint.getLonRad( ) ); final double cosLon = Math.cos( refPoint.getLonRad( ) ); final double e = -sinLon * dx + cosLon * dy + 0 * dz; final double n = -sinLat * cosLon * dx - sinLat * sinLon * dy + cosLat * dz; final double u = cosLat * cosLon * dx + cosLat * sinLon * dy + sinLat * dz; return new Vector3d( e, n, u ); }
/** * Computes the ECEF-r representation of the given (east,north,up) * vector given the underlying projection plane's point of tangency. * * @param enuPoint (east,north,up) coordinates of point to be converted, in system units * @param refPoint local tangent plane point of tangency * @return ECEF-r representation of the input (east,north,up) point */ public LatLonRect fromEnu( Vector3d enuPoint, LatLonGeo refPoint ) { final double e = enuPoint.getX( ); final double n = enuPoint.getY( ); final double u = enuPoint.getZ( ); final double sinLat = Math.sin( refPoint.getLatRad( ) ); final double cosLat = Math.cos( refPoint.getLatRad( ) ); final double sinLon = Math.sin( refPoint.getLonRad( ) ); final double cosLon = Math.cos( refPoint.getLonRad( ) ); final double dx = -sinLon * e - cosLon * sinLat * n + cosLon * cosLat * u; final double dy = cosLon * e - sinLon * sinLat * n + sinLon * cosLat * u; final double dz = 0 * e + cosLat * n + sinLat * u; LatLonRect refPointRect = refPoint.toLatLonRect( this ); return LatLonRect.fromXyz( refPointRect.getX( ) + dx, refPointRect.getY( ) + dy, refPointRect.getZ( ) + dz ); }
public LatLonGeo greatCircleShift( DatumSphere sphere, LatLonGeo from, double distance, double azimuth_SU, double[] temp2 ) { this.greatCircleShift( from.getLatRad( ), from.getLonRad( ), distance / sphere.getRadius( ), Azimuth.toNavRad( azimuth_SU ), temp2 ); return LatLonGeo.fromRad( temp2[ 0 ], temp2[ 1 ] ); }