blob: 0158d600836998cbe8ab599a0f004f06cd9c8492 (
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
60
61
62
63
64
65
66
67
68
|
package bezier.geom.transform;
import bezier.geom.TDHPoint;
public class TDHLineReflection implements TDHTransform {
public final double a;
public final double b;
public final double c;
public TDHLineReflection(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
@Override
public TDHTransformType type() {
return TDHTransformType.REFLECTION;
}
@Override
public TDHPoint transform(TDHPoint punkt) {
double com = (a * a - b * b);
double x = (punkt.x * com) - (2 * a * b * punkt.y) - (2 * a * c * punkt.z);
double y = (-2 * a * b * punkt.x) + (punkt.y * com) - (2 * b * c * punkt.z);
double z = (punkt.z * com);
return new TDHPoint(x, y, z);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(a);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(b);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(c);
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;
TDHLineReflection other = (TDHLineReflection) obj;
if (Double.doubleToLongBits(a) != Double.doubleToLongBits(other.a))
return false;
if (Double.doubleToLongBits(b) != Double.doubleToLongBits(other.b))
return false;
if (Double.doubleToLongBits(c) != Double.doubleToLongBits(other.c))
return false;
return true;
}
@Override
public String toString() {
return "TDHLineReflection [a=" + a + ", b=" + b + ", c=" + c + "]";
}
}
|