Search in sources :

Example 16 with RigidTransform3d

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

the class MeshFactory method createQuadHemisphere.

public static PolygonalMesh createQuadHemisphere(double r, int nslices, int nlevels, double x, double y, double z) {
    double tol = computeSphericalPointTolerance(r, 2 * Math.PI, Math.PI, nslices, nlevels);
    PolygonalMesh mesh = new PolygonalMesh();
    VertexMap vtxMap = new VertexMap(tol);
    RigidTransform3d XLM = new RigidTransform3d(x, y, z);
    addQuadSphericalSection(mesh, r, Math.PI, Math.PI / 2, nslices, nlevels, XLM, vtxMap);
    return mesh;
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 17 with RigidTransform3d

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

the class MeshFactory method createQuadExtendedTorus.

/**
 * Creates a quad extended torus mesh in the x-y plane.  An extended torus
 * is a torus with straight sections added in the middle, giving a
 * shape similar to a chain link. The straight sections are parallel
 * to the x-axis.
 *
 * @param rmajor major radius of the torus
 * @param rminor minor radius of the torus
 * @param xlen length of the straight sections
 * @param nmajor number of slices along the major radius
 * @param nminor number of slices along the minor radius
 */
public static PolygonalMesh createQuadExtendedTorus(double rmajor, double rminor, double xlen, int nmajor, int nminor) {
    double tol = computeToroidalTolerance(rmajor, rminor, 2 * Math.PI, nmajor, nminor);
    VertexMap vtxMap = new VertexMap(tol);
    PolygonalMesh mesh = new PolygonalMesh();
    RigidTransform3d XLM = new RigidTransform3d();
    XLM.p.set(xlen / 2, 0, 0);
    XLM.R.setRpy(-Math.PI / 2, 0, 0);
    addQuadToroidalSection(mesh, rmajor, rminor, Math.PI, nmajor, nminor, XLM, vtxMap);
    XLM.p.set(-xlen / 2, 0, 0);
    XLM.R.setRpy(Math.PI / 2, 0, 0);
    addQuadToroidalSection(mesh, rmajor, rminor, Math.PI, nmajor, nminor, XLM, vtxMap);
    double outerChordLen = 2 * (rmajor + rminor) * Math.sin(Math.PI / (nmajor));
    int nx = (int) Math.ceil(xlen / outerChordLen);
    XLM.p.set(0, rmajor, 0);
    XLM.R.setRpy(0, Math.PI / 2, 0);
    addQuadCylindricalSection(mesh, rminor, xlen, 2 * Math.PI, nx, nminor, /*outward=*/
    true, XLM, vtxMap);
    XLM.p.set(0, -rmajor, 0);
    XLM.R.setRpy(0, Math.PI / 2, 0);
    addQuadCylindricalSection(mesh, rminor, xlen, 2 * Math.PI, nx, nminor, /*outward=*/
    true, XLM, vtxMap);
    return mesh;
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 18 with RigidTransform3d

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

the class MeshFactory method createQuadBoxNew.

public static PolygonalMesh createQuadBoxNew(double wx, double wy, double wz, Point3d center, int nx, int ny, int nz) {
    double tol = Math.min(wx / nx, wy / ny);
    tol = Math.min(tol, wz / nz);
    VertexMap vtxMap = new VertexMap(tol);
    PolygonalMesh mesh = new PolygonalMesh();
    RigidTransform3d XLM = new RigidTransform3d();
    XLM.p.set(center);
    XLM.p.z = center.z + wz / 2;
    addQuadRectangle(mesh, wx, wy, nx, ny, XLM, vtxMap);
    XLM.p.z = center.z - wz / 2;
    XLM.R.set(1, 0, 0, 0, -1, 0, 0, 0, -1);
    addQuadRectangle(mesh, wx, wy, nx, ny, XLM, vtxMap);
    XLM.p.z = 0;
    XLM.p.x = center.x + wx / 2;
    XLM.R.set(0, 0, -1, 0, 1, 0, 1, 0, 0);
    addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
    XLM.p.x = center.x - wx / 2;
    XLM.R.set(0, 0, 1, 0, 1, 0, -1, 0, 0);
    addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
    XLM.p.x = 0;
    XLM.p.y = center.y + wy / 2;
    XLM.R.set(1, 0, 0, 0, 0, -1, 0, 1, 0);
    addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
    XLM.p.y = center.y - wy / 2;
    XLM.R.set(1, 0, 0, 0, 0, 1, 0, -1, 0);
    addQuadRectangle(mesh, wz, wy, nz, ny, XLM, vtxMap);
    return mesh;
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d)

Example 19 with RigidTransform3d

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

the class MeshFactory method createQuadSphere.

public static PolygonalMesh createQuadSphere(double r, int nslices, int nlevels, double x, double y, double z, boolean addTextureCoords) {
    double tol = computeSphericalPointTolerance(r, 2 * Math.PI, Math.PI, nslices, nlevels);
    PolygonalMesh mesh = new PolygonalMesh();
    VertexMap vtxMap = new VertexMap(tol);
    RigidTransform3d XLM = new RigidTransform3d(x, y, z);
    addQuadSphericalSection(mesh, r, Math.PI, Math.PI, nslices, nlevels, XLM, vtxMap);
    if (addTextureCoords) {
        Point3d origin = new Point3d(x, y, z);
        computeTextureCoordsForSphere(mesh, origin, r, tol);
    }
    return mesh;
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Point3d(maspack.matrix.Point3d)

Example 20 with RigidTransform3d

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

the class BVFeatureQueryTest method nearestVertexAndEdgeTest.

private void nearestVertexAndEdgeTest(MeshBase mesh) {
    // NearestFeatureQuery query = new NearestFeatureQuery();
    double inf = Double.POSITIVE_INFINITY;
    Point3d max = new Point3d(-inf, -inf, -inf);
    Point3d min = new Point3d(inf, inf, inf);
    Point3d center = new Point3d();
    Point3d widths = new Point3d();
    mesh.updateBounds(min, max);
    center.add(min, max);
    center.scale(0.5);
    widths.sub(max, min);
    widths.scale(0.5);
    double diameter = max.distance(min);
    RigidTransform3d X = new RigidTransform3d();
    OBBTree obbTree = new OBBTree(mesh, 2);
    AABBTree aabbTree = new AABBTree(mesh, 2, 0.001 * diameter);
    nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
    nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
    X.setRandom();
    nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
    // aabbTree.print();
    nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
    X.setRandom();
    nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
    nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
    X.setRandom();
    nearestVertexAndEdge(mesh, obbTree, X, center, diameter);
    nearestVertexAndEdge(mesh, aabbTree, X, center, diameter);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Point3d(maspack.matrix.Point3d)

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