mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-14 04:41:13 +00:00
Look ma, no Bukkit API in the core package
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.dfsek.terra.structure;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public enum Rotation {
|
||||
|
||||
CW_90(90), CW_180(180), CCW_90(270), NONE(0);
|
||||
private final int degrees;
|
||||
|
||||
Rotation(int degrees) {
|
||||
this.degrees = degrees;
|
||||
}
|
||||
|
||||
public static Rotation fromDegrees(int deg) {
|
||||
switch(FastMath.floorMod(deg, 360)) {
|
||||
case 0:
|
||||
return Rotation.NONE;
|
||||
case 90:
|
||||
return Rotation.CW_90;
|
||||
case 180:
|
||||
return Rotation.CW_180;
|
||||
case 270:
|
||||
return Rotation.CCW_90;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public int getDegrees() {
|
||||
return degrees;
|
||||
}
|
||||
|
||||
public Rotation inverse() {
|
||||
switch(this) {
|
||||
case NONE:
|
||||
return NONE;
|
||||
case CCW_90:
|
||||
return CW_90;
|
||||
case CW_90:
|
||||
return CCW_90;
|
||||
case CW_180:
|
||||
return CW_180;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Axis {
|
||||
X, Y, Z
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user