use of mcib3d.geom.Vector3D in project mcib3d-core by mcib3d.
the class DeformableMesh method iterateTranslation.
public Vector3D iterateTranslation(double error, int nIte) {
Vector3D transT = new Vector3D();
Vector3D trans;
boolean translate = true;
int count = 1;
while ((translate) && (count < nIte)) {
count++;
this.computeAllForces(false);
trans = this.getTranslation();
this.translate(trans);
transT = transT.add(trans);
// IJ.log("Translation " + trans);
if (trans.getLength() < error) {
translate = false;
}
}
return transT;
}
use of mcib3d.geom.Vector3D in project mcib3d-core by mcib3d.
the class DeformableMesh method getOrientedScaling.
public double getOrientedScaling(Vector3D dir) {
Point3D center = this.getCenterAsVector();
Vector3D dirN = dir.getNormalizedVector();
double ratio = 0;
double r;
double cpt = 0;
for (int i = 0; i < forces.size(); i++) {
Point3D P0 = new Point3D(this.getUniqueVertex(i));
Point3D P1 = new Point3D(this.getUniqueVertex(i));
Vector3D force = forces.get(i);
// IJ.log("Force " + i + " " + force);
if (force != null) {
double orient = Math.abs(force.getNormalizedVector().dotProduct(dirN));
double rat = orient * orient;
P1.translate(force);
Vector3D V0 = new Vector3D(center, P0);
Vector3D V1 = new Vector3D(center, P1);
r = V1.getLength() / V0.getLength();
ratio += rat * r;
cpt += rat;
if (r > 100) {
IJ.log("scale " + i + " " + r + " " + orient + " " + force.getLength() + " " + V0.getLength() + " " + V1.getLength() + " " + center + " " + P0 + " " + P1);
}
}
}
if (cpt > 0) {
ratio /= cpt;
} else {
ratio = 1;
}
return ratio;
}
use of mcib3d.geom.Vector3D in project mcib3d-core by mcib3d.
the class DeformableMesh method getBestDisplacement.
private Vector3D getBestDisplacement(int i) {
Point3D P = new Point3D(getUniqueVertex(i));
Point3D closestPlus = getClosestEdge(i, true);
Point3D closestMinus = getClosestEdge(i, false);
double distPlus, distMinus;
Vector3D displ;
if (closestPlus != null) {
distPlus = closestPlus.distance(P);
} else {
distPlus = Double.MAX_VALUE;
}
if (closestMinus != null) {
distMinus = closestMinus.distance(P);
} else {
distMinus = Double.MAX_VALUE;
}
if ((distPlus < distMinus) && (closestPlus != null)) {
displ = new Vector3D(P, closestPlus);
} else if ((distPlus > distMinus) && (closestMinus != null)) {
displ = new Vector3D(P, closestMinus);
} else {
displ = null;
}
return displ;
}
Aggregations