Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
3  
What do you mean by "draw"? Are you using some kind of software? x,y are coordinates of what? –  yohBS Jan 2 '12 at 17:16
    
I have to draw an arc using my own method in programming language like javascript. x,y is the center of circle. –  coure2011 Jan 2 '12 at 17:29
add comment

3 Answers 3

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

share|improve this answer
add comment

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.)

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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