Here you can find the source of getAngleForPoint(Arc2D arc, int x, int y)
public static double getAngleForPoint(Arc2D arc, int x, int y)
//package com.java2s; /*/* w w w . j a v a 2s.c om*/ * Copyright (c) Leuville Objects All Rights Reserved. * * Leuville Objects MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Leuville Objects SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import java.awt.geom.*; public class Main { public static double getAngleForPoint(Arc2D arc, int x, int y) { double px = x - arc.getCenterX(); double py = arc.getCenterY() - y; double d = Math.sqrt(px * px + py * py); double a1 = Math.toDegrees(Math.acos(px / d)); double a2 = Math.toDegrees(Math.asin(py / d)); if (a2 < 0) { if (a1 > 90) return 360 - a1; else return -a1; } else return a1; } }