Bud Gidiere 0a77487399
Replace Math with FastMath for improved performance.
FastMath is a drop in replacement for the native Java math class with improved performance and fall backs to the native Java math class if necessary.

https://commons.apache.org/proper/commons-math/javadocs/api-3.3/org/apache/commons/math3/util/FastMath.html

This requires further testing and might cause chunk borders due the FastMath giving slightly different results than the native Java math class.

I also added .idea/Terra.iml to the .gitignore
2020-11-18 17:23:09 -06:00

51 lines
1.1 KiB
Java

package com.dfsek.terra.structure;
import org.apache.commons.math3.util.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
}
}