Search in sources :

Example 66 with Point3d

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

the class MeshRendererBase method updatePositions.

protected void updatePositions(RenderObject r, MeshBase mesh) {
    boolean useRenderData = mesh.isRenderBuffered() && !mesh.isFixed();
    int numv = mesh.numVertices();
    for (int i = 0; i < numv; i++) {
        Vertex3d vtx = mesh.getVertex(i);
        Point3d pos = useRenderData ? vtx.myRenderPnt : vtx.pnt;
        r.setPosition(i, (float) pos.x, (float) pos.y, (float) pos.z);
    }
}
Also used : Point3d(maspack.matrix.Point3d)

Example 67 with Point3d

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

the class NURBSCurve2d method evalPoints.

/**
 * Returns a set of points evaluated along the curve at intervals which are
 * evenly spaced with respect to the curve parameter.
 *
 * @param npnts
 * number of points to create
 * @return array of evaluated points
 */
public Point2d[] evalPoints(int npnts) {
    Point2d[] pnts = new Point2d[npnts];
    Point3d pnt3 = new Point3d();
    if (npnts == 1) {
        eval(pnt3, myUstart);
        pnts[0] = new Point2d(pnt3.x, pnt3.y);
    }
    for (int i = 0; i < npnts; i++) {
        eval(pnt3, myUstart + (myUend - myUstart) * i / (npnts - 1));
        pnts[i] = new Point2d(pnt3.x, pnt3.y);
    }
    return pnts;
}
Also used : Point2d(maspack.matrix.Point2d) Point3d(maspack.matrix.Point3d)

Example 68 with Point3d

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

the class NURBSCurve3d method findPoint.

/**
 * Finds a u value for a given curve point within a specified interval of the
 * curve. If the point is not actually on the specified interval, this
 * routine attempts to return the u value for the nearest curve point. It
 * should be noted that one point may correspond to multiple u values.
 *
 * <p>
 * This routine uses an iterative golden section search, and so is not
 * particularly fast.
 *
 * @param pnt
 * point to search for
 * @param umin
 * minimum u valu for the interval
 * @param umax
 * maximum u valu for the interval
 * @return u value for the point closest to pnt within the interval.
 */
public double findPoint(Point3d pnt, double umin, double umax) {
    double[] dist = new double[1];
    double[] uinterval = new double[3];
    if (bracket(dist, uinterval, pnt, umin, umax)) {
        return golden(dist, uinterval, pnt, dist[0]);
    } else {
        Point3d pntu = new Point3d();
        eval(pntu, umin);
        double dmin = pntu.distance(pnt);
        eval(pntu, umax);
        double dmax = pntu.distance(pnt);
        return (dmin < dmax ? umin : umax);
    }
}
Also used : Point3d(maspack.matrix.Point3d)

Example 69 with Point3d

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

the class NURBSCurve3d method evalPoints.

/**
 * Returns a set of points evaluated along the curve at intervals which are
 * evenly spaced with respect to the curve parameter.
 *
 * @param npnts
 * number of points to create
 * @return array of evaluated points
 */
public Point3d[] evalPoints(int npnts) {
    Point3d[] pnts = new Point3d[npnts];
    if (npnts == 1) {
        pnts[0] = new Point3d();
        eval(pnts[0], myUstart);
    }
    for (int i = 0; i < npnts; i++) {
        pnts[i] = new Point3d();
        eval(pnts[i], myUstart + (myUend - myUstart) * i / (npnts - 1));
    }
    return pnts;
}
Also used : Point3d(maspack.matrix.Point3d)

Example 70 with Point3d

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

the class NURBSCurveBase method render.

/**
 * {@inheritDoc}
 */
public void render(Renderer renderer, RenderProps props, int flags) {
    boolean selecting = renderer.isSelecting();
    int numc = numControlPoints();
    if (numc == 0) {
        return;
    }
    renderer.pushModelMatrix();
    if (myXObjToWorld != RigidTransform3d.IDENTITY) {
        RigidTransform3d XOW = new RigidTransform3d(myXObjToWorld);
        renderer.mulModelMatrix(XOW);
    }
    renderer.setShading(Shading.NONE);
    if (myDrawControlShapeP) {
        // draw the control polygon
        if (props.getDrawEdges()) {
            renderer.setLineWidth(props.getEdgeWidth());
            if (!selecting) {
                renderer.setColor(props.getEdgeOrLineColorF());
            }
            if (myClosedP) {
                renderer.beginDraw(DrawMode.LINE_LOOP);
            } else {
                renderer.beginDraw(DrawMode.LINE_STRIP);
            }
            for (int i = 0; i < numc; i++) {
                Vector4d cpnt = myCtrlPnts.get(i);
                renderer.addVertex(cpnt.x, cpnt.y, cpnt.z);
            }
            renderer.endDraw();
        }
        // draw the control points
        drawControlPoints(renderer, props, flags);
    }
    // draw the curve itself
    if (!selecting) {
        renderer.setColor(props.getLineColorF());
    }
    double len = computeControlPolygonLength();
    double res = myResolution * renderer.distancePerPixel(myXObjToWorld.p);
    int nsegs = (int) Math.max(10, len / res);
    Point3d pnt = new Point3d();
    renderer.setLineWidth(props.getLineWidth());
    renderer.beginDraw(DrawMode.LINE_LOOP);
    double[] urange = new double[2];
    getRange(urange);
    for (int i = 0; i < nsegs + 1; i++) {
        eval(pnt, urange[0] + (urange[1] - urange[0]) * i / nsegs);
        renderer.addVertex(pnt);
    }
    renderer.endDraw();
    renderer.setLineWidth(1);
    renderer.setShading(Shading.FLAT);
    renderer.popModelMatrix();
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) Vector4d(maspack.matrix.Vector4d) Point3d(maspack.matrix.Point3d)

Aggregations

Point3d (maspack.matrix.Point3d)464 Vector3d (maspack.matrix.Vector3d)128 ArrayList (java.util.ArrayList)59 RigidTransform3d (maspack.matrix.RigidTransform3d)48 Vertex3d (maspack.geometry.Vertex3d)35 Point (artisynth.core.mechmodels.Point)30 PolygonalMesh (maspack.geometry.PolygonalMesh)30 Face (maspack.geometry.Face)25 ReaderTokenizer (maspack.util.ReaderTokenizer)19 IOException (java.io.IOException)18 RotationMatrix3d (maspack.matrix.RotationMatrix3d)17 Vector2d (maspack.matrix.Vector2d)16 VectorNd (maspack.matrix.VectorNd)16 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)15 HashMap (java.util.HashMap)14 Muscle (artisynth.core.mechmodels.Muscle)13 FemNode3d (artisynth.core.femmodels.FemNode3d)12 Particle (artisynth.core.mechmodels.Particle)12 BufferedReader (java.io.BufferedReader)11 Plane (maspack.matrix.Plane)11