3
$\begingroup$

How to draw an arc, I have these values

x  // x coordinate 
y // y coordinate 
r // Arc radius
startAngle // Starting point on circle
endAngle // End point on circle
clockwise  // clockwise or anticlockwise

where x,y is the center of circle. Can someone please provide me equation for drawing an arc?

$\endgroup$
  • 3
    $\begingroup$ What do you mean by "draw"? Are you using some kind of software? x,y are coordinates of what? $\endgroup$ – yohBS Jan 2 '12 at 17:16
  • $\begingroup$ I have to draw an arc using my own method in programming language like javascript. x,y is the center of circle. $\endgroup$ – coure2011 Jan 2 '12 at 17:29
4
$\begingroup$

$x(t) = x_0 + r \cos(t)$, $y(t) = y_0 + r \sin(t)$, for $t\in[\text{startAngle},\text{endAngle}]$.

| cite | improve this answer | |
$\endgroup$
1
$\begingroup$

You have everything it takes to draw an arc. The equation of circle is

$(X-x_1)^2+(Y-y_1)^2=r^2$ where $(x_1,y_1)$ is the centre of circle and $r$ is its radius. You also have the angle of arc, say $\theta$. You can either vary the parameter $t$ as told by lhf or you can find the $x$ and $y$ co-ordinates of start and end points of the arc from simple trigonometric relations as follows.

Let $(x_2,y_2)$ and $(x_3,y_3)$ be start and end points of arc respectively. You can find values of $x_2, x_3$ and $y_2,y_3$ from the fact that

$tan(\theta_1)=\frac{y_2-y_1}{x_2-x_1}$ where $\theta_1$ is the start angle. Plus, the value of $(x_1-x_2)^2+(y_1-y_2)^2=r^2$ is known, so from these two equations, you can find the value of $(x_2,y_2)$. Ditto for $(x_3,y_3)$ and you are done.

So, you have the equation of arc as:

$(X-x_1)^2+(Y-y_1)^2=r^2$ where $X \epsilon [x_2,x_3]$ & $Y \epsilon [y_2, y_3]$. (whichever is greater between $x_2,x_3$ or $y_2,y_3$, take the interval accordingly.)

| cite | improve this answer | |
$\endgroup$
1
$\begingroup$

If you are using Mathematica, Graphics[Circle[{x, y}, r, {startAngle, endAngle}]] does that. It is always anticlockwise, so for clockwise, swap the start and end angles.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.