How to Draw an Arc Starting at a Specific Point

  • Thread starter Thread starter zak100
  • Start date Start date
  • Tags Tags
    Arc Drawing
Click For Summary
SUMMARY

The discussion focuses on drawing an arc between two coordinates (130, 170) and (230, 170) using the Java Graphics method fillArc. The method requires parameters for the rectangle's origin, width, height, start angle, and arc angle. Participants clarify that the arc's starting point is determined by the startAngle parameter, which is measured from the 3 o'clock position in a counter-clockwise direction. The correct coordinates for the arc's center should be adjusted to (180, 170) to effectively connect the two specified points.

PREREQUISITES
  • Understanding of Java Graphics API
  • Familiarity with coordinate systems in 2D graphics
  • Knowledge of angles and their measurement in degrees
  • Basic programming skills in Java
NEXT STEPS
  • Research the Java Graphics drawArc method and its parameters
  • Explore coordinate transformations in 2D graphics
  • Learn about angle measurement and rotation in graphics programming
  • Investigate how to manipulate arc parameters to achieve desired shapes
USEFUL FOR

Java developers, graphic designers, and anyone interested in 2D graphics programming who needs to understand arc drawing techniques in Java.

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

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K