answersLogoWhite

0

  • C Programming
  • Visual Basic Programming

How do you draw a circle using C or C plus plus without using the built in function?

User Avatar

Wiki User

βˆ™ 2010-01-06 01:04:44

Best Answer
Copy

There are several options to draw a circle using C or C++ without the built-in functions...

<> <> <> <>

If you can draw a single pixel at a time, use a for loop to iterate Angle from 0 to 2*pi. Then plot a pixel with x=cos(Angle) and y=sin(Angle). Smaller steps will give better results. Lines from one point to the next may look nicer.

Generally, you can use a line from one pixel to the next to draw a polygon. The number of sides is determined by the number of steps from 0 to 2*pi. A circle is a polygon with an "infinite" number of sides (compared to the display resolution). Experiment with non-integral steps to see that the polygon can end at any place. Use an integral number of steps to end where the circle began. Start and stop at fractions of 2*pi, or step backwards, to create arcs. Speed up the code by using lookup tables to calculate sin() and cos(). Hint: they can be the same table, and don't need to be a complete 2*pi circle.

<> <> <> <>

You can also draw the circle without the sin() and cos() functions if you understand the trigonometry behind sin() and cos(). Recall that sin(theta) is radius / y, and cos(theta) is radius / x, given that x and y are the two sides of a right triangle and that radius is the hypotenuse.

By Pythagoream's theorem, x2 + y2 is radius2. It is then simple to solve for x or y, given the other along with radius. You also do not need to compute for the whole circle - you can compute for one quadrant, and generate the other three quadrants by symmetry. You generation loop would, for example, simply iterate from origin to radius as x by delta x, generating y, and reflecting that in the other three quadrants. You can also compute for one half of a quadrant, and use both symmetry and reflection to generate the other seven half quadrants.

2010-01-06 01:04:44
This answer is:
πŸ€“
🀯
πŸ€”
User Avatar

Your Answer

Loading...
Still have questions?
imp

Related Questions

How do you sinx without using mathh or built in sin function Any Algorithm to implement sin function?

You can compute sin(x) manually/numerically using Taylor's Series.


Is the circle a function?

No, it is a shape rather than a function but it can be described using an algebraic function.


How do you define power function without using operator?

using pow() function.. ..


How do you modulate in matlab without using matlab tools?

You would have to write your own code for a modulation (Matlab has a convolution function not in the tools), otherwise you can use its built in function in the signal processing toolbox.


How do you draw a circle without using graphicsh?

platform-dependent


How do you draw tangents to a circle without using its centre?

help me


How do you calculate sine value without using math function?

Using its Taylor-series.


Sorting an array in PHP without using sort function?

plz as soon as possible give me the program for shorting an array in asscending order without using any sort function in c++


How do you compare 2 numbers without using relational operators in c?

using max function


How does the SUM function add all the number in a range?

SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.SUM is a built-in function with Excel that has been specially designed to sum a range of cells. It just needs to know what the cells are and then it can add them all up. The method of doing that has been programmed into Excel by its developers. This leaves us with the simple task of using the function without needing to know the specifics of exactly how it does it.


How do you implement awgn in MATLAB without using awgn function?

no way... use awgn function in matlab


Reverse of a string without using string handling function?

shashi


C program to perform string operation like concatenation and compare?

using built in function


How do you reverse a string in PHP without using a function?

Without any function is impossible. So I'll assume you mean any coded function, in which case the predefined function below is your answer.$string = strrev($string);


Do function and formula have the same meaning in Excel?

Sort of... A formula can use a function. A formula is a calculation on a spreadsheet. A function is a pre-defined formula built into Excel.An example of a function is SUM.An example of a formula using a function is =SUM(A1:A3).An example of a formula not using a function is =A5+C5


On the unit circle define the sine function by using the distance walked as the input and the y coordinate as the output?

Yes, but only if the argument of the sine function is in radians.


It is possible to draw a perfect circle without any instrument?

yes it is possible by using a coin


Some situations where you might use cut without using the paste function?

Both cut and copy are used in conjuction with paste. Think of some situations where you might use cut without using the paste function


How do you draw line without using any predefined function?

That won't happen, you have to have a predefined putpixel (or something like that) function.


Area of a Circle using Function in C?

To find the area of a circle using the circumference, you need to use the formula Area=Circumference squared divided by four times pi. For this type of equation, pi would be equal to 3.14.


Program to count the length of a given string without using built in function?

size_t strlen (const char *s) { const char *p= s-1; while (*++p); return p-s; }


A c program to call a function without using function name?

It can be done via its address, for example: void function (void (*callback)(void)) { (*callback)(); }


Why does a laptop computer get hot when you are using it?

The electricity used for it to function turns into heat, that's why computers have built in fans.


How do you get the value of a circle without using mathematical formulas?

You don't... I am a math teacher... you need to use the formula!


What is the importance of using functions in a c program?

C programs do not function without functions.