mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-12 18:31:41 +01:00
Initial discussion commit
This commit is contained in:
parent
15cfea6f9a
commit
b9114ef5fe
@ -0,0 +1,73 @@
|
||||
package net.minestom.server.utils.incubator;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Coordinate {
|
||||
@NotNull Coordinate with(double x, double y, double z);
|
||||
|
||||
default @NotNull Coordinate with(@NotNull Coordinate coordinate) {
|
||||
return with(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate add(double x, double y, double z) {
|
||||
return with(x() + x, y() + y, z() + z);
|
||||
}
|
||||
|
||||
default @NotNull Coordinate add(@NotNull Coordinate coordinate) {
|
||||
return add(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate sub(double x, double y, double z) {
|
||||
return with(x() - x, y() - y, z() - z);
|
||||
}
|
||||
|
||||
default @NotNull Coordinate sub(@NotNull Coordinate coordinate) {
|
||||
return sub(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate mul(double x, double y, double z) {
|
||||
return with(x() * x, y() * y, z() * z);
|
||||
}
|
||||
|
||||
default @NotNull Coordinate mul(@NotNull Coordinate coordinate) {
|
||||
return mul(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate div(double x, double y, double z) {
|
||||
return with(x() / x, y() / y, z() / z);
|
||||
}
|
||||
|
||||
default @NotNull Coordinate div(@NotNull Coordinate coordinate) {
|
||||
return div(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate neg() {
|
||||
return with(-x(), -y(), -z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate abs() {
|
||||
return with(Math.abs(x()), Math.abs(y()), Math.abs(z()));
|
||||
}
|
||||
|
||||
default @NotNull Coordinate min(double x, double y, double z) {
|
||||
return with(Math.min(x(), x), Math.min(y(), y), Math.min(z(), z));
|
||||
}
|
||||
|
||||
default @NotNull Coordinate min(@NotNull Coordinate coordinate) {
|
||||
return min(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
default @NotNull Coordinate max(double x, double y, double z) {
|
||||
return with(Math.max(x(), x), Math.max(y(), y), Math.max(z(), z));
|
||||
}
|
||||
|
||||
default @NotNull Coordinate max(@NotNull Coordinate coordinate) {
|
||||
return max(coordinate.x(), coordinate.y(), coordinate.z());
|
||||
}
|
||||
|
||||
double x();
|
||||
|
||||
double y();
|
||||
|
||||
double z();
|
||||
}
|
34
src/main/java/net/minestom/server/utils/incubator/Pos.java
Normal file
34
src/main/java/net/minestom/server/utils/incubator/Pos.java
Normal file
@ -0,0 +1,34 @@
|
||||
package net.minestom.server.utils.incubator;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Pos implements Coordinate {
|
||||
|
||||
private final double x, y, z;
|
||||
|
||||
public Pos(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pos with(double x, double y, double z) {
|
||||
return new Pos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user