get Average Angle from GeneralPath - Java 2D Graphics

Java examples for 2D Graphics:Path

Description

get Average Angle from GeneralPath

Demo Code


import java.awt.geom.PathIterator;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Line2D;
import java.awt.Point;

public class Main{
    public static double getAverageAngle(GeneralPath path) {
        double seg[] = new double[6];
        PathIterator pi = path.getPathIterator(null);
        int segType = pi.currentSegment(seg);

        return GeoUtils.getAngle(seg[0], seg[1], path.getCurrentPoint()
                .getX(), path.getCurrentPoint().getY());
    }/* w w  w . j a v  a2s .  com*/
}

Related Tutorials