answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

You cannot draw any graphics in standard C++. For graphics output you need an appropriate API that supports your platform and hardware. Since this is platform-specific, it is not part of the standard.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

C++ has no built-in graphics methods. Graphics are platform-specific, but C++ is a generic language. To use graphics you need a graphics library and API that are specific to your platform and hardware. The code you use will therefore be specific to that library.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

You cannot -- not with a generic C or C++ implementation. Both are designed to be as generic as possible, but graphics are platform-specific. For graphics output, you therefore need a suitable graphics library and API for your specific platform and hardware.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

C does not provide any native support for graphics manipulation. C is a general-purpose language, not a system-specific language. To add graphics support you must link to a graphics library. Generic libraries such as OpenGL are recommended.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: To draw a circle and show its movements using c plus plus graphics?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you divide a circle into eight parts using only three lines?

Draw two diameter lines, then draw a circle inside the circle.


How do you draw a rhombus using a compass?

first you draw a circle, divide it into 4


How do you draw a circle in isometric projection?

Here is the link that will help you with Illustrations http://www.ider.herts.ac.uk/school/courseware/graphics/drawing_circles_in_isometric.html


Write a java code to draw a circle inside in an ellipse?

write a program draw circle and ellipse by using oval methods in java


How do you draw a circle with a 4 cm diameter?

Using a protractor.


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 draw pie slice in c graphics?

using pie slice function akwinder can draw monkey which exactly looks like her.


How do you draw Logic Gates in C language?

The C language is not a graphics language and you cannot draw logic gates using it. C is a programming language, and it is possible to use a graphics library to do so, but you did not specify which library you were using. Please restate the question.


What is graphics programming in vb?

Graphics programming is when you manually draw an item to your application instead of using a picture box, label, or button. To start drawing graphics you need to import the graphics library. Imports System.Drawing.Graphics Then create a new graphics Dim g As New Graphics that is it. when you call "g" you will have many operators in it to draw to the forum. Hope this helps :)


How do you draw a circle in assembly program?

You can draw a circle in assembly program by using a compass-like tool. Secure the tip of the compass and then rotate the compass tool so that it completes the circle.


What are the disadvantages of using virtual components in SolidWorks?

you need a alienware computer, with extreme graphics to draw it.