예제 #1
0
  public Point2D projectOnAC(Point2D q) {
    Vector2D r = a.sub(c);
    Vector2D s = r.rightNormal();
    double t = ((q.sub(c)).cross(r) / (r.cross(s)));

    return q.add(s.scale(t));
  }
예제 #2
0
  public Point2D projectOnAB(Point2D q) {
    Vector2D r = a.sub(b);
    Vector2D s = r.rightNormal();
    double t = ((q.sub(b)).cross(r) / (r.cross(s)));
    //		System.out.println(t);

    return q.add(s.scale(t));
  }