Here you can find the source of circle2poly(float x, float y, float radius)
public static Polygon circle2poly(float x, float y, float radius)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html ******************************************************************************/ import java.awt.Polygon; public class Main { public static Polygon circle2poly(float x, float y, float radius) { float dphi = 2.0f / radius; int nangles = (int) ((2.0f * (float) Math.PI) / dphi); int[] xpts = new int[nangles]; int[] ypts = new int[nangles]; for (int i = 0; i < nangles; i++) { float phi = dphi * i; xpts[i] = (int) (radius * (float) Math.cos(phi) + x); ypts[i] = (int) (radius * (float) Math.sin(phi) + y); }//from w ww.ja v a 2 s .c o m return new Polygon(xpts, ypts, nangles); } }