class PArc2D { java.awt.geom.Arc2D arc2D; PArc2D(float x, float y, float w, float a, float e) { // x, y : center // w : width // a : direction (point at) in radians // e : extent angle in radians arc2D = new java.awt.geom.Arc2D.Float(x-w/2, y-w/2, w, w, degrees(-a-e), degrees(e*2), java.awt.geom.Arc2D.PIE); } void setXY(float x, float y) { arc2D.setArcByCenter((double)x, (double)y, arc2D.getWidth()/2, arc2D.getAngleStart(), arc2D.getAngleExtent(), java.awt.geom.Arc2D.PIE); } void setAngle(float a) { arc2D.setAngleStart(-degrees(a) - arc2D.getAngleExtent()/2); } void turn(float ra) { arc2D.setAngleStart(arc2D.getAngleStart() - degrees(ra)); } void display() { float x = (float)arc2D.getX(); float y = (float)arc2D.getY(); float w = (float)arc2D.getWidth(); float as = -radians((float)arc2D.getAngleStart()); float ae = radians((float)arc2D.getAngleExtent()); arc(x + w/2, y + w/2, w, w, as - ae, as); } boolean contains(float x, float y) { return arc2D.contains(x, y); } }