Search in sources :

Example 11 with Matrix

use of mcib3d.Jama.Matrix in project mcib3d-core by mcib3d.

the class ObjectCreator3D method createConeAxes.

public void createConeAxes(int centerx, int centery, int centerz, double rx0, double ry0, double rx1, double ry1, double height, float value, Vector3D V, Vector3D W) {
    V.normalize();
    W.normalize();
    Vector3D X = V.crossProduct(W);
    X.normalize();
    Matrix M = new Matrix(3, 3);
    // V
    M.set(0, 0, V.getX());
    M.set(1, 0, V.getY());
    M.set(2, 0, V.getZ());
    // W
    M.set(0, 1, W.getX());
    M.set(1, 1, W.getY());
    M.set(2, 1, W.getZ());
    // X
    M.set(0, 2, X.getX());
    M.set(1, 2, X.getY());
    M.set(2, 2, X.getZ());
    createConeAxes(centerx, centery, centerz, rx0, ry0, rx1, ry1, height, value, M);
}
Also used : Matrix(mcib3d.Jama.Matrix)

Example 12 with Matrix

use of mcib3d.Jama.Matrix in project mcib3d-core by mcib3d.

the class ObjectCreator3D method createCylinderAxes.

public void createCylinderAxes(int centerx, int centery, int centerz, double rx, double ry, double height, float value, Vector3D V, Vector3D W) {
    V.normalize();
    W.normalize();
    Vector3D X = V.crossProduct(W);
    X.normalize();
    Matrix M = new Matrix(3, 3);
    // V
    M.set(0, 0, V.getX());
    M.set(1, 0, V.getY());
    M.set(2, 0, V.getZ());
    // W
    M.set(0, 1, W.getX());
    M.set(1, 1, W.getY());
    M.set(2, 1, W.getZ());
    // X
    M.set(0, 2, X.getX());
    M.set(1, 2, X.getY());
    M.set(2, 2, X.getZ());
    createCylinderAxes(centerx, centery, centerz, rx, ry, height, value, M);
}
Also used : Matrix(mcib3d.Jama.Matrix)

Example 13 with Matrix

use of mcib3d.Jama.Matrix in project mcib3d-core by mcib3d.

the class Object3DVoxels method computeEigenInertia.

/**
 * Constructor for the computeEigenInertia object
 */
private void computeEigenInertia() {
    if (eigen == null) {
        Matrix mat = new Matrix(3, 3);
        mat.set(0, 0, s200);
        mat.set(0, 1, -s110);
        mat.set(0, 2, -s101);
        mat.set(1, 0, -s110);
        mat.set(1, 1, s020);
        mat.set(1, 2, -s011);
        mat.set(2, 0, -s101);
        mat.set(2, 1, -s011);
        mat.set(2, 2, s002);
        eigen = new EigenvalueDecomposition(mat);
    }
}
Also used : Matrix(mcib3d.Jama.Matrix) EigenvalueDecomposition(mcib3d.Jama.EigenvalueDecomposition)

Example 14 with Matrix

use of mcib3d.Jama.Matrix in project mcib3d-core by mcib3d.

the class ObjectCreator3D method createCylinderAxes.

/**
 * Creation d'un cylindre
 *
 * @param rx      Rayon en x (unit)
 * @param ry      Rayon en y (unit)
 * @param height  Rayon en z (unit)
 * @param centerx Centre en x
 * @param centery Centre en y
 * @param centerz Centre en z
 * @param value   Valeur à remplir
 * @param M       Description of the Parameter
 */
public void createCylinderAxes(int centerx, int centery, int centerz, double rx, double ry, double height, float value, Matrix M) {
    double radius = Math.max(rx, Math.max(ry, height / 2));
    int startx = (int) (centerx - radius);
    if (startx < 0) {
        startx = 0;
    }
    int starty = (int) (centery - radius);
    if (starty < 0) {
        starty = 0;
    }
    int startz = (int) (centerz - radius);
    if (startz < 0) {
        startz = 0;
    }
    int endx = (int) (centerx + radius);
    if (endx >= img.sizeX) {
        endx = img.sizeX - 1;
    }
    int endy = (int) (centery + radius);
    if (endy >= img.sizeY) {
        endy = img.sizeY - 1;
    }
    int endz = (int) (centerz + radius);
    if (endz >= img.sizeZ) {
        endz = img.sizeZ - 1;
    }
    double ddx, ddy, ddz;
    double dx, dy, dz;
    double rx2 = rx * rx;
    double ry2 = ry * ry;
    // inverse
    Matrix MM = M.inverse();
    Matrix V1 = new Matrix(3, 1);
    Matrix V2;
    // work in pixel coordinate
    for (int k = startz; k <= endz; k++) {
        IJ.showStatus("Cylinder " + k + "/" + endz);
        ddz = (k - centerz);
        for (int j = starty; j <= endy; j++) {
            ddy = (j - centery);
            for (int i = startx; i <= endx; i++) {
                ddx = (i - centerx);
                // vector in column
                V1.set(0, 0, ddx);
                V1.set(1, 0, ddy);
                V1.set(2, 0, ddz);
                // multiplication
                V2 = MM.times(V1);
                // result
                dx = V2.get(0, 0);
                dy = V2.get(1, 0);
                dz = V2.get(2, 0);
                // cylinder
                if (Math.abs(dz) < height / 2) {
                    double d = (dx * dx) / (rx2) + (dy * dy) / (ry2);
                    if (d <= 1.0) {
                        img.setPixel(i, j, k, value);
                    }
                }
            // System.out.println(ddx + " " + ddy + " " + ddz + " | " + dx + " " + dy + " " + dz);
            }
        }
    }
}
Also used : Matrix(mcib3d.Jama.Matrix)

Aggregations

Matrix (mcib3d.Jama.Matrix)14 EigenvalueDecomposition (mcib3d.Jama.EigenvalueDecomposition)4 Vector3D (mcib3d.geom.Vector3D)1