package ru.dbotthepony.mc.otm.shapes;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public record Rectangle(Point a, Point b, Point c, Point d) {
	public Rectangle rotate(double rad) {
		return new Rectangle(a.rotate(rad), b.rotate(rad), c.rotate(rad), d.rotate(rad));
	}

	public Rectangle translate(double x, double y) {
		return new Rectangle(a.translate(x, y), b.translate(x, y), c.translate(x, y), d.translate(x, y));
	}

	public Point min() {
		final double x = MathHelper.min(a.x(), b.x(), c.x(), d.x());
		final double y = MathHelper.min(a.y(), b.y(), c.y(), d.y());

		return new Point(x, y);
	}

	public Point max() {
		final double x = MathHelper.max(a.x(), b.x(), c.x(), d.x());
		final double y = MathHelper.max(a.y(), b.y(), c.y(), d.y());

		return new Point(x, y);
	}
}
