To draw a circle using Cartesian coordinate system
A Cartesian coordinate system is a coordinate system that specifies each point uniquely in a plane by a pair of numerical coordinates. Considering two points x and y on the x-axis and y-axis which meet at (x,y), this produces a right angle triangle with base of length x and height y. Here we could implement Pythagorean theorem which states ; The sum of the areas of the two squares on the legs (a and b) equals the area of the square on the hypotenuse (c). now applying to the above fig we get.
To run the script ; Script ;
- the step are defined to 40.
- setting radius of the circle to r
- defining x position to 0
- defining y position to -r ( i.e.. To start the circle from the point (0,-r))
- determines the centre of x and y.Pen down starts to draw
- the first loop repeats for the number of steps i.e..40
- y value is changed with respect to delta of y .
- x is set to the modified equation of circle i.e.. x= √(r*r) – (y*y)
- this draws only a semi circle starting from the point (0,-r) to the point (0,r)
- hence we require a second loop to draw the other half of the semi circle.
- the second loop repeats for the number of steps ie.40
- y value is changed with respect to delta of – y.
- y is set to the modified equation of circle i.e.. x= – √ (r*r) – (y*y)
- this draws only a semi circle starting from the point (0,r) to the point (0,-r)
- hence the other half of the semi circle is dawn.
Now this whole script is user defined to perform 3 concentric circles around each points (0,0) and (100,50)
The Drawn Circles;
reference : http://en.wikipedia.org – image 2