Search in sources :

Example 1 with Matrix

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

the class ObjectCreator3D method createBrickAxes.

/**
 * Creation d'une ellipsoide
 *
 * @param rx      Rayon en x (unit)
 * @param ry      Rayon en y (unit)
 * @param rz      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 createBrickAxes(int centerx, int centery, int centerz, double rx, double ry, double rz, float value, Matrix M) {
    double radius = Math.max(rx, Math.max(ry, rz));
    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;
    double ddy;
    double ddz;
    double dx;
    double dy;
    double dz;
    // inverse
    Matrix MM = M.inverse();
    Matrix V1 = new Matrix(3, 1);
    Matrix V2;
    // work in unit coordinate
    for (int k = startz; k <= endz; k++) {
        IJ.showStatus("Brick " + k + "/" + endz);
        ddz = resZ * (k - centerz);
        for (int j = starty; j <= endy; j++) {
            ddy = resXY * (j - centery);
            for (int i = startx; i <= endx; i++) {
                ddx = resXY * (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);
                // brick
                if ((Math.abs(dx) <= rx) && (Math.abs(dy) <= ry) && (Math.abs(dz) <= rz)) {
                    img.setPixel(i, j, k, value);
                }
            // System.out.println(ddx + " " + ddy + " " + ddz + " | " + dx + " " + dy + " " + dz);
            }
        }
    }
}
Also used : Matrix(mcib3d.Jama.Matrix)

Example 2 with Matrix

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

the class ObjectCreator3D method createBrickAxes.

/**
 * @param centerx
 * @param centery
 * @param centerz
 * @param rx
 * @param ry
 * @param rz
 * @param value
 * @param V
 */
public void createBrickAxes(int centerx, int centery, int centerz, double rx, double ry, double rz, float value, Vector3D V) {
    V.normalize();
    Vector3D W = V.getRandomPerpendicularVector();
    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());
    createBrickAxes(centerx, centery, centerz, rx, ry, rz, value, M);
}
Also used : Matrix(mcib3d.Jama.Matrix)

Example 3 with Matrix

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

the class ObjectCreator3D method drawEllipsoid.

private void drawEllipsoid(int startx, int endx, int starty, int endy, int startz, int endz, int centerx, int centery, int centerz, double rx, double ry, double rz, Matrix MM, float value, boolean gauss) {
    double ddx, ddy, ddz, dx, dy, dz, d;
    Matrix V1 = new Matrix(3, 1);
    Matrix V2;
    double rx2 = rx * rx;
    double ry2 = ry * ry;
    double rz2 = rz * rz;
    // work in pixel coordinate
    for (int k = startz; k <= endz; k++) {
        IJ.showStatus("Ellipsoid " + 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);
                // ellipsoid
                d = (dx * dx) / (rx2) + (dy * dy) / (ry2) + (dz * dz) / (rz2);
                if (d <= 1.0) {
                    if (gauss) {
                        img.setPixel(i, j, k, (float) (value * (1.0 - d / 2)));
                    } else {
                        img.setPixel(i, j, k, value);
                    }
                // System.out.println(ddx + " " + ddy + " " + ddz + " | " + dx + " " + dy + " " + dz);
                }
            }
        }
    }
}
Also used : Matrix(mcib3d.Jama.Matrix)

Example 4 with Matrix

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

the class ObjectCreator3D method createEllipsoidAxes.

/**
 * Creation d'une ellipsoide (data in pix)
 *
 * @param rx      Rayon en x
 * @param ry      Rayon en y
 * @param rz      Rayon en z
 * @param centerx Centre en x
 * @param centery Centre en y
 * @param centerz Centre en z
 * @param value   Valeur à remplir
 * @param gauss   uniform or ramp values
 * @param M       Description of the Parameter
 */
public void createEllipsoidAxes(int centerx, int centery, int centerz, double rx, double ry, double rz, float value, Matrix M, boolean gauss) {
    double radius = Math.max(rx, Math.max(ry, rz));
    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;
    }
    // inverse
    Matrix MM = M.inverse();
    drawEllipsoid(startx, endx, starty, endy, startz, endz, centerx, centery, centerz, rx, ry, rz, MM, value, gauss);
}
Also used : Matrix(mcib3d.Jama.Matrix)

Example 5 with Matrix

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

the class Object3D method computeEigen.

/**
 * Constructor for the computeEigen object
 */
protected void computeEigen() {
    if (eigen == null) {
        Matrix mat = new Matrix(3, 3);
        if (Double.isNaN(s200)) {
            computeMoments2(true);
        }
        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)

Aggregations

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