Examples of Line


Examples of net.helipilot50.stocktrade.displayproject.controls.Line

            int lineStyle, int lineWeight) {
        setForm(form);
        java.awt.Point loc = location(startX, startY);
        int H = loc.x + distHorizontal;
        int V = loc.y + distVertical;
        Line line = GraphicFactory.newLine(loc.x, loc.y, H, V);
        line.setLineStyle(lineStyle);
        line.setLineWeight(lineWeight);
        line.setVisible(true);
        ColourChange.setForeground(line, penColor);
        Parent.set(line, form);
        processActions();
        setXPen(form, loc.x + distHorizontal);
        setYPen(form, loc.y + distVertical);
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body land = new StaticBody("Line1", new Line(190,0));
    land.setPosition(50,400);
    world.add(land);
    Body land2 = new StaticBody("Box1", new Box(190,10));
    land2.setPosition(350,405);
    world.add(land2);
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

   *
   * @param g The graphics context on which to draw
   * @param body The body to be rendered
   */
  protected void drawLineBody(Graphics2D g, Body body) {
    Line line = (Line) body.getShape();

    g.setColor(Color.gray);
    drawAABody(g,body,body.getShape().getBounds());
   
    g.setColor(Color.black);
    float xp = body.getPosition().getX();
    float yp = body.getPosition().getY();
   
    g.drawLine((int) (xp + line.getX1()),(int) (yp + line.getY1()),
           (int) (xp + line.getX2()),(int) (yp + line.getY2()));

  }
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body body1 = new StaticBody("Ground1", new Line(-300.0f, 0, false, true));
    body1.setPosition(400, 300);
    world.add(body1);
    Body body3 = new StaticBody("Ground2", new Line(0,50, false, true));
    body3.setPosition(100, 301);
    world.add(body3);
   
    body2 = new Body("Mover1", new Box(40,40), 10.0f);
    body2.setPosition(150.0f, 280.0f);
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

  /**
   * @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) {
    Line line = (Line) bodyA.getShape();
    Circle circle = (Circle) bodyB.getShape();
   
    Vector2f[] vertsA = line.getVertices(bodyA.getPosition(), bodyA.getRotation());
   
    // compute intersection of the line A and a line parallel to
    // the line A's normal passing through the origin of B
    Vector2f startA = vertsA[0];
    Vector2f endA = vertsA[1];
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

  /**
   * @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) {
    Line line = (Line) bodyA.getShape();
    Polygon poly = (Polygon) bodyB.getShape();
   
    // TODO: this can be optimized using matrix multiplications and moving only one shape
    // specifically the line, because it has only two vertices
    Vector2f[] vertsA = line.getVertices(bodyA.getPosition(), bodyA.getRotation());
    Vector2f[] vertsB = poly.getVertices(bodyB.getPosition(), bodyB.getRotation());

    Vector2f pos = poly.getCentroid(bodyB.getPosition(), bodyB.getRotation());
   
    // using the z axis of a 3d cross product we determine on what side B is
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

      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();
       
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body land = new StaticBody("Line1", new Line(130,30));
    land.setPosition(-30,200);
    world.add(land);
    Body land2 = new StaticBody("Line2", new Line(50,50));
    land2.setPosition(100,230);
    world.add(land2);
    Body land3 = new StaticBody("Line3", new Line(100,20));
    land3.setPosition(150,280);
    world.add(land3);
    Body land4 = new StaticBody("Line4", new Line(100,80));
    land4.setPosition(250,300);
    world.add(land4);
    Body land5 = new StaticBody("Line5", new Line(100,0));
    land5.setPosition(350,380);
    world.add(land5);
    Body land6 = new StaticBody("Line6", new Line(10,-200));
    land6.setPosition(450,380);
    world.add(land6);
    Body land7 = new StaticBody("Line7", new Line(80,-10));
    land7.setPosition(460,180);
    world.add(land7);
   
    box = new Body("Faller", new Box(50,50), 1);
    box.setPosition(50,50);
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

   * @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) {
    int numContacts = 0;
   
    Line line = (Line) bodyA.getShape();
    Box box = (Box) bodyB.getShape();
   
    Vector2f lineVec = new Vector2f(line.getDX(), line.getDY());
    lineVec.normalise()
    Vector2f axis = new Vector2f(-line.getDY(), line.getDX());
    axis.normalise();
   
    Vector2f res = new Vector2f();
    line.getStart().projectOntoUnit(axis, res);
    float linePos = getProp(res,axis);
   
    Vector2f c = MathUtil.sub(bodyB.getPosition(),bodyA.getPosition());
    c.projectOntoUnit(axis,res);
    float centre = getProp(res, axis);
   
    Vector2f[] pts = box.getPoints(bodyB.getPosition(), bodyB.getRotation());
    float[] tangent = new float[4];
    float[] proj = new float[4];
   
    int outOfRange = 0;
   
    for (int i=0;i<4;i++) {
      pts[i].sub(bodyA.getPosition());
      pts[i].projectOntoUnit(axis, res);
      tangent[i] = getProp(res, axis);
      pts[i].projectOntoUnit(lineVec, res);
      proj[i] = getProp(res, new Vector2f(line.getDX(), line.getDY()));
     
      if ((proj[i] >= 1) || (proj[i] <= 0)) {
        outOfRange++;
      }
    }
    if (outOfRange == 4) {
      return 0;
    }
   
    Vector2f normal = new Vector2f(axis);
   
    if (centre < linePos) {
      if (!line.blocksInnerEdge()) {
        return 0;
      }
     
      normal.scale(-1);
      for (int i=0;i<4;i++) {
        if (tangent[i] > linePos) {
          if (proj[i] < 0) {
            Vector2f onAxis = new Vector2f();
            Line leftLine = new Line(getPt(pts,i-1),pts[i]);
            Line rightLine = new Line(getPt(pts,i+1),pts[i]);
            leftLine.getClosestPoint(line.getStart(),res);
            res.projectOntoUnit(axis, onAxis);
            float left = getProp(onAxis, axis);
            rightLine.getClosestPoint(line.getStart(),res);
            res.projectOntoUnit(axis, onAxis);
            float right = getProp(onAxis, axis);
           
            if ((left > 0) && (right > 0)) {
              Vector2f pos = new Vector2f(bodyA.getPosition());
              pos.add(line.getStart());
             
              resolveEndPointCollision(pos,bodyA,bodyB,normal,leftLine,rightLine,contacts[numContacts],i);
              numContacts++;
            }
          } else if (proj[i] > 1) {
            Vector2f onAxis = new Vector2f();
            Line leftLine = new Line(getPt(pts,i-1),pts[i]);
            Line rightLine = new Line(getPt(pts,i+1),pts[i]);
            leftLine.getClosestPoint(line.getEnd(),res);
            res.projectOntoUnit(axis, onAxis);
            float left = getProp(onAxis, axis);
            rightLine.getClosestPoint(line.getEnd(),res);
            res.projectOntoUnit(axis, onAxis);
            float right = getProp(onAxis, axis);
           
            if ((left > 0) && (right > 0)) {
              Vector2f pos = new Vector2f(bodyA.getPosition());
              pos.add(line.getEnd());

              resolveEndPointCollision(pos,bodyA,bodyB,normal,leftLine,rightLine,contacts[numContacts],i);
              numContacts++;
            }
          } else {
            pts[i].projectOntoUnit(lineVec, res);
            res.add(bodyA.getPosition());
            contacts[numContacts].setSeparation(-(tangent[i]-linePos));
            contacts[numContacts].setPosition(new Vector2f(res));
            contacts[numContacts].setNormal(normal);
            contacts[numContacts].setFeature(new FeaturePair(i))
            numContacts++;
          }
        }
      }
    } else {
      if (!line.blocksOuterEdge()) {
        return 0;
      }
     
      for (int i=0;i<4;i++) {
        if (tangent[i] < linePos) {
          if (proj[i] < 0) {
            Vector2f onAxis = new Vector2f();
            Line leftLine = new Line(getPt(pts,i-1),pts[i]);
            Line rightLine = new Line(getPt(pts,i+1),pts[i]);
            leftLine.getClosestPoint(line.getStart(),res);
            res.projectOntoUnit(axis, onAxis);
            float left = getProp(onAxis, axis);
            rightLine.getClosestPoint(line.getStart(),res);
            res.projectOntoUnit(axis, onAxis);
            float right = getProp(onAxis, axis);
           
            if ((left < 0) && (right < 0)) {
              Vector2f pos = new Vector2f(bodyA.getPosition());
              pos.add(line.getStart());

              resolveEndPointCollision(pos,bodyA,bodyB,normal,leftLine,rightLine,contacts[numContacts],i);
              numContacts++;
            }
          } else if (proj[i] > 1) {
            Vector2f onAxis = new Vector2f();
            Line leftLine = new Line(getPt(pts,i-1),pts[i]);
            Line rightLine = new Line(getPt(pts,i+1),pts[i]);
            leftLine.getClosestPoint(line.getEnd(),res);
            res.projectOntoUnit(axis, onAxis);
            float left = getProp(onAxis, axis);
            rightLine.getClosestPoint(line.getEnd(),res);
            res.projectOntoUnit(axis, onAxis);
            float right = getProp(onAxis, axis);
           
            if ((left < 0) && (right < 0)) {
              Vector2f pos = new Vector2f(bodyA.getPosition());
View Full Code Here

Examples of net.phys2d.raw.shapes.Line

    Vector2f end = new Vector2f(start);
    end.add(norm);
   
    rightLine.move(bodyA.getPosition());
    leftLine.move(bodyA.getPosition());
    Line normLine = new Line(start,end);
    Vector2f rightPoint = normLine.intersect(rightLine);
    Vector2f leftPoint = normLine.intersect(leftLine);
   
    float dis1 = Float.MAX_VALUE;
    if (rightPoint != null) {
      dis1 = rightPoint.distance(start) - norm.length();
    }
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.