Examples of AngleJoint


Examples of net.phys2d.raw.AngleJoint

      g.drawLine((int)p1.x,(int)p1.y,(int)(p1.x+im.x*joint.getMinDistance()),(int)(p1.y+im.y*joint.getMinDistance()));
      g.setColor(Color.blue);
      g.drawLine((int)(p1.x+im.x*joint.getMinDistance()),(int)(p1.y+im.y*joint.getMinDistance()),(int)(p1.x+im.x*joint.getMaxDistance()),(int)(p1.y+im.y*joint.getMaxDistance()));
    }
    if(j instanceof AngleJoint){
      AngleJoint angleJoint = (AngleJoint)j;
      Body b1 = angleJoint.getBody1();
      Body b2 = angleJoint.getBody2();
      float RA = j.getBody1().getRotation() + angleJoint.getRotateA();
      float RB = j.getBody1().getRotation() + angleJoint.getRotateB();
     
      Vector2f VA = new Vector2f((float) Math.cos(RA), (float) Math.sin(RA));
      Vector2f VB = new Vector2f((float) Math.cos(RB), (float) Math.sin(RB));
     
      Matrix2f R1 = new Matrix2f(b1.getRotation());
      Matrix2f R2 = new Matrix2f(b2.getRotation());
     
      ROVector2f x1 = b1.getPosition();
      Vector2f p1 = MathUtil.mul(R1,angleJoint.getAnchor1());
      p1.add(x1);
 
      ROVector2f x2 = b2.getPosition();
      Vector2f p2 = MathUtil.mul(R2,angleJoint.getAnchor2());
      p2.add(x2);
     
      g.setColor(Color.red);
      g.drawLine((int)p1.x,(int)p1.y,(int)(p1.x+VA.x*20),(int)(p1.y+VA.y*20));
      g.drawLine((int)p1.x,(int)p1.y,(int)(p1.x+VB.x*20),(int)(p1.y+VB.y*20));
 
View Full Code Here

Examples of net.phys2d.raw.AngleJoint

      world.add(b2);
     
      bodies[i]=b2;
    }
   
    final AngleJoint aj1 = new AngleJoint(b1,bodies[0],new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f,-0.0f);
    //AngleJoint aj1 = new AngleJoint(b1,bodies[0],new Vector2f(),new Vector2f(),0.0f,-0.0f);
    final DistanceJoint dj1 = new DistanceJoint(b1,bodies[0],new Vector2f(),new Vector2f(),30);
    final AngleJoint aja2 = new AngleJoint(bodies[0],b1,new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f+(float)Math.PI,(float)Math.PI);
    world.add(aja2);
    world.add(dj1);
    world.add(aj1);
    for(int i=1;i<N;i++){
      final AngleJoint aj = new AngleJoint(bodies[i-1],bodies[i],new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f,-0.0f);
      world.add(aj);
     
      final AngleJoint aj2 = new AngleJoint(bodies[i],bodies[i-1],new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f+(float)(Math.PI+Math.sin(i/10.0f)),(float)(Math.PI+Math.sin(i/10.0f)));
      world.add(aj2);
     
      final DistanceJoint dj = new DistanceJoint(bodies[i-1],bodies[i],new Vector2f(),new Vector2f(),30);
      world.add(dj);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.