Esempio n. 1
0
  /**
   * computes the angle difference between a and b as viewed from center
   *
   * @param center
   * @param a
   * @param b
   * @return angle
   */
  public static double computeObservedAngle(Point2D center, Point2D a, Point2D b) {
    Point2D da = Geometry.diff(a, center);
    Point2D db = Geometry.diff(b, center);
    double angle = Math.abs(Geometry.computeAngle(da) - Geometry.computeAngle(db));
    if (angle > Math.PI) angle = 2 * Math.PI - angle;

    double det = da.getX() * db.getY() - da.getY() * db.getX();

    if (det >= 0) return angle;
    else return -angle;
  }
Esempio n. 2
0
 /**
  * computes the angle difference between a and b as viewed from center
  *
  * @param center
  * @param a
  * @param b
  * @return angle
  */
 public static double basicComputeAngle(Point2D center, Point2D a, Point2D b) {
   Point2D da = Geometry.diff(a, center);
   Point2D db = Geometry.diff(b, center);
   return Geometry.moduloTwoPI(Geometry.computeAngle(db) - Geometry.computeAngle(da));
 }