Package org.ode4j.math

Examples of org.ode4j.math.DVector3


      ParCollection params) {
   
    if (currentSimTime.getLastTick() == 0) {
      Snake snake = new Snake(0, env, params, 16);
      env.addAgent(snake);
      lastPos = new DVector3(snake.getPosition());
      System.out.println("");
      System.out.println("");
      System.out.println("Use the number keys to start different motion patterns.");
      snake.setMotionInclinedSideWinding(40, 2);
    }
View Full Code Here


   */
  @Override
  public void runBeforeSimulation(CurlingEnv env, ParCollection params) {   
    env.setMu(0.001);
   
    DVector3 position = new DVector3(0,40,5);
    BumperAgent bumper = new BumperAgent(0, env, params, position);
    env.addAgent(bumper);
   
    position = new DVector3(0,33,5);
    PuckAgent puck = new PuckAgent(1, env, params, position);
    env.addAgent(puck);
   
    float[] xyz = new float[] {0,-6,6};
    float[] hpr = new float[] {90,-30,0};   
View Full Code Here

    if (currentSimTime.getLastTick() == 1) {
      for (int i = 0; i < 2; i++) {
        System.out.println();
      }
      System.out.println("Use the arrow keys to steer the puck... Have fun!");
      env.getAgent(0).getBody(0).addForce(new DVector3(0, -5000, 0));
      env.getAgent(0).getBody(0).addTorque(0, 0, Math.random()*50);
    }
   
    distance = 0;
    distance += env.getAgent(1).getBody(0).getPosition().get0() * env.getAgent(1).getBody(0).getPosition().get0();
 
View Full Code Here

      DVector3C prePos;
      if (node.getPredecessor() != null) {
        prePos = node.getPredecessor().getContent().getBody().getPosition();
      }
      else {
        prePos = new DVector3(0, 0, 10);
      }
      DVector3 relPos = bp.getPosition();
      DVector3 size = bp.getSize();
      DVector3 newPos;
      if (node.getPredecessor() == null) {
        newPos = new DVector3(
            prePos.get0(),
            prePos.get1(),
            prePos.get2());
      }
      else {
        newPos = new DVector3(
            prePos.get0() + relPos.get0()*size.get0()/2,
            prePos.get1() + relPos.get1()*size.get1()/2,
            prePos.get2() + relPos.get2()*size.get2()/2);
      }
      DBody b = OdeHelper.createBody(env.getWorld());
      bp.setBody(b);
      DGeom g = OdeHelper.createBox(
          env.getSpace(),
          size.get0(),
          size.get1(),
          size.get2());
      b.setPosition(newPos);
      g.setBody(b);
      DMass mass = OdeHelper.createMass();
      mass.setBox(
          1,
          bp.getSize().get0(),
          bp.getSize().get1(),
          bp.getSize().get2());
      b.setMass(mass);
     
      lowestHeight = Math.min(lowestHeight,b.getPosition().get2()-size.get2()/2);     
      bodies.add(b);
      masses.add(mass);
      geoms.add(g);
    }
   
    // Move close to ground
    Iterator<DBody> itb = bodies.iterator();
    while (itb.hasNext()) {
      DBody b = itb.next();
      DVector3 newPos = b.getPosition().clone();
      newPos.set2(b.getPosition().get2()-lowestHeight*.99);
      b.setPosition(newPos);
      System.out.println(b.getPosition());
    }
   
   
 
View Full Code Here

  public GOAgent1(int id, GOEnv1 env, ParCollection params) {
    super(id, env, params);
    this.geoms = new DGeom[1];
    this.bodies = new DBody[1];
    bodies[0] = OdeHelper.createBody(env.getWorld());
    bodies[0].setPosition(new DVector3(1, 0, 10));
    geoms[0] = OdeHelper.createBox(1, 1, 1);
    geoms[0].setBody(bodies[0]);
  }
View Full Code Here

    for (int i = 0; i < len; i++) {
      x += bodies[i].getPosition().get0();
      y += bodies[i].getPosition().get1();
      z += bodies[i].getPosition().get2();
    }
    DVector3 vec = new DVector3(x/len, y/len, z/len);
    return vec;
  }
View Full Code Here

      DVector3C pos = iter.next().getPosition();
      x += pos.get0();
      y += pos.get1();
      z += pos.get2();
    }
    DVector3 vec = new DVector3(x/size, y/size, z/size);
    return vec;
  }
View Full Code Here

  public void setBounceVel (double bounce_vel) {
    this.bounce_vel = bounce_vel;
  }
 
  public void setGravity(double gravity) {
    DVector3 grav = new DVector3(0, 0, gravity);
    this.setGravity(grav);
  }
View Full Code Here

        DVector3C vec0 = bodies[i][j].getPosition();
        DVector3C vec1 = bodies[i + 1][j].getPosition();
        DVector3C vec2 = bodies[i][j + 1].getPosition();
        DVector3C vec3 = bodies[i + 1][j + 1].getPosition();

        DVector3C temp1 = new DVector3(vec1.get0() - vec0.get0(),
            vec1.get1() - vec0.get1(), vec1.get2() - vec0.get2());
        DVector3C temp2 = new DVector3(vec2.get0() - vec0.get0(),
            vec2.get1() - vec0.get1(), vec2.get2() - vec0.get2());

        DVector3C temp3 = new DVector3(vec1.get0() - vec2.get0(),
            vec1.get1() - vec2.get1(), vec1.get2() - vec2.get2());
        DVector3C temp4 = new DVector3(vec3.get0() - vec2.get0(),
            vec3.get1() - vec2.get1(), vec3.get2() - vec2.get2());

        DVector3C normal = new DVector3(temp1.get1() * temp2.get2()
            - temp1.get2() * temp2.get1(), temp1.get2()
            * temp2.get0() - temp1.get0() * temp2.get2(),
            temp1.get0() * temp2.get1() - temp1.get1()
                * temp2.get0());
        DVector3C normal2 = new DVector3(temp3.get1() * temp4.get2()
            - temp3.get2() * temp4.get1(), temp3.get2()
            * temp4.get0() - temp3.get0() * temp4.get2(),
            temp3.get0() * temp4.get1() - temp3.get1()
                * temp4.get0());

        DVector3C norm0 = normal.clone();
        DVector3C norm1 = normal.clone();
        DVector3C norm2 = normal.clone();
        DVector3C norm3 = normal.clone();

        norm1 = new DVector3(norm1.get0() + normal2.get0(),
            norm1.get1() + normal2.get1(), norm1.get2()
                + normal2.get2());
        norm2 = new DVector3(norm2.get0() + normal2.get0(),
            norm2.get1() + normal2.get1(), norm2.get2()
                + normal2.get2());
        norm3 = new DVector3(norm3.get0() + normal2.get0(),
            norm3.get1() + normal2.get1(), norm3.get2()
                + normal2.get2());

        GL11.glNormal3d(norm0.get0(), norm0.get1(), norm0.get2());
        GL11.glVertex3d(vec0.get0(), vec0.get1(), vec0.get2());
        GL11.glNormal3d(norm1.get0(), norm1.get1(), norm1.get2());
        GL11.glVertex3d(vec1.get0(), vec1.get1(), vec1.get2());
View Full Code Here

TOP

Related Classes of org.ode4j.math.DVector3

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.