Search in sources :

Example 76 with RigidTransform3d

use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.

the class CutPlaneProbe method setOrientation.

/**
 * Sets the orientation of the display
 */
public void setOrientation(AxisAngle axisAng) {
    RigidTransform3d X = new RigidTransform3d(XGridToWorld);
    X.R.setAxisAngle(axisAng);
    setGridToWorld(X);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 77 with RigidTransform3d

use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.

the class CutPlaneProbe method setPosition.

/**
 * Sets the 3D position of the centre of the display
 */
public void setPosition(Point3d pos) {
    RigidTransform3d X = new RigidTransform3d(XGridToWorld);
    X.p.set(pos);
    setGridToWorld(X);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 78 with RigidTransform3d

use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.

the class PointDistributor method getTightOBB.

public static OBB getTightOBB(Point3d[] pnts, RigidTransform3d principal) {
    Vector3d[] axis = new Vector3d[3];
    double[][] projBounds = new double[3][2];
    for (int i = 0; i < 3; i++) {
        axis[i] = new Vector3d();
        principal.R.getColumn(i, axis[i]);
    }
    Vector3d p = principal.p;
    // loop through all nodes, projecting onto axes
    for (int i = 0; i < pnts.length; i++) {
        for (int j = 0; j < 3; j++) {
            Vector3d vec = new Vector3d();
            vec.sub(pnts[i], p);
            double d = vec.dot(axis[j]);
            if (d < projBounds[j][0]) {
                projBounds[j][0] = d;
            } else if (d > projBounds[j][1]) {
                projBounds[j][1] = d;
            }
        }
    // end looping through axes
    }
    // end looping over vertices
    // construct bounds
    Point3d c = new Point3d(0, 0, 0);
    Vector3d widths = new Vector3d();
    for (int i = 0; i < 3; i++) {
        c.set(i, 0);
        widths.set(i, projBounds[i][1] - projBounds[i][0]);
        c.set(i, p.get(i) + (projBounds[i][0] + projBounds[i][1]) / 2);
    }
    RigidTransform3d trans = new RigidTransform3d(c, principal.R);
    OBB obb = new OBB(widths, trans);
    return obb;
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) OBB(maspack.geometry.OBB)

Example 79 with RigidTransform3d

use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.

the class PointDistributor method getSphericalMidpointCubature.

public static CubaturePoint3d[] getSphericalMidpointCubature(Point3d center, double radius, int nR, int nPhi, int nTheta, Vector3d axis) {
    CubaturePoint3d[] pnts = new CubaturePoint3d[nR * nPhi * nTheta];
    double dr = radius / nR;
    double dphi = 2 * Math.PI / nPhi;
    double dtheta = Math.PI / nTheta;
    RigidTransform3d trans = new RigidTransform3d();
    if (axis != null) {
        RotationMatrix3d R = new RotationMatrix3d();
        R.rotateZDirection(axis);
        trans.setRotation(R);
    }
    trans.setTranslation(center);
    double r, phi, theta;
    int idx = 0;
    for (int i = 0; i < nR; i++) {
        for (int j = 0; j < nPhi; j++) {
            for (int k = 0; k < nTheta; k++) {
                r = i * dr + dr / 2;
                phi = j * dphi + (i + k) * dphi / 2;
                theta = k * dtheta + dtheta / 2;
                pnts[idx] = new CubaturePoint3d();
                pnts[idx].x = r * Math.cos(phi) * Math.sin(theta);
                pnts[idx].y = r * Math.sin(phi) * Math.sin(theta);
                pnts[idx].z = r * Math.cos(theta);
                pnts[idx].w = spherePartialVolume(radius, r, dr, phi, dphi, theta, dtheta);
                // transform
                pnts[idx].transform(trans);
                idx++;
            }
        }
    }
    return pnts;
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Example 80 with RigidTransform3d

use of maspack.matrix.RigidTransform3d in project artisynth_core by artisynth.

the class PointDistributor method sphereGridFill.

// fills a mesh based on a regular grid of points
public static Point3d[] sphereGridFill(PolygonalMesh mesh, double r) {
    ArrayList<Point3d> pnts = new ArrayList<Point3d>();
    RigidTransform3d trans = getPrincipalAxes(mesh);
    Point3d[] box = getTightBox(mesh, trans);
    Point3d center = new Point3d(box[0]);
    center.add(box[6]);
    center.scale(0.5);
    trans.setTranslation(center);
    Vector3d l = new Vector3d(box[0]);
    l.sub(box[6]);
    l.inverseTransform(trans);
    double alpha = 2 * Math.sqrt(2) * r;
    int nx = (int) Math.ceil(l.x / alpha) + 1;
    int ny = (int) Math.ceil(l.y / alpha) + 1;
    int nz = (int) Math.ceil(l.z / alpha) + 1;
    double xoffset = -(nx - 1) * alpha / 2;
    double yoffset = -(ny - 1) * alpha / 2;
    double zoffset = -(nz - 1) * alpha / 2;
    BVTree bvh = mesh.getBVTree();
    Vector2d coords = new Vector2d();
    Point3d nearest = new Point3d();
    BVFeatureQuery query = new BVFeatureQuery();
    Point3d p;
    for (int i = 0; i < nx; i++) {
        for (int j = 0; j < ny; j++) {
            for (int k = 0; k < nz; k++) {
                double x = i * alpha + xoffset;
                double y = j * alpha + yoffset;
                double z = k * alpha + zoffset;
                p = new Point3d(x, y, z);
                p.transform(trans);
                addIfIntersects(pnts, p, r, bvh, nearest, coords, query);
            }
        }
    }
    return pnts.toArray(new Point3d[pnts.size()]);
}
Also used : BVTree(maspack.geometry.BVTree) RigidTransform3d(maspack.matrix.RigidTransform3d) Vector2d(maspack.matrix.Vector2d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) ArrayList(java.util.ArrayList) BVFeatureQuery(maspack.geometry.BVFeatureQuery)

Aggregations

RigidTransform3d (maspack.matrix.RigidTransform3d)206 Vector3d (maspack.matrix.Vector3d)56 Point3d (maspack.matrix.Point3d)48 PolygonalMesh (maspack.geometry.PolygonalMesh)21 MechModel (artisynth.core.mechmodels.MechModel)19 RigidBody (artisynth.core.mechmodels.RigidBody)18 AxisAngle (maspack.matrix.AxisAngle)18 RotationMatrix3d (maspack.matrix.RotationMatrix3d)17 AffineTransform3d (maspack.matrix.AffineTransform3d)13 FemModel3d (artisynth.core.femmodels.FemModel3d)11 RenderProps (maspack.render.RenderProps)11 FemNode3d (artisynth.core.femmodels.FemNode3d)9 Color (java.awt.Color)7 Point (java.awt.Point)7 Matrix3d (maspack.matrix.Matrix3d)7 Shading (maspack.render.Renderer.Shading)7 LinearMaterial (artisynth.core.materials.LinearMaterial)6 Renderable (maspack.render.Renderable)6 ArrayList (java.util.ArrayList)5 Vector2d (maspack.matrix.Vector2d)5