Example usage for java.awt.geom Point2D getY

List of usage examples for java.awt.geom Point2D getY

Introduction

In this page you can find the example usage for java.awt.geom Point2D getY.

Prototype

public abstract double getY();

Source Link

Document

Returns the Y coordinate of this Point2D in double precision.

Usage

From source file:Main.java

/** Determines the maximum y-coordinate for the set of points.
 * @param points//from   w  w  w  . j a  va2  s  .  c  o m
 * @return the maximum y-coordinate of the points
 */
public static double maxY(Point2D[] points) {
    double maxY = Double.MIN_VALUE;
    for (Point2D point : points) {
        if (point.getY() > maxY) {
            maxY = point.getY();
        }
    }
    return maxY;
}

From source file:Main.java

private static double extractAngle(AffineTransform at) {
    Point2D p0 = new Point();
    Point2D p1 = new Point(1, 0);
    Point2D pp0 = at.transform(p0, null);
    Point2D pp1 = at.transform(p1, null);
    double dx = pp1.getX() - pp0.getX();
    double dy = pp1.getY() - pp0.getY();
    double angle = Math.atan2(dy, dx);
    return angle;
}

From source file:Main.java

/** Does linear interpolation at x of the line from pt1 to pt2.
 * @param pt1 one endpoint of the line./*from  www  . j  a  va2 s  .c  om*/
 * @param pt2 another endpoint of the line.
 * @param x the x-coordinate of the interpolated point.
 * @return the desired interpolated point.
 */
public static Point2D interpolate(Point2D pt1, Point2D pt2, double x) {
    double slope = (pt2.getY() - pt1.getY()) / (pt2.getX() - pt1.getX());
    double y = pt1.getY() + (x - pt1.getX()) * slope;
    return new Point2D.Double(x, y);
}

From source file:FindHullWindowLogic.java

static private boolean areTheSamePoints(Point2D p1, Point2D p2) {
    if (p1.getX() == p2.getX() && p1.getY() == p2.getY())
        return true;
    else//w ww  .j  a  va 2  s . c o  m
        return false;
}

From source file:MonteCarloWindowLogic.java

static private void convertArrayListToXYSeries(XYSeries seriesDestination, ArrayList<Point2D> arrListFrom) {
    for (Point2D onePoint : arrListFrom) {
        seriesDestination.add(onePoint.getX(), onePoint.getY());
    }/*  www  .ja  va 2 s.c  o  m*/
}

From source file:Utils.java

public static Shape generatePolygon(int sides, int outsideRadius, int insideRadius) {

    if (sides < 3) {
        return new Ellipse2D.Float(0, 0, 10, 10);
    }/*from  w ww .j a va  2 s  .  co  m*/

    AffineTransform trans = new AffineTransform();
    Polygon poly = new Polygon();
    for (int i = 0; i < sides; i++) {
        trans.rotate(Math.PI * 2 / (float) sides / 2);
        Point2D out = trans.transform(new Point2D.Float(0, outsideRadius), null);
        poly.addPoint((int) out.getX(), (int) out.getY());
        trans.rotate(Math.PI * 2 / (float) sides / 2);
        if (insideRadius > 0) {
            Point2D in = trans.transform(new Point2D.Float(0, insideRadius), null);
            poly.addPoint((int) in.getX(), (int) in.getY());
        }
    }

    return poly;
}

From source file:GeometryUtilities.java

public static boolean isBetween(Point2D a, Point2D b, Point2D c) {
    double u = c.getX() - a.getX();
    double v = c.getY() - a.getY();
    double tx = (b.getX() - a.getX()) / u;
    double ty = (b.getY() - a.getY()) / v;

    return (tx > 0 && tx < 1) || (ty > 0 && ty < 1);
}

From source file:Main.java

/** Interpolates the given x onto the line of points.
 * @param points//  ww w .  j a v a 2 s . c  o m
 * @param x
 * @return x interpolated onto the line defined by the points
 */
public static Point2D interpolate(Point2D[] points, double x) {
    // determine the two point boundaries for the line segment
    for (int i = 0; i < points.length - 1; i++) {
        Point2D pt1 = points[i];
        Point2D pt2 = points[i + 1];
        if (x == pt1.getX())
            return new Point2D.Double(pt1.getX(), pt1.getY());
        else if (x < pt2.getX())
            return interpolate(pt1, pt2, x);
    }

    // if we reach here, then x >= the last point
    Point2D pt1 = points[points.length - 2];
    Point2D pt2 = points[points.length - 1];
    if (x == pt2.getX())
        return new Point2D.Double(pt2.getX(), pt2.getY());
    else
        return interpolate(pt1, pt2, x);
}

From source file:FindHullWindowLogic.java

static private void addPointsToSeries(XYSeries seriesDestination) {
    for (Point2D onePoint : importedPointsFromPointsReader) {
        seriesDestination.add(onePoint.getX(), onePoint.getY());
    }//from w ww  . j  a  v a 2  s.  co m
}

From source file:org.jcurl.mr.exp.gui.MouseSketchPanel.java

private static void circle(Graphics g, Point2D c, int r) {
    final int x = (int) c.getX();
    final int y = (int) c.getY();
    final int d = 2 * r;
    g.drawArc(x - r, y - r, d, d, 0, 360);
}