package yi.math;

public class MathTransform2D {
  public static MathPoint2D shift(double x, double y, double shift_x, double shift_y) {
    return new MathPoint2D(x + shift_x, y + shift_y);
  }

  public static MathPoint2D shift(MathPoint2D p, double shift_x, double shift_y) {
    return shift(p.x, p.y, shift_x, shift_y);
  }


  /**
   * Rotate a point: x' = cos(angle) * x - sin(angle) * y;
   * y' = sin(angle) * x + cos(angle) * y;
   * @param x
   * @param y
   * @param angle rotate angle, in radians
   * @return
   */
  public static MathPoint2D rotate(double x, double y, double angle) {
    return new MathPoint2D(
        Math.cos(angle) * x - Math.sin(angle) * y,
        Math.sin(angle) * x + Math.cos(angle) * y
      );
  }

  public static MathPoint2D rotate(MathPoint2D p, double angle) {
    return rotate(p.x, p.y, angle);
  }
}