/** * Sets the starting angle and angular extent of this arc using two sets of coordinates. The * first set of coordinates is used to determine the angle of the starting point relative to * the arc's center. The second set of coordinates is used to determine the angle of the end * point relative to the arc's center. The arc will always be non-empty and extend * counterclockwise from the first point around to the second point. */ public void setAngles (float x1, float y1, float x2, float y2) { float cx = centerX(); float cy = centerY(); float a1 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y1 - cy, x1 - cx))); float a2 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y2 - cy, x2 - cx))); a2 -= a1; if (a2 <= 0f) { a2 += 360f; } setAngleStart(a1); setAngleExtent(a2); }
/** * Sets the starting angle and angular extent of this arc using two sets of coordinates. The * first set of coordinates is used to determine the angle of the starting point relative to * the arc's center. The second set of coordinates is used to determine the angle of the end * point relative to the arc's center. The arc will always be non-empty and extend * counterclockwise from the first point around to the second point. */ public void setAngles (float x1, float y1, float x2, float y2) { float cx = centerX(); float cy = centerY(); float a1 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y1 - cy, x1 - cx))); float a2 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y2 - cy, x2 - cx))); a2 -= a1; if (a2 <= 0f) { a2 += 360f; } setAngleStart(a1); setAngleExtent(a2); }
/** * Sets the starting angle of this arc to the angle defined by the supplied point relative to * the center of this arc. */ public void setAngleStart (XY point) { float angle = FloatMath.atan2(point.y() - centerY(), point.x() - centerX()); setAngleStart(normAngle(-FloatMath.toDegrees(angle))); }
/** * Sets the starting angle of this arc to the angle defined by the supplied point relative to * the center of this arc. */ public void setAngleStart (XY point) { float angle = FloatMath.atan2(point.y() - centerY(), point.x() - centerX()); setAngleStart(normAngle(-FloatMath.toDegrees(angle))); }
/** * Sets the location, size, angular extents, and closure type of this arc based on the * specified values. */ public void setArcByTangent (XY p1, XY p2, XY p3, float radius) { // use simple geometric calculations of arc center, radius and angles by tangents float a1 = -FloatMath.atan2(p1.y() - p2.y(), p1.x() - p2.x()); float a2 = -FloatMath.atan2(p3.y() - p2.y(), p3.x() - p2.x()); float am = (a1 + a2) / 2f; float ah = a1 - am; float d = radius / Math.abs(FloatMath.sin(ah)); float x = p2.x() + d * FloatMath.cos(am); float y = p2.y() - d * FloatMath.sin(am); ah = ah >= 0f ? FloatMath.PI * 1.5f - ah : FloatMath.PI * 0.5f - ah; a1 = normAngle(FloatMath.toDegrees(am - ah)); a2 = normAngle(FloatMath.toDegrees(am + ah)); float delta = a2 - a1; if (delta <= 0f) { delta += 360f; } setArcByCenter(x, y, radius, a1, delta, type); }
/** * Sets the location, size, angular extents, and closure type of this arc based on the * specified values. */ public void setArcByTangent (XY p1, XY p2, XY p3, float radius) { // use simple geometric calculations of arc center, radius and angles by tangents float a1 = -FloatMath.atan2(p1.y() - p2.y(), p1.x() - p2.x()); float a2 = -FloatMath.atan2(p3.y() - p2.y(), p3.x() - p2.x()); float am = (a1 + a2) / 2f; float ah = a1 - am; float d = radius / Math.abs(FloatMath.sin(ah)); float x = p2.x() + d * FloatMath.cos(am); float y = p2.y() - d * FloatMath.sin(am); ah = ah >= 0f ? FloatMath.PI * 1.5f - ah : FloatMath.PI * 0.5f - ah; a1 = normAngle(FloatMath.toDegrees(am - ah)); a2 = normAngle(FloatMath.toDegrees(am + ah)); float delta = a2 - a1; if (delta <= 0f) { delta += 360f; } setArcByCenter(x, y, radius, a1, delta, type); }