Examples of Circle


Examples of net.phys2d.raw.shapes.Circle

    boolean touches = bodyA.getShape().getBounds().touches(x1,y1,bodyB.getShape().getBounds(),x2,y2);
    if (!touches) {
      return 0;
    }
   
    Circle circleA = (Circle) bodyA.getShape();
    Circle circleB = (Circle) bodyB.getShape();
   
    touches = circleA.touches(x1,y1,circleB,x2,y2);
    if (!touches) {
      return 0;
    }
   
    Vector2f normal = MathUtil.sub(bodyB.getPosition(),bodyA.getPosition());
    float sep = (circleA.getRadius() + circleB.getRadius()) - normal.length();

    normal.normalise();
    Vector2f pt = MathUtil.scale(normal, circleA.getRadius());
    pt.add(bodyA.getPosition());
View Full Code Here

Examples of net.phys2d.raw.shapes.Circle

  /**
   * @see net.phys2d.raw.collide.Collider#collide(net.phys2d.raw.Contact[], net.phys2d.raw.Body, net.phys2d.raw.Body)
   */
  public int collide(Contact[] contacts, Body bodyA, Body bodyB) {
    Polygon polyA = (Polygon) bodyA.getShape();
    Circle circle = (Circle) bodyB.getShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only the circle
    Vector2f[] vertsA = polyA.getVertices(bodyA.getPosition(), bodyA.getRotation());
   
    Vector2f centroidA = new Vector2f(polyA.getCentroid());
    centroidA.add(bodyA.getPosition());

   
    int[][] collPairs = getCollisionCandidates(vertsA, centroidA, circle.getRadius(), bodyB.getPosition());

    int noContacts = 0;
    for ( int i = 0; i < collPairs.length; i++ ) {
      if ( noContacts >= contacts.length )
        return contacts.length;
     
      Vector2f lineStartA = vertsA[collPairs[i][0]];
      Vector2f lineEndA = vertsA[(collPairs[i][0]+1) % vertsA.length ];
      Line line = new Line(lineStartA, lineEndA);
           
      float dis2 = line.distanceSquared(bodyB.getPosition());
      float r2 = circle.getRadius() * circle.getRadius();

      if ( dis2 < r2 ) {
        Vector2f pt = new Vector2f();
       
        line.getClosestPoint(bodyB.getPosition(), pt);
        Vector2f normal = new Vector2f(bodyB.getPosition());
        normal.sub(pt);
        float sep = circle.getRadius() - normal.length();
        normal.normalise();
       
        contacts[noContacts].setSeparation(-sep);
        contacts[noContacts].setPosition(pt);
        contacts[noContacts].setNormal(normal);
View Full Code Here

Examples of net.phys2d.raw.shapes.Circle

   
    box = new Body("Faller", new Box(50,50), 1);
    box.setPosition(50,50);
    box.setRotation(-0.5f);
    world.add(box);
    Body other = new Body("Faller", new Circle(10), 1);
    other.setPosition(200,50);
    other.setRotation(-0.5f);
    world.add(other);
    other = new Body("Faller", new Circle(10), 1);
    other.setPosition(225,50);
    other.setRotation(-0.5f);
    world.add(other);
    other = new Body("Faller", new Circle(10), 1);
    other.setPosition(250,50);
    other.setRotation(-0.5f);
    world.add(other);
    other = new Body("Faller", new Circle(10), 1);
    other.setPosition(275,50);
    other.setRotation(-0.5f);
    world.add(other);
    other = new Body("Faller", new Circle(10), 1);
    other.setPosition(300,50);
    other.setRotation(-0.5f);
    world.add(other);
  }
View Full Code Here

Examples of net.phys2d.raw.shapes.Circle

 
  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    b1= new Body(new Circle(15),1e3f);
    b1.setMoveable(false);
    b1.setPosition(250,250);
    b1.setRotDamping(10);
    b1.setRotation(0.01f);
   
    world.add(b1);
    final int N=15;
    final Body bodies[] = new Body[N];
    for(int i=0;i<N;i++){
      final Body b2 = new Body(new Circle(8),10);
      b2.setPosition(250+30*(1+i),250);
      world.add(b2);
     
      bodies[i]=b2;
    }
 
View Full Code Here

Examples of net.phys2d.raw.shapes.Circle

  protected void init(World world) {
    world.setGravity(0,0);
   
    for (int y=0;y<4;y++) {
      for (int x=0;x<y+1;x++) {
        Body body1 = new Body("Ball"+x+","+y, new Circle(20.0f), 1);
        //Body body1 = new Body("Ball"+x+","+y, new Box(40.0f,40.0f), 1);
        body1.setPosition(250.0f+(x*40)-(y*20), 200+(y*35f));
        body1.setRestitution(1.0f);
        body1.setFriction(0);
        world.add(body1);
      }
    }

    Body body5 = new StaticBody("Ground1", new Box(20.0f, 500.0f));
    body5.setPosition(20.0f, 250);
    body5.setRestitution(1.0f);
    world.add(body5);
    Body body6 = new StaticBody("Ground2", new Box(20.0f, 500.0f));
    body6.setPosition(480.0f, 250);
    body6.setRestitution(1.0f);
    world.add(body6);
    Body body1 = new StaticBody("Ground3", new Box(500.0f, 20.0f));
    body1.setPosition(250.0f, 480);
    body1.setRestitution(1.0f);
    world.add(body1);
   
    Body body2 = new Body("Cue", new Circle(20.0f),1);
    //Body body2 = new Body("Cue", new Box(40.0f,40.0f),1);
    body2.setPosition(250,0);
    body2.adjustVelocity(new Vector2f(0,100));
    body2.setRestitution(1.0f);
    body2.setFriction(0);
View Full Code Here

Examples of net.phys2d.raw.shapes.Circle

   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body[] bodies = new Body[5];
    for (int x=0;x<4;x++) {
      bodies[x] = new Body("Ball"+x, new Circle(20.0f), 1);
      bodies[x].setPosition(220.0f+(x*20), 200+(x*40f));
      bodies[x].setRestitution(1.0f);
      world.add(bodies[x]);
    }
    for (int x=0;x<4;x++) {
View Full Code Here

Examples of net.phys2d.raw.shapes.Circle

    if (!touches) {
      return 0;
    }
   
    Box box = (Box) boxBody.getShape();
    Circle circle = (Circle) circleBody.getShape();
   
    Vector2f[] pts = box.getPoints(boxBody.getPosition(), boxBody.getRotation());
    Line[] lines = new Line[4];
    lines[0] = new Line(pts[0],pts[1]);
    lines[1] = new Line(pts[1],pts[2]);
    lines[2] = new Line(pts[2],pts[3]);
    lines[3] = new Line(pts[3],pts[0]);
   
    float r2 = circle.getRadius() * circle.getRadius();
    int closest = -1;
    float closestDistance = Float.MAX_VALUE;
   
    for (int i=0;i<4;i++) {
      float dis = lines[i].distanceSquared(circleBody.getPosition());
      if (dis < r2) {
        if (closestDistance > dis) {
          closestDistance = dis;
          closest = i;
        }
      }
    }
   
    if (closest > -1) {
      float dis = (float) Math.sqrt(closestDistance);
      contacts[0].setSeparation(dis - circle.getRadius());
     
      // this should really be where the edge and the line
      // between the two elements cross?
      Vector2f contactPoint = new Vector2f();
      lines[closest].getClosestPoint(circleBody.getPosition(), contactPoint);
View Full Code Here

Examples of net.wigis.graph.dnv.geometry.Circle

    {
      for( Geometric g : graph.getGeometricObjects( level ) )
      {
        if( g instanceof Circle )
        {
          Circle c = (Circle)g;
          c.setCenter( (float)( c.getCenter().getX() * xRatio ), (float)( c.getCenter().getY() * yRatio ) );
        }
        else if( g instanceof Rectangle )
        {
          Rectangle r = (Rectangle)g;
          r.setBottomRight( (float)( r.getBottomRight().getX() * xRatio ), (float)( r.getBottomRight().getY() * yRatio ) );
View Full Code Here

Examples of org.eclipse.sapphire.samples.gallery.Circle

            {
                final int x = Integer.parseInt( segments[ 0 ].trim() );
                final int y = Integer.parseInt( segments[ 1 ].trim() );
                final int radius = Integer.parseInt( segments[ 2 ].trim() );
               
                return new Circle( x, y, radius );
            }
            catch( NumberFormatException e )
            {
                // Intentionally ignored.
            }
View Full Code Here

Examples of org.eluder.coveralls.maven.plugin.service.Circle

     */
    protected List<ServiceSetup> getServices() {
        Map<String, String> env = System.getenv();
        List<ServiceSetup> services = new ArrayList<ServiceSetup>();
        services.add(new Travis(env));
        services.add(new Circle(env));
        services.add(new Jenkins(env));
        services.add(new Bamboo(env));
        services.add(new General(env));
        return services;
    }
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.