package ru.dbotthepony.mc.otm.shapes;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public record Point(double x, double y) {
	public Point rotate(double rad) {
		double sin = Math.sin(rad);
		double cos = Math.cos(rad);

		return new Point(x * cos - y * sin, x * sin + y * cos);
	}

	public Point translate(double x, double y) {
		return new Point(this.x + x, this.y + y);
	}

	public int compareTo(Point other) {
		if (x == other.x && y == other.y)
			return 0;

		return 1;
	}

	public double length() {
		return Math.sqrt(x * x + y * y);
	}
}
