Package models.distances

Source Code of models.distances.VisibleDistance

package models.distances;

import models.Coordinates;
import models.coordinates.LocalHorizontalCoordinates;
import models.coordinates.UserCoordinates;
import views.Astre;
import views.SkyMap;
import controllers.Front;

/**
* Euclidian 2D distance visible from the Earth
* @author clement
*
*/

// Useless

public class VisibleDistance extends Distance {

  private static String name = "Visible";
  private static String description = "Distance déterminée par l'angle visible entre deux étoiles depuis la Terre";
  private static final int dimension = 2;
 
  /**
   *
   * @param a
   * @param b
   * @return The visible angle (in rad) between two stars
   */
  @Override
  public double get(Astre a, Astre b) {
    UserCoordinates uc = ((SkyMap) Front.userInterface.getSkyMap()).getUserCoordinates();
    LocalHorizontalCoordinates ac = Coordinates.equatorialToLocalHorizontal(a.getCoodinates(), uc);
    LocalHorizontalCoordinates bc = Coordinates.equatorialToLocalHorizontal(b.getCoodinates(), uc);
//    double x = 2*Math.sin(Math.abs(ac.getHauteur() - bc.getHauteur())/2);
//    double y = 2*Math.sin(Math.abs(ac.getAzimut() - bc.getAzimut())/2);
    double x = Math.abs(ac.getHauteur() - bc.getHauteur());
    double y = Math.abs(ac.getAzimut() - bc.getAzimut());
    double dist = Math.sqrt(x*x + y*y);
//    return Math.asin(dist);
    return dist;
  }

  @Override
  public String getName() {
    return name;
  }

  @Override
  public String getDescription() {
    return description;
  }
 
  @Override
  public int getDimension(){
    return dimension;
  }

}
TOP

Related Classes of models.distances.VisibleDistance

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.