Search in sources :

Example 16 with Vector3D

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;
}
Also used : Vector3D(mcib3d.geom.Vector3D)

Example 17 with Vector3D

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;
}
Also used : Vector3D(mcib3d.geom.Vector3D) Point3D(mcib3d.geom.Point3D)

Example 18 with Vector3D

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;
}
Also used : Vector3D(mcib3d.geom.Vector3D) Point3D(mcib3d.geom.Point3D)

Aggregations

Vector3D (mcib3d.geom.Vector3D)18 Point3D (mcib3d.geom.Point3D)4 EigenvalueDecomposition (mcib3d.Jama.EigenvalueDecomposition)1 Matrix (mcib3d.Jama.Matrix)1 Object3D (mcib3d.geom.Object3D)1 Objects3DPopulation (mcib3d.geom.Objects3DPopulation)1 ImageFloat (mcib3d.image3d.ImageFloat)1 ImageHandler (mcib3d.image3d.ImageHandler)1 ArrayUtil (mcib3d.utils.ArrayUtil)1 Chrono (mcib3d.utils.Chrono)1 Point3f (org.scijava.vecmath.Point3f)1