blob: b4e5bb0b7a061a6c58c21380a559510ae2611277 (
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
|
package bezier.transforms;
import bezier.TDHPoint;
public class TDHMatrix implements TDHTransform {
public final double[][] mat;
public TDHMatrix(double[][] mat) {
super();
this.mat = mat;
}
@Override
public TDHTransformType type() {
return TDHTransformType.MATRIX;
}
@Override
public TDHPoint transform(TDHPoint punkt) {
double x = (punkt.x * mat[0][0]) + (punkt.y * mat[1][0]) + (punkt.z * mat[2][0]);
double y = (punkt.x * mat[0][1]) + (punkt.y * mat[1][1]) + (punkt.z * mat[2][1]);
double z = (punkt.x * mat[0][2]) + (punkt.y * mat[1][2]) + (punkt.z * mat[2][2]);
return new TDHPoint(x, y, z);
}
public TDHTransform then(double[][] matr) {
double[][] ret = new double[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
ret[i][j] += mat[i][k] * matr[k][j];
}
}
}
return new TDHMatrix(ret);
}
}
|