Search in sources :

Example 16 with AxisAngle

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

the class FemCollision method reset.

void reset() {
    double r1 = rand.nextDouble();
    double r2 = rand.nextDouble();
    double r3 = rand.nextDouble();
    // case001: the blue ball has a very strange wobbling experience partly
    // inside the table, just after touching the red ball.
    r1 = 0.9339890095435555;
    r2 = 0.256644068300397;
    r3 = 0.005600826760283728;
    positionBall(fem0, new Vector3d(0.1, 0.1, 10 + r3 * 2));
    positionBall(fem1, testEdgeEdge ? new Vector3d(0, 0, 6) : new Vector3d(0, 0, 2));
    if (box0 != null) {
        box0.setPose(new RigidTransform3d(new Vector3d(-0.5, r1 * 0.2, 3.0 + r2), new AxisAngle()));
        box0.setVelocity(0, 0, 0, 0, 0, 0);
    }
    System.out.println("r1=" + r1 + "; r2=" + r2 + "; r3=" + r3 + ";");
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) AxisAngle(maspack.matrix.AxisAngle) Vector3d(maspack.matrix.Vector3d)

Example 17 with AxisAngle

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

the class FemCollision method positionBall.

void positionBall(FemModel3d ball, Vector3d startPos) {
    if (ball == null)
        return;
    Vector3d avg = new Vector3d();
    for (FemNode3d n : ball.getNodes()) avg.add(n.getPosition());
    avg.scale(1 / (double) ball.getNodes().size());
    Vector3d pos = new Vector3d(startPos);
    pos.sub(avg);
    ball.transformGeometry(new RigidTransform3d(pos, new AxisAngle()));
    for (FemNode3d n : ball.getNodes()) {
        n.setVelocity(0, 0, 0);
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) AxisAngle(maspack.matrix.AxisAngle) Vector3d(maspack.matrix.Vector3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 18 with AxisAngle

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

the class RigidBodyCollision method reset.

void reset() {
    System.out.println("Reset");
    double q = (rand.nextDouble() - 0.5) * 2;
    double q1 = (rand.nextDouble() - 0.5) * 0.2;
    double q2 = (rand.nextDouble() - 0.5) * 0.2;
    double q3 = rand.nextDouble();
    double t = rand.nextDouble();
    double t1 = rand.nextDouble();
    double t2 = rand.nextDouble();
    double t3 = rand.nextDouble();
    double t1a = rand.nextDouble();
    double t2a = rand.nextDouble();
    double t3a = rand.nextDouble();
    q = 0.24457661495520133;
    q1 = 0.07143622990642744;
    q2 = -0.09679961441554841;
    q3 = 0.147067025570912;
    t = 0.4178296424474287;
    t1 = 0.6413202748594918;
    t2 = 0.0721263882620764;
    t3 = 0.8925255651397567;
    t1a = 0.4168287232167902;
    t2a = 0.2168593863506586;
    t3a = 0.4951442499550106;
    double twist = t * 4;
    if (box0 != null) {
        box0.setPose(new RigidTransform3d(new Vector3d(-3 + q, 0.0, 2.05), new AxisAngle(0, 0, 0, 0)));
        box0.setVelocity(0, 0, 0, 0, 0, 0);
    }
    if (box1 != null) {
        box1.setPose(new RigidTransform3d(new Vector3d(-4.3135585102416233 + q, 0.0, 1.44), new AxisAngle(0.5794, -0.5763, -0.5763, Math.toRadians(119.824))));
        box1.setVelocity(0, 0, 0, 0, 0, 0);
    }
    if (box2 != null) {
        box2.setPose(new RigidTransform3d(new Vector3d(-6 + q + q1, 0.0, 5.05), new AxisAngle(0, 0, 0, 0)));
        box2.setVelocity(0, 0, 0, twist * t1, twist * t2, twist * t3);
    }
    if (box3 != null) {
        box3.setPose(new RigidTransform3d(new Vector3d(-3.2 + q + q1 + q2, 0.0, 3.05), new AxisAngle(0, 0, 0, 0)));
        box3.setVelocity(0, 0, 0, 0, 0, 0);
    }
    if (box4 != null) {
        box4.setPose(new RigidTransform3d(new Vector3d(1, 0.0, 2 + /* 5 */
        q3), new AxisAngle(0, 0, 0, 0)));
        box4.setVelocity(0, 0, 0, twist * t1a, twist * t2a, twist * t3a);
    }
// // This prints a line of java code that can be copied from the log and
// pasted above to recreate a specific starting configuration.
// System.out.println(
// "q="+q+"; q1="+q1+"; q2="+q2+"; q3="+q3+"; t="+t+"; t1="+t1+"; t2="+t2+"; t3="+t3+"; t1a="+t1a+"; t2a="+t2a+"; t3a="+t3a+";"
// );
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) AxisAngle(maspack.matrix.AxisAngle) Vector3d(maspack.matrix.Vector3d)

Example 19 with AxisAngle

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

the class MultiViewerTesterBase method addCylinder.

protected static void addCylinder(MultiViewer tester) {
    // cylinder
    RenderObject cylinderRO = RenderObjectFactory.createCylinder(32, true);
    RenderObjectWrapper rcylinder = new RenderObjectWrapper(cylinderRO);
    AffineTransform3d cscale = new AffineTransform3d();
    cscale.setTranslation(0.3, 0.3, 0);
    cscale.setRotation(new AxisAngle(1d / Math.sqrt(2), -1d / Math.sqrt(2), 0, Math.PI / 8));
    cscale.applyScaling(0.05, 0.05, 1.0);
    rcylinder.setTransform(cscale);
    RenderProps rprops2 = rcylinder.getRenderProps();
    rprops2.setFaceColor(Color.CYAN);
    rprops2.setShading(Shading.SMOOTH);
    tester.addRenderable(rcylinder);
}
Also used : AxisAngle(maspack.matrix.AxisAngle) RenderProps(maspack.render.RenderProps) RenderObject(maspack.render.RenderObject) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 20 with AxisAngle

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

the class AxisAngleField method main.

public static void main(String[] args) {
    JFrame frame = new JFrame("AxisAngleField Test");
    LabeledComponentPanel panel = new LabeledComponentPanel();
    AxisAngleField widget = new AxisAngleField();
    frame.getContentPane().add(panel);
    RotationMatrix3d R = new RotationMatrix3d(1, 0, 0, Math.toRadians(45));
    widget.setValue(new AxisAngle(R));
    panel.addWidget("axisAng", widget);
    // panel.addWidget (widget);
    frame.pack();
    frame.setVisible(true);
}
Also used : AxisAngle(maspack.matrix.AxisAngle) JFrame(javax.swing.JFrame) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Aggregations

AxisAngle (maspack.matrix.AxisAngle)38 Vector3d (maspack.matrix.Vector3d)19 RigidTransform3d (maspack.matrix.RigidTransform3d)18 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Point3d (maspack.matrix.Point3d)7 RotationMatrix3d (maspack.matrix.RotationMatrix3d)7 AffineTransform3d (maspack.matrix.AffineTransform3d)5 RigidBody (artisynth.core.mechmodels.RigidBody)4 MechModel (artisynth.core.mechmodels.MechModel)3 Font (java.awt.Font)3 File (java.io.File)3 IOException (java.io.IOException)3 GLViewer (maspack.render.GL.GLViewer)3 FemNode3d (artisynth.core.femmodels.FemNode3d)2 CollisionManager (artisynth.core.mechmodels.CollisionManager)2 HashMap (java.util.HashMap)2 JFrame (javax.swing.JFrame)2 RenderProps (maspack.render.RenderProps)2 ReaderTokenizer (maspack.util.ReaderTokenizer)2 AxisAngleField (maspack.widgets.AxisAngleField)2