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?

  • 0
    I have to draw an arc using my own method in programming language like javascript. x,y is the center of circle.2012-01-02

3 Answers 3

4

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

1

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

1

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.