Package org.openpnp.model

Examples of org.openpnp.model.Point


 
    return point;
  }
 
  public static Point translatePoint(Point point, double x, double y) {
    return new Point(point.getX() + x, point.getY() + y);
  }
View Full Code Here


    double yn = x * Math.sin(c) + y * Math.cos(c);
   
    x = xn;
    y = yn;
   
    return new Point(x, y);
  }
View Full Code Here

   
    return new Point(x, y);
  }
 
  public static Point scalePoint(Point point, double scaleX, double scaleY) {
    return new Point(point.getX() * scaleX, point.getY() * scaleY);
  }
 
View Full Code Here

        if (bl.getSide() == Side.Bottom) {
            placementLocation = placementLocation.invert(true, false, false, false);
        }

        // Create the point that represents the final placement location
        Point p = new Point(placementLocation.getX(),
                placementLocation.getY());

        // Rotate and translate the point into the same coordinate space
        // as the board
        p = Utils2D.rotateTranslateScalePoint(p, boardLocation
                .getRotation(), boardLocation.getX(), boardLocation
                .getY(), 1.0, 1.0);

        // Update the placementLocation with the transformed point
        placementLocation = placementLocation.derive(p.getX(), p.getY(), null, null);

        // Update the placementLocation with the board's rotation and
        // the placement's rotation
        // This sets the rotation of the part itself when it will be
        // placed
View Full Code Here

    // is rotated by.
    double angleCD = indicatedAngle - expectedAngle ;  // this is the rotation angle to be done
    logger.debug("angle C-D " + angleCD);
   

    Point center = new Point(centerX/2,centerY/2)// This is the center point of the four board used for rotation

   
    double dxAB = 0, dxCD = 0, dxMP = 0;
    double dyAB = 0, dyCD = 0, dyMP = 0;


    // Now we do binary search n-times between AngleAB and AngleCD to find lowest error
    // This is up to as good as we want, I prefer for-loop than while-loop.
    for(int i = 0; i< 50;++i)
    {
        // use angleAB to calculate the displacement necessary to get placementLocation to boardLocation.
        // Each point will have slightly different value.
        // Then we can tell the error resulted from using this angleAB.
        Point A = new Point(placementLocationA.getX(),placementLocationA.getY());
        A = Utils2D.rotateTranslateCenterPoint(A, angleAB,0,0,center);

        Point B = new Point(placementLocationB.getX(),placementLocationB.getY());
        B = Utils2D.rotateTranslateCenterPoint(B, angleAB,0,0,center);

        Point C = new Point(placementLocationC.getX(),placementLocationC.getY());
        C = Utils2D.rotateTranslateCenterPoint(C, angleAB,0,0,center);


        Point D = new Point(placementLocationD.getX(),placementLocationD.getY());
        D = Utils2D.rotateTranslateCenterPoint(D, angleAB,0,0,center);

        double dA = (boardLocationA.getX() - A.getX());
        double dB = (boardLocationB.getX() - B.getX());
        double dC = (boardLocationC.getX() - C.getX());
        double dD = (boardLocationD.getX() - D.getX());

        // Take the average of the four
        dxAB = (dA + dB + dC + dD)/4;
        double errorAB = Math.abs(dxAB- dA) + Math.abs(dxAB- dB) + Math.abs(dxAB- dC) + Math.abs(dxAB- dD);

         dA = (boardLocationA.getY() - A.getY());
         dB = (boardLocationB.getY() - B.getY());
         dC = (boardLocationC.getY() - C.getY());
         dD = (boardLocationD.getY() - D.getY());

        // Take the average of the four
        dyAB = (dA + dB + dC + dD)/4;
        errorAB += Math.abs(dyAB- dA) + Math.abs(dyAB- dB) + Math.abs(dyAB- dC) + Math.abs(dyAB- dD); // Accumulate the error


        // Now do the same using angleCD, find the error caused by angleCD
         A = new Point(placementLocationA.getX(),placementLocationA.getY());
        A = Utils2D.rotateTranslateCenterPoint(A, angleCD,0,0,center);

         B = new Point(placementLocationB.getX(),placementLocationB.getY());
        B = Utils2D.rotateTranslateCenterPoint(B, angleCD,0,0,center);

         C = new Point(placementLocationC.getX(),placementLocationC.getY());
        C = Utils2D.rotateTranslateCenterPoint(C, angleCD,0,0,center);

         D = new Point(placementLocationD.getX(),placementLocationD.getY());
        D = Utils2D.rotateTranslateCenterPoint(D, angleCD,0,0,center);

         dA = (boardLocationA.getX() - A.getX());
         dB = (boardLocationB.getX() - B.getX());
         dC = (boardLocationC.getX() - C.getX());
         dD = (boardLocationD.getX() - D.getX());

        // Take the average of the four
        dxCD = (dA + dB + dC + dD)/4;
        double errorCD = Math.abs(dxCD- dA) + Math.abs(dxCD- dB) + Math.abs(dxCD- dC) + Math.abs(dxCD- dD);

         dA = (boardLocationA.getY() - A.getY());
         dB = (boardLocationB.getY() - B.getY());
         dC = (boardLocationC.getY() - C.getY());
         dD = (boardLocationD.getY() - D.getY());

        // Take the average of the four
        dyCD = (dA + dB + dC + dD)/4;
        errorCD += Math.abs(dyCD- dA) + Math.abs(dyCD- dB) + Math.abs(dyCD- dC) + Math.abs(dyCD- dD); // Accumulate the error


        // Now take the mid-point between the two angles,
        // and do the same math
        double angleMP = (angleAB + angleCD)/2// MP = mid-point angle between angleAB and angleCD
        double deltaAngle = Math.abs(angleAB - angleCD);

        A = new Point(placementLocationA.getX(),placementLocationA.getY());
        A = Utils2D.rotateTranslateCenterPoint(A, angleMP,0,0,center);

         B = new Point(placementLocationB.getX(),placementLocationB.getY());
        B = Utils2D.rotateTranslateCenterPoint(B, angleMP,0,0,center);

         C = new Point(placementLocationC.getX(),placementLocationC.getY());
        C = Utils2D.rotateTranslateCenterPoint(C, angleMP,0,0,center);

         D = new Point(placementLocationD.getX(),placementLocationD.getY());
        D = Utils2D.rotateTranslateCenterPoint(D, angleMP,0,0,center);

         dA = (boardLocationA.getX() - A.getX());
         dB = (boardLocationB.getX() - B.getX());
         dC = (boardLocationC.getX() - C.getX());
         dD = (boardLocationD.getX() - D.getX());

        // Take the average of the four
         dxMP = (dA + dB + dC + dD)/4;
         double errorMP = Math.abs(dxMP- dA) + Math.abs(dxMP- dB) + Math.abs(dxMP- dC) + Math.abs(dxMP- dD);

         dA = (boardLocationA.getY() - A.getY());
         dB = (boardLocationB.getY() - B.getY());
         dC = (boardLocationC.getY() - C.getY());
         dD = (boardLocationD.getY() - D.getY());

        // Take the average of the four
        dyMP = (dA + dB + dC + dD)/4;
        errorMP += Math.abs(dyMP- dA) + Math.abs(dyMP- dB) + Math.abs(dyMP- dC) + Math.abs(dyMP- dD); // Accumulate the error
View Full Code Here

        if (bl.getSide() == Side.Bottom) {
          placementLocation = placementLocation.invert(true, false, false, false);
        }

        // Create the point that represents the final placement location
        Point p = new Point(placementLocation.getX(),
            placementLocation.getY());

        // Rotate and translate the point into the same coordinate space
        // as the board
        p = Utils2D.rotateTranslateScalePoint(p, boardLocation
            .getRotation(), boardLocation.getX(), boardLocation
            .getY(), 1.0, 1.0);

        // Update the placementLocation with the transformed point
        placementLocation = placementLocation.derive(p.getX(), p.getY(), null, null);

        // Update the placementLocation with the board's rotation and
        // the placement's rotation
        // This sets the rotation of the part itself when it will be
        // placed
View Full Code Here

      Location ntOffset = this.nozzleOffsets; //nozzle tip offset from xml file
      Location calculatedOffset = null; //new calculated offset


      // Create the point that represents the nozzle tip offsets (stored offset always for angle zero)
    Point nt_p = new Point(ntOffset.getX(), ntOffset.getY());

      // Rotate and translate the point into the same rotational coordinate space as the new location
    // use point derived from offsets stored in xml
    Point new_p = Utils2D.rotatePoint(nt_p, location.getRotation());

    //calculate actual (not the change in) new offset. this is used to calibrate camera head-offset
    calculatedOffset = location.derive(new_p.getX(), new_p.getY(), 0.0, null);

   
      //log calculated offsets
        logger.debug("{}.moveTo( stored_off {})", new Object[] { id, ntOffset } );
        logger.debug("{}.moveTo( calculated_off {})", new Object[] { id, calculatedOffset } );
View Full Code Here

TOP

Related Classes of org.openpnp.model.Point

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.