How to Draw an Arc Starting at a Specific Point

  • Thread starter Thread starter zak100
  • Start date Start date
  • Tags Tags
    Arc Drawing
AI Thread Summary
To draw an arc connecting the points (130, 170) and (230, 170), the fillArc function requires the correct rectangle parameters. The center of the arc should be calculated based on the midpoint of the two points, which is (180, 170), and the width and height should be adjusted accordingly. The startAngle should be set to 0 for the arc to begin at the rightmost point, with an arcAngle of 180 degrees to create a semicircle. The discussion emphasizes understanding the coordinate system where x increases to the right and y decreases upward. Properly setting these parameters will enable the desired arc to be drawn accurately.
zak100
Messages
462
Reaction score
11

Homework Statement



Hi,
I am trying to draw an arc at the top of two parallel lines i.e connecting two coordinate (130, 170) & (230, 170) using the function below. I can't understand how to start the arc at a particular point.

public abstract void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)

The resulting arc begins at startAngle and extends for arcAngle degrees. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.

The center of the arc is the center of the rectangle whose origin is (x, y) and
whose size is specified by the width and height arguments.

Homework Equations


Instead of eq i have a function:
public abstract void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)

The Attempt at a Solution


g.drawLine(130, 170, 130, 270);
g.drawLine(230, 170, 230, 270);
g.drawArc(80, 220, 100,30, 0, 180);

I have stored my result in the image. Some body please guide me,
Arc.jpg


Zulfi.
 
Physics news on Phys.org
It looks like the upper left corner of the rectangle in the picture below is the x,y coordinate for g.drawArc. And I think that the coordinate system is such that x starts from 0 on the left edge and increases to the right, and y starts from 0 on the top and increases downward.
If the last parameter in g.drawArc was 360, you would get an ellipse that fills the whole 100 by 30 rectangle.
So it looks like x has to increase to move the arc to the right, and y has to decrease to move the arc upward.
I'm not positive that I am right on this. Let me know what you find out.
DrawArc Picture.jpg
 
I do not understand how you arrived at those x and y values for the arc. From the description, it seems like they should be 180, 170, i.e. the coordinates of the point half way between the two points you are trying to connect.
 

Similar threads

Back
Top