Java Geometry Polygon polyArea(Polygon target)

Here you can find the source of polyArea(Polygon target)

Description

poly Area

License

Open Source License

Declaration

public static int polyArea(Polygon target) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Polygon;

public class Main {
    public static int polyArea(Polygon target) {
        int sum = 0;
        for (int i = 0; i < target.npoints; i++) {
            sum = sum + target.xpoints[i] * target.ypoints[(i + 1) % target.npoints]
                    - target.ypoints[i] * target.xpoints[(i + 1) % target.npoints];
        }/*from   w w w  . j a  v a 2  s  .  c  o m*/

        return Math.abs(sum / 2);
    }
}

Related

  1. boundingTest(Polygon p, int x, int y, int w, int h)
  2. inside_polygon(float[] xpts, float[] ypts, double ptx, double pty)
  3. makeArea(Polygon polygon, int steps, int dX, int dY)
  4. regularPolygon(int sides, double x, double y, double width, double height)
  5. sparsifyPolygon(java.awt.Polygon p, double minDistance)