/** * Get the rotation of a body. * @param b b * * @return pointer to a 4x3 rotation matrix. */ //ODE_API //const public static DMatrix3C dBodyGetRotation (DBody b){ return b.getRotation(); }
/** * Get the rotation of a body. * @param b b * * @return pointer to a 4x3 rotation matrix. */ //ODE_API //const public static DMatrix3C dBodyGetRotation (DBody b){ return b.getRotation(); }
/** * Copy the rotation of a body. * * @param b the body to query * @param R a copy of the rotation matrix * @see #dBodyGetRotation(DBody) */ //ODE_API public static void dBodyCopyRotation (DBody b, DMatrix3 R){ R.set(b.getRotation()); }
/** * Copy the rotation of a body. * * @param b the body to query * @param R a copy of the rotation matrix * @see #dBodyGetRotation(DBody) */ //ODE_API public static void dBodyCopyRotation (DBody b, DMatrix3 R){ R.set(b.getRotation()); }
void draw() { dsDrawBox(body.getPosition(), body.getRotation(), sides); } };
@Override public void step(boolean pause) { if (!pause) { expStep(expGyroBody); world.step(dt); } dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor(1,0,0); dsDrawBox(noGyroBody.getPosition(), noGyroBody.getRotation(), sides); dsSetColor(1,1,0); dsDrawBox(expGyroBody.getPosition(), expGyroBody.getRotation(), sides); dsSetColor(0,1,0); dsDrawBox(impGyroBody.getPosition(), impGyroBody.getRotation(), sides); }
private void simLoop (boolean pause) { dsSetColor (0,0,2); space.collide(0,nearCallback); if (!pause) { //world.quickStep(0.02); world.step(0.02); } // remove all contact joints contactgroup.empty(); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor (1,0.5f,0); dsDrawCylinder(top1.getPosition(), top1.getRotation(), toplength, topradius); dsDrawCapsule(top1.getPosition(), top1.getRotation(), pinlength, pinradius); dsSetColor (0.5f,1,0); dsDrawCylinder(top2.getPosition(), top2.getRotation(), toplength, topradius); dsDrawCapsule(top2.getPosition(), top2.getRotation(), pinlength, pinradius); }
private void simLoop (boolean pause) { OdeHelper.spaceCollide (space,0,nearCallback); if (!pause) { world.quickStep (0.01); // 100 Hz } contactgroup.empty (); dsSetColorAlpha (1f,1f,0f,0.5f); dsDrawCylinder ( cylbody.getPosition(), cylbody.getRotation(), CYLLENGTH, CYLRADIUS ); dsDrawSphere ( sphbody.getPosition(), sphbody.getRotation(), SPHERERADIUS ); }
top1.getRotation(), toplength, topradius); dsDrawCapsule(top1.getPosition(), top1.getRotation(), pinlength, pinradius); top2.getRotation(), toplength, topradius); dsDrawCapsule(top2.getPosition(), top2.getRotation(), pinlength, pinradius);
private static void simLoop (boolean pause) { if (!pause) { OdeHelper.spaceCollide(space,null,nearCallback); world.quickStep (0.05); contactgroup.empty (); } DVector3C sides1 = geom[0].getLengths(); DVector3C sides2 = geom[1].getLengths(); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor (1,1,0); dsDrawBox (body[0].getPosition(), body[0].getRotation(), sides1); dsSetColor (0,1,1); dsDrawBox (body[1].getPosition(), body[1].getRotation(), sides2); }
@Override public void step (boolean pause) { int i; if (!pause) { //static double angle = 0; angle += 0.05; body[NUM-1].addForce(0,0,1.5*(Math.sin(angle)+1.0)); space.collide(0,myNearCallback); world.step(0.05); /* remove all contact joints */ contactgroup.empty(); } dsSetColor (1,1,0); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); for (i=0; i<NUM; i++) dsDrawSphere (body[i].getPosition(), body[i].getRotation(),RADIUS); }
@Override public void step (boolean pause) { if (!pause) { // static double angle = 0; angle += 0.05; body[NUM-1].addForce (0,0,1.5*(Math.sin(angle)+1.0)); space.collide (0,nearCallback); world.step (0.05); // remove all contact joints contactgroup.empty(); } DVector3 sides = new DVector3(SIDE,SIDE,SIDE); dsSetColor (1,1,0); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); for (int i=0; i<NUM; i++) dsDrawBox (body[i].getPosition(),body[i].getRotation(),sides); }
DVector3 sides3 = new DVector3(3*SIDE,3*SIDE,3*SIDE); dsSetColor (1,1,1); dsDrawBox (anchor_body.getPosition(), anchor_body.getRotation(), sides3); dsSetColor (1,0,0); dsDrawBox (test_body.getPosition(), test_body.getRotation(), sides2); dsSetColor (1,1,0); for (int i=0; i<NUM; i++) dsDrawBox (particle[i].getPosition (), particle[i].getRotation (), sides);
@Override public void step (boolean pause) { if (!pause) { // static double angle = 0; angle += 0.05; body[NUM-1].addForce (0,0,1.5*(sin(angle)+1.0)); space.collide (0,nearCallback); world.step (0.05); // remove all contact joints contactgroup.empty(); } DVector3 sides = new DVector3(SIDE,SIDE,SIDE); dsSetColor (1,1,0); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); for (int i=0; i<NUM; i++) dsDrawBox (body[i].getPosition(),body[i].getRotation(),sides); }
DMatrix3C srot = sphbody.getRotation(); dsDrawSphere ( spos, srot, RADIUS );
DMatrix3C srot = sphbody.getRotation(); dsDrawSphere ( spos, srot, RADIUS );
R1 = body[0].getRotation (); dRFromAxisAndAngle (R2,dRandReal()-0.5,dRandReal()-0.5, dRandReal()-0.5,dRandReal()-0.5); dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); dsSetColor (1,1,0); dsDrawBox (body[0].getPosition(),body[0].getRotation(),sides1); dsSetColor (0,1,1); dsDrawBox (body[1].getPosition(),body[1].getRotation(),sides2);
dsSetTexture (DS_TEXTURE_NUMBER.DS_WOOD); DVector3 sides = new DVector3(LENGTH,WIDTH,HEIGHT); dsDrawBox (body[0].getPosition(), body[0].getRotation(), sides); dsSetColor (1,1,1); for (i=1; i<=3; i++) dsDrawCylinder (body[i].getPosition(), body[i].getRotation(),0.02f,RADIUS);
@Override public void step (boolean pause) { if (!pause) { // add random forces and torques to all bodies int i; final double scale1 = 5; final double scale2 = 5; for (i=0; i<NUM; i++) { body[i].addForce ( scale1*(dRandReal()*2-1), scale1*(dRandReal()*2-1), scale1*(dRandReal()*2-1)); body[i].addTorque ( scale2*(dRandReal()*2-1), scale2*(dRandReal()*2-1), scale2*(dRandReal()*2-1)); } world.step (0.05); createTest(); } // float sides[3] = {SIDE,SIDE,SIDE}; dsSetColor (1,1,0); for (int i=0; i<NUM; i++) dsDrawSphere (body[i].getPosition(), body[i].getRotation(), RADIUS); }
/** * This is the explicit computation of * gyroscopic forces. */ private static void expStep(DBody body) { // Explicit computation DMatrix3 I = new DMatrix3(), tmp = new DMatrix3(); DMassC m = body.getMass(); DMatrix3C R = body.getRotation(); // compute inertia tensor in global frame OdeMath.dMultiply2_333 (tmp,m.getI(),R); OdeMath.dMultiply0_333 (I,R,tmp); // compute explicit rotational force // we treat 'tmp'like a vector, but that's okay. DVector3C w = body.getAngularVel(); OdeMath.dMultiply0_331 (tmp,I,w); DVector3 tau = new DVector3(); DVector3 tmp2 = new DVector3(tmp.get00(), tmp.get01(), tmp.get02()); OdeMath.dCalcVectorCross3(tau,tmp2,w); body.addTorque(tau); }