diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/Icp.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/Icp.java index 9d4b51d2d6d6d3677f156a5d16779d4be4fdf456..c027f4128c81484870af11803d7f7229081ae466 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/Icp.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/Icp.java @@ -28,7 +28,7 @@ public class Icp { private final List<IcpTransformation> transformations = new LinkedList<>(); private MeshFacet transformedFacet = null; - private int maxIteration = 10; + private int maxIteration = 10; private boolean scale; private double error = 0.05; @@ -141,8 +141,10 @@ public class Icp { meanD /= countOfNotNullPoints; - Vector3d translation = new Vector3d(mainCenter.x - comparedCenter.x, - mainCenter.y - comparedCenter.y, mainCenter.z -comparedCenter.z); + Vector3d translation = new Vector3d( + mainCenter.x - comparedCenter.x, + mainCenter.y - comparedCenter.y, + mainCenter.z - comparedCenter.z); // END computing translation parameter @@ -158,9 +160,11 @@ public class Icp { max = i; } } - Quaternion q = new Quaternion(eigM.getElement(0, max), eigM.getElement(1, max), eigM.getElement(2, max), + Quaternion q = new Quaternion( + eigM.getElement(0, max), + eigM.getElement(1, max), + eigM.getElement(2, max), eigM.getElement(3, max)); - q = q.normalize(); // END computing rotation parameter @@ -223,11 +227,13 @@ public class Icp { } if(scale && !Double.isNaN(transformation.getScaleFactor())) { - meshPointPosition.set(rotation.getX() * transformation.getScaleFactor() + transformation.getTranslation().x, + meshPointPosition.set( + rotation.getX() * transformation.getScaleFactor() + transformation.getTranslation().x, rotation.getY() * transformation.getScaleFactor() + transformation.getTranslation().y, rotation.getZ() * transformation.getScaleFactor() + transformation.getTranslation().z); } else { - meshPointPosition.set(rotation.getX() + transformation.getTranslation().x, + meshPointPosition.set( + rotation.getX() + transformation.getTranslation().x, rotation.getY() + transformation.getTranslation().y , rotation.getZ() + transformation.getTranslation().z); } @@ -273,8 +279,8 @@ public class Icp { countOfNotNullPoints ++; } - result.add(new Point3d(xN/countOfNotNullPoints,yN/countOfNotNullPoints,zN/countOfNotNullPoints)); - result.add(new Point3d(xC/countOfNotNullPoints,yC/countOfNotNullPoints,zC/countOfNotNullPoints)); + result.add(new Point3d(xN/countOfNotNullPoints, yN/countOfNotNullPoints, zN/countOfNotNullPoints)); + result.add(new Point3d(xC/countOfNotNullPoints, yC/countOfNotNullPoints, zC/countOfNotNullPoints)); return result; } @@ -287,7 +293,7 @@ public class Icp { * @return Vector3d which represents coordinates of new point according to center. */ private Point3d relativeCoordinate(Point3d p, Point3d center) { - return new Point3d(p.x - center.x,p.y - center.y, p.z - center.z); + return new Point3d(p.x - center.x, p.y - center.y, p.z - center.z); } /** @@ -297,10 +303,11 @@ public class Icp { * @return Sum matrix of given point */ private Matrix4d sumMatrixComp(Point3d p) { - return new Matrix4d(0, -p.x, -p.y, -p.z, - p.x, 0, p.z, -p.y, - p.y, -p.z, 0, p.x, - p.z, p.y, -p.x,0 ); + return new Matrix4d( + 0, -p.x, -p.y, -p.z, + p.x, 0, p.z, -p.y, + p.y, -p.z, 0, p.x, + p.z, p.y, -p.x, 0); } /** * Compute sum matrix of given point. Given point is point from main facet. @@ -309,10 +316,11 @@ public class Icp { * @return Sum matrix of given point */ private Matrix4d sumMatrixMain(Point3d p) { - return new Matrix4d(0, -p.x, -p.y, -p.z, - p.x, 0, -p.z, p.y, - p.y, p.z, 0, -p.x, - p.z, -p.y, p.x, 0); + return new Matrix4d( + 0, -p.x, -p.y, -p.z, + p.x, 0, -p.z, p.y, + p.y, p.z, 0, -p.x, + p.z, -p.y, p.x, 0); } /** @@ -322,9 +330,11 @@ public class Icp { * @return Matrix of point. */ private Matrix4d pointToMatrix(Point3d p){ - return new Matrix4d(p.x, p.y, p.z, 1, - 0, 0, 0, 0, 0, 0, - 0,0, 0, 0, 0, 0); + return new Matrix4d( + p.x, p.y, p.z, 1, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0); } } \ No newline at end of file diff --git a/Comparison/src/main/java/cz/fidentis/analyst/icp/Quaternion.java b/Comparison/src/main/java/cz/fidentis/analyst/icp/Quaternion.java index ddfb63391e17e6fd70c88054768648721d244cf7..c8d8c24dc163993e6d7f099e0812067e6cd64f27 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/icp/Quaternion.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/icp/Quaternion.java @@ -8,11 +8,12 @@ import javax.vecmath.Matrix4d; * @author Maria Kocurekova */ public final class Quaternion { - public final double w; + + private final double w; private final double x; private final double y; private final double z; - + /** * Builds a quaternion from its components. * @@ -21,10 +22,7 @@ public final class Quaternion { * @param y Second vector component. * @param z Third vector component. */ - public Quaternion( final double w, - final double x, - final double y, - final double z) { + public Quaternion(double w, double x, double y, double z) { this.w = w; this.x = x; this.y = y;