Search in sources :

Example 1 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Mesh method normalization.

public Point3f normalization(Point3f v) {
    Point3f nV;
    float norme = (float) Math.sqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z));
    nV = new Point3f(v.x / norme, v.y / norme, v.z / norme);
    return nV;
}
Also used : Point3f(org.scijava.vecmath.Point3f)

Example 2 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Mesh method invertNormals.

// dans mesh.java
public ArrayList<Point3f> invertNormals(ArrayList<Point3f> v) {
    ArrayList<Point3f> v2 = new ArrayList<Point3f>();
    for (int i = 0; i < v.size(); i += 3) {
        v2.add(new Point3f(v.get(i)));
        v2.add(new Point3f(v.get(i + 2)));
        v2.add(new Point3f(v.get(i + 1)));
    }
    return v2;
}
Also used : Point3f(org.scijava.vecmath.Point3f) ArrayList(java.util.ArrayList)

Example 3 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Mesh method intersectTriangle.

public boolean intersectTriangle(int ti, Point3f dir, Point3f origin) {
    // Calcul des vecteurs u et v qui engendrent le plan du triangle
    Point3f A, B, C, u, v;
    Triangle t = triangles.get(ti);
    A = vertexList.get(t.getVertices().get(0)).getPosition();
    B = vertexList.get(t.getVertices().get(1)).getPosition();
    C = vertexList.get(t.getVertices().get(2)).getPosition();
    u = new Point3f(B.x - A.x, B.y - A.y, B.z - A.z);
    v = new Point3f(C.x - A.x, C.y - A.y, C.z - A.z);
    Point3f n = crossProduct(u, v);
    Point3f intersectionPoint;
    boolean inter = false;
    // Calcul de la normale du triangle t de maillage de l'objet k
    float prodNormDir = dotProduct(n, dir);
    // Si le plan du triangle n est pas parallele au rayon, donc visible depuis la camera:
    if (// cos inferieur a 1 => la normal et la direction forment un angle inferieur à 90 degres
    (prodNormDir) < 0.0f) {
        // Calcul de w, vecteur du point d'origine du rayon au point A
        Point3f w = new Point3f(origin.x - A.x, origin.y - A.y, origin.z - A.z);
        // Point3f w = new Point3f(A.x - origin.x,A.y - origin.y,A.z - origin.z);
        // Les coordonées baricentriques du point d'intersection I sont donc, par rapport aux vecteurs u et v qui engendrent le triangle:
        float Ix = dotProduct(crossProduct(w, v), dir) / prodNormDir;
        float Iy = dotProduct(crossProduct(u, w), dir) / prodNormDir;
        // distance du triangle a l origine.
        float Ir = -dotProduct(n, w) / prodNormDir;
        // Test: Si le rayon traverse le triangle: la somme des coordonnees suivant u et v ne doivent pas depaser 1, et les deux doivent etre positifs (puisque dans la direction de u et v, "vers" le triangle)
        if ((Ix + Iy <= 1) && ((Ix >= 0) && (Iy >= 0)) && Ir >= 0) {
            // baricentriques = Vec3Df(Ix, Iy, Iz);
            intersectionPoint = new Point3f(A.x + (u.x * Ix) + (v.x * Iy), A.y + (u.y * Ix) + (v.y * Iy), A.z + (u.z * Ix) + (v.z * Iy));
            if (distance(intersectionPoint, origin) <= 1) {
                inter = true;
            }
        }
    }
    return inter;
}
Also used : Point3f(org.scijava.vecmath.Point3f)

Example 4 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method createRoi.

@Override
@Deprecated
public Roi createRoi(int z) {
    // FIXME coordinates may not be ordered
    float[] xcoor = new float[faces.size()];
    float[] ycoor = new float[faces.size()];
    int i = 0;
    Point3f vox;
    for (Point3f vertice : vertices) {
        vox = vertice;
        if (Math.abs(z - vox.z) < 0.5) {
            xcoor[i] = vox.x;
            ycoor[i] = vox.y;
        }
    }
    return new PolygonRoi(xcoor, ycoor, xcoor.length, Roi.POINT);
}
Also used : PolygonRoi(ij.gui.PolygonRoi) Point3f(org.scijava.vecmath.Point3f)

Example 5 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method reCalibratePoints.

public void reCalibratePoints() {
    for (Point3f P : faces) {
        P.set(P.x * (float) resXY, P.y * (float) resXY, P.z * (float) resZ);
    }
    for (Point3f P : vertices) {
        P.set(P.x * (float) resXY, P.y * (float) resXY, P.z * (float) resZ);
    }
    this.computeCenter();
    this.computeBounding();
}
Also used : Point3f(org.scijava.vecmath.Point3f)

Aggregations

Point3f (org.scijava.vecmath.Point3f)58 ArrayList (java.util.ArrayList)20 Calibration (ij.measure.Calibration)6 HashMap (java.util.HashMap)5 Color3f (org.scijava.vecmath.Color3f)5 Point (java.awt.Point)4 Color (java.awt.Color)3 Area (java.awt.geom.Area)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 Point3d (com.github.quickhull3d.Point3d)2 QuickHull3D (com.github.quickhull3d.QuickHull3D)2 PolygonRoi (ij.gui.PolygonRoi)2 Rectangle (java.awt.Rectangle)2 AffineTransform (java.awt.geom.AffineTransform)2 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Vector3f (org.scijava.vecmath.Vector3f)2 CustomLineMesh (customnode.CustomLineMesh)1 CustomMesh (customnode.CustomMesh)1