Package java.awt.geom

Examples of java.awt.geom.Point2D.distance()


      for (int i = 1; i < points.length - 1; i++)
      {
        if (clickPoint.distance(points[i]) < minDist)
        {
          pos = i;
          minDist = clickPoint.distance(points[i]);
        }
      }
      if (pos != -1 && minDist < 10)
      {
        return true;
View Full Code Here


      EdgeView edge = (EdgeView) view;
      Point2D last = null, current = null;
      for (int i = 0; i < edge.getPointCount(); i++) {
        current = edge.getPoint(i);
        if (last != null)
          cost += last.distance(current);
        last = current;
      }
    }
    return cost;
  }
View Full Code Here

        double[] p2 = new double[]{b.P1.getX(), b.P1.getY()};
        double[] p3 = b.cp1();
        Point2D p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], true);
        if( p == null || insideP == null )
          a.add(new LineSegment(a.last.P2, b.P1));
        else if((p.distance(insideP)/width) < limit)
          {
            a.add(new LineSegment(a.last.P2, p));
            a.add(new LineSegment(p, b.P1));
          }
        else
View Full Code Here

     */
    private static void makeCornerTo(GeneralPath gp, Point2D cornerPoint, Point2D nextCornerPoint, float radius) {
        Point2D currentPoint = gp.getCurrentPoint();

        //get fractional to the corner where the line first starts to curve
        double distance = currentPoint.distance(cornerPoint);
        double fraction = (distance - radius) / distance;

        //calculate these distance from the current point
        double xDistance = (cornerPoint.getX() - currentPoint.getX()) * fraction;
        double yDistance = (cornerPoint.getY() - currentPoint.getY()) * fraction;
 
View Full Code Here

            intersection = bisectorA_B.intersectionPoint(bisectorA_C);
            i++;
        } while (intersection == null);               
       
        //radius is the distance to the three points (which is hopefully the same!)       
        double radius = intersection.distance(a.getCoordinate().x, a.getCoordinate().y);
               
        //convert from center-radius to the java format
        Ellipse2D.Double circle = new Ellipse2D.Double(intersection.getX()-radius,
                                                       intersection.getY()-radius,
                                                       2*radius,
 
View Full Code Here

      EdgeView edge = (EdgeView) view;
      Point2D last = null, current = null;
      for (int i = 0; i < edge.getPointCount(); i++) {
        current = edge.getPoint(i);
        if (last != null)
          cost += last.distance(current);
        last = current;
      }
    }
    return cost;
  }
View Full Code Here

     */
    private double distance(final Point2D index, final AffineTransform tr) {
        try {
            Point2D geoCoord = transform(index, null);
            geoCoord = tr.inverseTransform(geoCoord, geoCoord);
            return geoCoord.distance(index);
        } catch (TransformException exception) {
            // Should not happen
            throw new AssertionError(exception);
        } catch (NoninvertibleTransformException exception) {
            // Not impossible. What should we do? Open question...
View Full Code Here

    public static Ellipse2D fitCircle(final Point2D P1, final Point2D P2, final Point2D P3)
    {
        final Point2D center = circleCentre(P1.getX(), P1.getY(),
                                            P2.getX(), P2.getY(),
                                            P3.getX(), P3.getY());
        final double radius = center.distance(P2);
        return new Ellipse2D.Double(center.getX()-radius,
                                    center.getY()-radius,
                                    2*radius, 2*radius);
    }

View Full Code Here

                double intensity = field.values[i][j];

                // Fade out at edges of trefoil.
                //intensity = intensity * Rippler.dampen(p.distance(trefoilMidpoint), rippleDissipation * 3);
                intensity = intensity * dissipateFieldOfView(p.distance(trefoilMidpoint));

                intensity = intensify(intensity, 3);
                if (intensity < 0) {
                    intensity = 0;
                }
View Full Code Here

            for (int j = 0; j < field.width; j++) {
                Point2D p = new Point2D.Double(
                        field.virtualY(i),
                        field.virtualX(j));

                double dist = p.distance(center);

                field.values[i][j] += intensity * waveFunc(dist);
            }
        }
    }
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.