A geometric shape that represents a segment of a circle. Generally is measured by two angles, starting and ending, and it's radius. If you need an arc of an ellipse, please be sure to tag the question with the [ellipse] tag as well.
Geometric Definition:
An arc is a geometric shape used for drawing circle segments. It is comprised of three main parts:
- staring θ: the angle measure, for the first part of the sub-circle, usually in radians
- ending θ: the angle measure, for the ending part of the sub-circle, usually in radians
- radius: the radius of the circle that this arc is a part of.
Arcs in computer programming cannot be accurately represented, as the value of π is infinite. Thus, any circle or arc you see will always be slightly inaccurate, although most algorithms usually keep that with a few pixels.
The length of an arc can be approximated by the following formula:
Notice that on some systems, the length of an arc can be negative, specifying that it moves counter-clockwise around the circle, instead of clockwise. This is usually represented by a boolean flag being set from the calling function.
On Specific Systems:
For windows, arcs can be drawn using the gdi+ functions, and can also draw arcs of ellipses.
Example in c#:
void drawArc(Graphics myGraphics, Pen myPen, float x, float y, float startTheta, float endTheta, float radius)
{
myGraphics.DrawArc(myPen, x - radius, y - radius, radius * 2, radius * 2, startTheta, endTheta);
}
Arcs can also be drawing using the equivalent c++ drawing functions.
For Mac OS X, arcs can be drawn using the NSBezierPath class in AppKit.
Example in objective-c:
void drawArc(float x, float y, float startTheta, float endTheta, float radius)
{
NSBezierPath *bezierPath = [NSBezierPath bezierPath];
[bezierPath appendBezierPathWithArcWithCenter:CGPointMake(x, y) radius:radius startAngle:startTheta endAngle:endTheta];
[bezierPath stroke]; // draws with current set color
}
In Java, you can draw arcs as well, using the portable functions found in the Graphics class.