mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-15 17:44:42 +00:00
Initial 1.7 commit
This commit is contained in:
1 parent
34154fc011
commit
ca675b5f31
72 files changed
+2967
-3335
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package codechicken.lib.render.uv;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
public class UVRotation extends UVTransformation
|
||||
{
|
||||
public double angle;
|
||||
|
||||
/**
|
||||
* @param angle The angle to rotate counterclockwise in radians
|
||||
*/
|
||||
public UVRotation(double angle) {
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(UV uv) {
|
||||
double c = MathHelper.cos(angle);
|
||||
double s = MathHelper.sin(angle);
|
||||
double u2 = c*uv.u + s*uv.v;
|
||||
uv.v = - s*uv.u + c*uv.v;
|
||||
uv.u = u2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UVTransformation inverse() {
|
||||
return new UVRotation(-angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UVTransformation merge(UVTransformation next) {
|
||||
if(next instanceof UVRotation)
|
||||
return new UVRotation(angle+((UVRotation)next).angle);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRedundant() {
|
||||
return MathHelper.between(-1E-5, angle, 1E-5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
MathContext cont = new MathContext(4, RoundingMode.HALF_UP);
|
||||
return "UVRotation(" + new BigDecimal(angle, cont) + ")";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user