Search in sources :

Example 36 with AxisAngle

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

the class RotAxisFrameMaterial method computeF.

public void computeF(Wrench wr, RigidTransform3d X21, Twist vel21, RigidTransform3d initialX21) {
    Vector3d p = X21.p;
    wr.f.x = myK.x * p.x;
    wr.f.y = myK.y * p.y;
    wr.f.z = myK.z * p.z;
    AxisAngle axisAng = new AxisAngle();
    X21.R.getAxisAngle(axisAng);
    wr.m.scale(myRotK * axisAng.angle, axisAng.axis);
    Vector3d v = vel21.v;
    Vector3d w = vel21.w;
    wr.f.x += myD.x * v.x;
    wr.f.y += myD.y * v.y;
    wr.f.z += myD.z * v.z;
    wr.m.scaledAdd(myRotD, w);
}
Also used : AxisAngle(maspack.matrix.AxisAngle) Vector3d(maspack.matrix.Vector3d)

Example 37 with AxisAngle

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

the class FemMuscleArm method addFemMuscle.

public void addFemMuscle(Point3d upper, Point3d lower) throws IOException {
    upperArm = model.rigidBodies().get("upper");
    RigidBody lowerArm = model.rigidBodies().get("lower");
    if (upperArm == null || lowerArm == null) {
        return;
    }
    muscle = new PointToPointMuscle("muscle", 1.0, 0.85, "muscle", true);
    model.addModel(muscle);
    RigidTransform3d X = new RigidTransform3d();
    // Point3d upper = new Point3d(2.4, 0, 20), lower = new Point3d(3, 0, -7);
    FemNode3d first = muscle.getFirstNode(), last = muscle.getLastNode();
    double scale = (upper.distance(lower) / first.getPosition().distance(last.getPosition()));
    System.out.println(scale);
    AffineTransform3d scaling = new AffineTransform3d();
    scaling.setIdentity();
    scaling.applyScaling(scale, scale, scale);
    // muscle.transformGeometry(scaling);
    Vector3d translate = new Vector3d();
    translate.sub(upper, first.getPosition());
    muscle.transformGeometry(new RigidTransform3d(translate, new AxisAngle()));
    Vector3d offfem = new Vector3d(), offtarget = new Vector3d();
    offfem.sub(last.getPosition(), first.getPosition());
    offtarget.sub(lower, upper);
    double angle = offfem.angle(offtarget);
    offfem.cross(offtarget);
    muscle.transformGeometry(new RigidTransform3d(new Vector3d(-upper.x, -upper.y, -upper.z), new AxisAngle()));
    muscle.transformGeometry(new RigidTransform3d(upper, new AxisAngle(offfem, angle)));
    muscle.getFirstNode().setDynamic(false);
    // ant.getFirstNode().setPosition(new Point3d(2.381, 0.000, 20));
    // model.AttachPoint(ant.getFirstNode(),upperArm,new Point3d(-size.x,0,-(size.z/2.0)/1.2));
    model.attachPoint(muscle.getLastNode(), lowerArm);
    muscle.setMaxForce(300000);
    muscle.setExcitation(0.0);
    RenderProps rp = new RenderProps(model.getRenderProps());
    rp.setFaceColor(Color.RED);
    rp.setLineStyle(Renderer.LineStyle.LINE);
    rp.setPointStyle(Renderer.PointStyle.POINT);
    rp.setShading(Renderer.Shading.SMOOTH);
    rp.setLineColor(Color.WHITE);
    muscle.setRenderProps(rp);
    muscle.setSurfaceRendering(SurfaceRender.Shaded);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) AxisAngle(maspack.matrix.AxisAngle) Vector3d(maspack.matrix.Vector3d) FemNode3d(artisynth.core.femmodels.FemNode3d) RenderProps(maspack.render.RenderProps) PointToPointMuscle(artisynth.core.femmodels.PointToPointMuscle) RigidBody(artisynth.core.mechmodels.RigidBody) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 38 with AxisAngle

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

the class RootModel method setDefaultValues.

@Override
public void setDefaultValues() {
    super.setDefaultValues();
    myDefaultViewOrientation = new AxisAngle(DEFAULT_VIEW_ORIENTATION);
}
Also used : AxisAngle(maspack.matrix.AxisAngle)

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