Example #1
0
 /**
  * @param lat1 lat1
  * @param longt1 longt1
  * @param lat2 lat2
  * @param longt2 longt2
  * @return distance of two points
  * @throws Exception
  */
 public static double distance(double lat1, double longt1, double lat2, double longt2)
     throws Exception {
   double x, y, distance;
   x = (longt2 - longt1) * PI * R * Math.cos(((lat1 + lat2) / 2) * PI / 180) / 180;
   y = (lat2 - lat1) * PI * R / 180;
   distance = Math.hypot(x, y) / 1000;
   return Double.valueOf(new DecimalFormat("0.00").format(distance));
 }
Example #2
0
  /// @pre --
  /// @post retorna l'angle que ha d'apuntar la NauEnemiga(e) per aconseguir que un RaigLaser
  // disparat per e
  ///     col·lisioni amb n
  private int angleApuntarMoviment(Nau n) {
    double[] cn = n.obtenirCentreTriangle();
    double[] ce = obtenirCentreTriangle();

    double dist = Math.hypot(Math.abs(cn[0] - ce[0]), Math.abs(cn[1] - ce[1]));
    double temps = dist / velocitatRaig_;
    double[] previsio = preveurePosicio(n, temps);

    double angle = angleApuntar(previsio);
    return (int) angle;
  }
Example #3
0
 private double Edist(Position A, Position B) {
   return Math.hypot(A.getX() - B.getX(), A.getY() - B.getY());
 }