diff options
| author | bjculkin <bjculkin@BECK-DZ9BJB2.wvu-ad.wvu.edu> | 2018-04-11 15:29:25 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@BECK-DZ9BJB2.wvu-ad.wvu.edu> | 2018-04-11 15:29:25 -0400 |
| commit | dcb6c2159446135a142cad41eec185bb24c45bfb (patch) | |
| tree | 965dcc07fc0256a9a8254d5f968e316a1e928617 /CSMath/src/bezier/transforms/TDHRotation.java | |
| parent | 8ecf52b6c5821e5c3de8a0f5c9e7ed3e357cb282 (diff) | |
Split #9 into one class/file
Diffstat (limited to 'CSMath/src/bezier/transforms/TDHRotation.java')
| -rw-r--r-- | CSMath/src/bezier/transforms/TDHRotation.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/CSMath/src/bezier/transforms/TDHRotation.java b/CSMath/src/bezier/transforms/TDHRotation.java new file mode 100644 index 0000000..b2255d4 --- /dev/null +++ b/CSMath/src/bezier/transforms/TDHRotation.java @@ -0,0 +1,57 @@ +package bezier.transforms;
+
+import bezier.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 |
