Conical curves are very known geometric spaces based on section of cones. There are four conical curves:

All of them are very used in computer graphics and, in this post, I wish to present how to plot a circle.

The analytic equation of circles is:

We know

Comparing original equation with obtained equation, it's possible to verify that:

So, we have now the values for

Now, let's write some code in Scilab.

By first, a circle of radius

The result of this code is the following picture.

Take attention the limits of the circle are

And for finishing, a harder example, four circles with different centers and radius.

And the result is:

Take attention the parameters of center and radius of each circle and the obtained picture.

- circle;
- ellipse;
- hyperbole;
- parabola.

All of them are very used in computer graphics and, in this post, I wish to present how to plot a circle.

The analytic equation of circles is:

*where***(x - xc)² + (y - yc)² = r²****means the center of the circle and***(xc, yc)**is it radius.***r**We know

*, for any angle***cos²(a) + sin²(a) = 1***, thus multiplying both sides of equation by***a****we obtain***r²**.***(r cos(a))² + (r sin(a))² = r²**Comparing original equation with obtained equation, it's possible to verify that:

*x - xc = r cos (a)**x = r cos(a) + xc***y - yc = r sin(a)****y = r sin(a) + yc**So, we have now the values for

*and***x****depending only of the center of the circle, it radius and an angle***y**.***a***and***(xc, yc)****are given by the circle and***r**is an angle that means a dummy variable in range***a****.***[0, 2*%pi]*Now, let's write some code in Scilab.

By first, a circle of radius

*and center***r = 2****.***(xc, yc) = (0, 0)*//center of the circle xc = 0; yc = 0; //radius of the circle r = 2; //dummy variable for angle in range [0, 2*%pi] a = linspace(0, 2*%pi, 100); //x axis x = xc + r*cos(a); //y axis y = yc + r*sin(a); //plot the circle plot(x, y);

The result of this code is the following picture.

Take attention the limits of the circle are

*both for***(-2, 2)****and***x**axis, what means this circle is centered in***y***with radius***(0,0)****.***2*And for finishing, a harder example, four circles with different centers and radius.

///////////////////////////////////////// //center of the circle xc = 6; yc = 0; //radius of the circle r = 6; //dummy variable for angle in range [0, 2*%pi] a = linspace(0, 2*%pi, 100); //x axis x = xc + r*cos(a); //y axis y = yc + r*sin(a); //plot the circle plot(x, y); //////////////////////////////////////// //center of the circle xc = 6; yc = 0; //radius of the circle r = 2; //dummy variable for angle in range [0, 2*%pi] a = linspace(0, 2*%pi, 100); //x axis x = xc + r*cos(a); //y axis y = yc + r*sin(a); //plot the circle plot(x, y); //////////////////////////////////////// //center of the circle xc = 2; yc = 0; //radius of the circle r = 2; //dummy variable for angle in range [0, 2*%pi] a = linspace(0, 2*%pi, 100); //x axis x = xc + r*cos(a); //y axis y = yc + r*sin(a); //plot the circle plot(x, y); //////////////////////////////////////// //center of the circle xc = -3; yc = 3; //radius of the circle r = 3; //dummy variable for angle in range [0, 2*%pi] a = linspace(0, 2*%pi, 100); //x axis x = xc + r*cos(a); //y axis y = yc + r*sin(a); //plot the circle plot(x, y);

And the result is:

Take attention the parameters of center and radius of each circle and the obtained picture.

## 5 comments:

Hi Alex, nice post.

I just saw your messages posted in my blog early this year, http://scilab-imageprocessing.blogspot.com/

I am still not used to read the comments, hence I've disable it now and thinking of adding some gadget to sent the email direct to my account.

yes, I am still using Scilab but life is too busy for me to keeping bloging. I would try to spent some time to share my experience in scilab.

thanks for your sharing.

CL

Nice thanks :p

Itz really helpfull

Thank you for posting this .. I was using the polar function all this time to plot a circle.

Every person has the passion in any aspects or things.

If you love something and it came in front of you it completes your day and your mood turns into something you won't expected.

I love your work and I want to read more about it. Visit my site if you have time . Thank you.

triciajoy.com

www.triciajoy.com

Post a Comment