Пример #1
0
  public static Polar midpoint(Polar from, Polar to) {
    if (from != null && to != null) {
      Point fromR = from.getRect();
      Point toR = to.getRect();
      int currentX = (fromR.x + toR.x) / 2;
      int currentY = (fromR.y + toR.y) / 2;

      return new Polar(currentX, currentY, 0, 0);
    }
    return null;
  }
Пример #2
0
 public Polar(Polar p) {
   init();
   length = p.length;
   angle = p.angle;
   origin = new Point(p.origin);
   rect = new Point(p.getRect());
 }
Пример #3
0
  public static Polar translate(Polar from, Polar to, int percent) {
    percent = percent < 0 ? 0 : percent;
    percent = percent > 100 ? 100 : percent;

    if (percent == 0) {
      return from;
    } else if (percent == 100) {
      return to;
    } else {
      if (from != null && to != null) {
        Point fromR = from.getRect();
        Point toR = to.getRect();
        int dx = toR.x - fromR.x;
        int dy = toR.y - fromR.y;

        int currentX = fromR.x + ((dx * percent) / 100);
        int currentY = fromR.y + ((dy * percent) / 100);

        return new Polar(currentX, currentY, 0, 0);
      }
    }
    return null;
  }