From 48f781fb6e61539ba9d17efcfd9f9e38245cf6c0 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 23 May 2018 16:42:38 -0400 Subject: Refactor package structure --- CSMath/src/bezier/geom/transform/TDHRotation.java | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 CSMath/src/bezier/geom/transform/TDHRotation.java (limited to 'CSMath/src/bezier/geom/transform/TDHRotation.java') diff --git a/CSMath/src/bezier/geom/transform/TDHRotation.java b/CSMath/src/bezier/geom/transform/TDHRotation.java new file mode 100644 index 0000000..a8c4cd6 --- /dev/null +++ b/CSMath/src/bezier/geom/transform/TDHRotation.java @@ -0,0 +1,57 @@ +package bezier.geom.transform; + +import bezier.geom.TDHPoint; + +public class TDHRotation implements TDHTransform { + public final double theta; + + public TDHRotation(double theta) { + this.theta = theta; + } + + @Override + public TDHPoint transform(TDHPoint punkt) { + double x = (punkt.x * Math.cos(theta)) - (punkt.y * Math.sin(theta)); + double y = (punkt.x * Math.sin(theta)) - (punkt.y * Math.cos(theta)); + + return new TDHPoint(x, y, punkt.z); + } + + public double[][] matrix() { + return new double[][] { new double[] { Math.cos(theta), Math.sin(theta), 0 }, + new double[] { -Math.sin(theta), Math.cos(theta), 0 }, new double[] { 0, 0, 1 } }; + } + + public TDHTransform invert() { + return new TDHRotation(-theta); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(theta); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TDHRotation other = (TDHRotation) obj; + if (Double.doubleToLongBits(theta) != Double.doubleToLongBits(other.theta)) + return false; + return true; + } + + @Override + public String toString() { + return "TDHRotation [theta=" + theta + "]"; + } +} \ No newline at end of file -- cgit v1.2.3