Java examples for java.lang:Math Geometry Shape
create Polygon From Function
//package com.java2s; import java.awt.Polygon; import java.util.function.BiFunction; public class Main { public static Polygon createPolygonFromFunction( BiFunction<double[], double[], Void> fx, int steps, double width, double height, double[] tmp, double tmp2[]) { Polygon polygon = new Polygon(); double dX = width / steps; for (int i = 0; i < steps; ++i) { tmp[0] = i;/*from w w w .j a v a2 s . c o m*/ tmp2[0] = dX * i; fx.apply(tmp, tmp2); double val = tmp[0] * height / 2; polygon.addPoint((int) (dX * i), (int) (height / 2 - val)); } return polygon; } }