get Min in Polygon - Java 2D Graphics

Java examples for 2D Graphics:Polygon

Description

get Min in Polygon

Demo Code


//package com.java2s;
import java.awt.Point;
import java.awt.Polygon;

public class Main {
    public static Point getMin(Polygon poly) {
        Point p = new Point(poly.xpoints[0], poly.ypoints[0]);
        for (int i = 0; i < poly.npoints; i++) {
            if (poly.xpoints[i] < p.x) {
                p.x = poly.xpoints[i];/*from w  w w .j a  v a  2 s  .  c om*/
            }
            if (poly.ypoints[i] < p.y) {
                p.y = poly.ypoints[i];
            }
        }
        return p;
    }
}

Related Tutorials