-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleICP.java
More file actions
52 lines (33 loc) · 1.36 KB
/
SimpleICP.java
File metadata and controls
52 lines (33 loc) · 1.36 KB
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
import geometry.Plane;
import geometry.Point;
import geometry.Transformation;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.SingularValueDecomposition;
import org.apache.commons.math.linear.SingularValueDecompositionImpl;
public class SimpleICP implements ICP {
@Override
public Transformation iterate(Point[] source, Plane[] target) {
Point[] targetPoints = new Point[source.length];
int a = 0;
for(Point s : source) {
targetPoints[a++] = Scene.findClosestPlane(target, s);
}
return findRigidTransformation(source, targetPoints);
}
public Transformation findRigidTransformation(Point[] source, Point[] target) {
if(source.length != target.length) {
throw new RuntimeException("Points do not correspond");
}
double[][] m1 = new double[source.length][2], m2 = new double[source.length][2];
for(int a = 0;a < source.length;a++) {
m1[a][0] = source[a].getX();
m1[a][1] = source[a].getY();
m2[a][0] = source[a].getX();
m2[a][1] = source[a].getY();
}
RealMatrix sourceMatrix = MatrixUtils.createRealMatrix(m1);
RealMatrix destMatrix = MatrixUtils.createRealMatrix(m2);
return null;
}
}