use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.
the class Object3DSurface method getNormalVertexWeighted.
public Point3f getNormalVertexWeighted(int idx) {
if (vertices_faces_index == null) {
computeUniqueVertices();
}
List<Integer> list = vertices_faces_index.get(idx);
Vector3D N = new Vector3D();
Point3f P = vertices.get(idx);
for (int i : list) {
Point3f C = getCenterFace(i);
// Vector3D V = new Vector3D(P, C);
// Vector3D Nf = new Vector3D(getNormalFace(i));
Vector3D V = new Vector3D();
V.setVectorTwoPoint3f(P, C);
Vector3D Nf = new Vector3D();
Nf.setVectorPoint3f(getNormalFace(i));
Nf.multiplyMe(1.0 / V.getLength());
N.addMe(Nf);
// TEST
if (idx == 100) {
IJ.log("normal " + Nf + " " + " " + N);
}
}
N.normalize();
return N.getPoint3f();
}
use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.
the class Object3DSurface method getRotated.
public ArrayList<Point3f> getRotated(Vector3D Axis, double angle) {
GeomTransform3D trans = new GeomTransform3D();
trans.setRotation(Axis, angle);
Vector3D center = this.getCenterAsVector();
ArrayList<Point3f> res = new ArrayList(faces.size());
for (Point3f v : faces) {
Vector3D tmp = new Vector3D();
tmp.setVectorPoint3f(v);
Vector3D tv = trans.getVectorTransformed(tmp, center);
res.add(new Point3f((float) tv.getX(), (float) tv.getY(), (float) tv.getZ()));
}
return res;
}
use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.
the class Object3DSurface method getCenterFace.
public Point3f getCenterFace(int idx) {
if (vertices_faces_index == null) {
computeUniqueVertices();
}
int ba = (idx / 3) * 3;
Point3f C = new Point3f(faces.get(ba));
C.add(faces.get(ba + 1));
C.add(faces.get(ba + 2));
C.scale(0.333f);
return C;
}
use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.
the class Object3DSurface method getSurfaceTrianglesUnit.
public List<Point3f> getSurfaceTrianglesUnit(boolean smooth) {
if ((smooth) && (smooth_faces == null)) {
computeSmoothSurfaceArea();
}
List<Point3f> l;
if (smooth) {
l = smooth_faces;
} else {
l = faces;
}
// calibration
ArrayList<Point3f> unit_vertices = new ArrayList();
Iterator it = l.iterator();
Point3f P, PP;
// coordinates are normally calibrated
while (it.hasNext()) {
P = (Point3f) it.next();
PP = new Point3f(P.x, P.y, P.z);
unit_vertices.add(PP);
}
return unit_vertices;
}
use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.
the class Object3DSurface method computeConvexHull3D.
public ArrayList<Point3f> computeConvexHull3D() {
QuickHull3D hull = new QuickHull3D();
ArrayList<Voxel3D> pointsList = this.getContours();
Point3d[] points = new Point3d[pointsList.size()];
for (int ve = 0; ve < points.length; ve++) {
points[ve] = new Point3d(pointsList.get(ve).getX(), pointsList.get(ve).getY(), pointsList.get(ve).getZ());
}
hull.build(points);
hull.triangulate();
ArrayList<Point3f> convex = new ArrayList<Point3f>();
int[][] faceIndices = hull.getFaces();
Point3d[] verticesHull = hull.getVertices();
for (int ve = 0; ve < verticesHull.length; ve++) {
for (int k = 0; k < faceIndices[ve].length; k++) {
Point3d point = verticesHull[faceIndices[ve][k]];
convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
}
}
for (int[] faceIndice : faceIndices) {
for (int ve = 0; ve < 3; ve++) {
Point3d point = verticesHull[faceIndice[ve]];
convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
}
}
return convex;
}
Aggregations