summaryrefslogtreecommitdiff
path: root/CSMath/src/bezier/transforms/TDHShear.java
blob: 40b38145aa1ef442eaac390341681907f91089da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package bezier.transforms;

import bezier.TDHPoint;

public class TDHShear implements TDHTransform {
	public final double shx;
	public final double shy;

	@Override
	public TDHTransformType type() {
		return TDHTransformType.SHEAR;
	}

	public TDHShear(double shx, double shy) {
		this.shx = shx;
		this.shy = shy;
	}

	@Override
	public TDHPoint transform(TDHPoint punkt) {
		double x = punkt.x + (punkt.y * shx);
		double y = punkt.y + (punkt.x * shy);

		return new TDHPoint(x, y, punkt.z);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(shx);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(shy);
		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;
		TDHShear other = (TDHShear) obj;
		if (Double.doubleToLongBits(shx) != Double.doubleToLongBits(other.shx))
			return false;
		if (Double.doubleToLongBits(shy) != Double.doubleToLongBits(other.shy))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "TDHShear [shx=" + shx + ", shy=" + shy + "]";
	}
}