Пример #1
0
 public void process() {
   if (in instanceof VSDouble) {
     out.setValue(Math.asin(in.getValue()));
     out.setChanged(true);
     element.notifyPin(0);
   }
 }
  /**
   * Converts a point from pixel XY coordinates at a specified level of detail into
   * latitude/longitude WGS-84 coordinates (in degrees)
   *
   * @param pixelX X coordinate in pixels
   * @param pixelY Y coordinate in pixels
   * @param levelOfDetail Level of detail, from 1 (lowest detail) to 23 (highest detail)
   * @return LatLon Geodetic coordinates
   */
  public static LatLon PixelXYToLatLong(int pixelX, int pixelY, int levelOfDetail) {
    double mapSize = (double) calcMapSize(levelOfDetail);

    double x = (pixelX - 0.5) / mapSize;
    double y = (pixelY - 0.5) / mapSize;

    double lon = 360 * x - 180;

    double b = Math.pow(Math.E, -4 * Math.PI * (y - 0.5));
    double sinLatitude = (b - 1) / (1 + b);

    double lat = Math.asin(sinLatitude) * 180 / Math.PI;

    return LatLon.fromDegrees(lat, lon);
  }
Пример #3
0
 /**
  * Compute the view range footprint on the globe.
  *
  * @param dc the current <code>DrawContext</code>
  * @param steps the number of steps.
  * @return an array list of <code>LatLon</code> forming a closed shape.
  */
 protected ArrayList<LatLon> computeViewFootPrint(DrawContext dc, int steps) {
   ArrayList<LatLon> positions = new ArrayList<LatLon>();
   Position eyePos = dc.getView().getEyePosition();
   Angle distance =
       Angle.fromRadians(
           Math.asin(
               dc.getView().getFarClipDistance()
                   / (dc.getGlobe().getRadius() + eyePos.getElevation())));
   if (distance.degrees > 10) {
     double headStep = 360d / steps;
     Angle heading = Angle.ZERO;
     for (int i = 0; i <= steps; i++) {
       LatLon p = LatLon.greatCircleEndPosition(eyePos, heading, distance);
       positions.add(p);
       heading = heading.addDegrees(headStep);
     }
     return positions;
   } else return null;
 }
Пример #4
0
  private static LinkedList<Point2D> getCirclePoints(
      double centerLat, double centerLong, int numberOfPoints, double radius) {

    LinkedList<Point2D> Point2Ds = new LinkedList<Point2D>();

    double lat1, long1;
    double d_rad;
    double delta_pts;
    double radial, lat_rad, dlon_rad, lon_rad;

    // convert coordinates to radians
    lat1 = Math.toRadians(centerLat);
    long1 = Math.toRadians(centerLong);

    // radius is in meters
    d_rad = radius / 6378137;

    // loop through the array and write points
    for (int i = 0; i <= numberOfPoints; i++) {
      delta_pts = 360 / (double) numberOfPoints;
      radial = Math.toRadians((double) i * delta_pts);

      // This algorithm is limited to distances such that dlon < pi/2
      lat_rad =
          Math.asin(
              Math.sin(lat1) * Math.cos(d_rad)
                  + Math.cos(lat1) * Math.sin(d_rad) * Math.cos(radial));
      dlon_rad =
          Math.atan2(
              Math.sin(radial) * Math.sin(d_rad) * Math.cos(lat1),
              Math.cos(d_rad) - Math.sin(lat1) * Math.sin(lat_rad));
      lon_rad = ((long1 + dlon_rad + Math.PI) % (2 * Math.PI)) - Math.PI;

      Point2Ds.add(new Point2D.Double(Math.toDegrees(lat_rad), Math.toDegrees(lon_rad)));
    }
    return Point2Ds;
  }
Пример #5
0
  private int calculate_angle(int rad, int x, int y) {
    /*
    double angle = 0,
         sin_value = Math.asin ((double)y / (double)rad),
         tan_value = Math.atan ((double)y / (double)x);

    if (x >= 0)
         angle = (x !=  0) ? tan_value : sin_value +
         ((y < 0) ? 2*Math.PI : 0);
      else
         angle = Math.PI + tan_value;

         return (int) Math.round (angle * 180.0 / Math.PI);
         */

    double angle = 0.0, sin_value = Math.asin((double) Math.abs(y) / (double) rad);

    if (x >= 0 && y >= 0) angle = sin_value;
    else if (x < 0 && y >= 0) angle = sin_value + Math.PI / 2.0;
    else if (x < 0 && y < 0) angle = sin_value + Math.PI;
    else if (x >= 0 && y < 0) angle = sin_value + 3.0 * Math.PI / 2.0;

    return (int) Math.round(angle * 180.0 / Math.PI);
  }