473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Circle code

Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad

Jan 19 '06 #1
20 8102
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad


Asking in comp.programming is possibly a better idea.

If you try to implement this in C, and have questions, you can always
come back here.

Cheers

Vladimir
--
My e-mail address is real, and I read it.
Jan 19 '06 #2
"ch*******@yahoo.com" wrote:

Can anyone give me an idea for drawing a circle without making
use of any floating point computations?


Sure. Take compass, insert pencil in pencil holder, place pointy
end on desired circle center, adjust compass for appropriate
radius, and spin it.

What was your question about the C language?

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>

Jan 19 '06 #3
<ch*******@yahoo.com> wrote:
Can anyone give me an idea for drawing a
circle without making use of any floating
point computations?


This is not a C language question.
Try asking in "comp.graphics.algorithms",
and/or search for "Bresenham’s Algorithm"

Roberto Waltman

[ Please reply to the group, ]
[ return address is invalid. ]
Jan 19 '06 #4
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?

Why? That seems a fairly useless thing to do.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Jan 19 '06 #5

<ch*******@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad


Use a compass and a pencil.

I used no floating point calculations in
conceiving or presenting this idea.

-Mike
Jan 19 '06 #6
Vladimir S. Oka wrote:
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?


If you try to implement this in C, and have questions, you can always
come back here.


this C program draws one circle without any fp:

#include <stdio.h>
int main(int argc, char **argv) {
printf("o\n");
}

Jan 19 '06 #7
Ico
ch*******@yahoo.com <ch*******@yahoo.com> wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad

Solution #1:
------------

#include <stdio.h>

int main(void)
{
putchar('O');
}

Solution #2:
------------

#include <stdio.h>

int main(int i, char **v)
{
int c='\n',_=-c,y;
for(y=i-c;putc((_*_<c*c-y*y)?0x2a:040,stdout),_<=c;++_);
return((puts("")&&c>y)?main(++i,v):i^i);
}

--
:wq
^X^Cy^K^X^C^C^C^C
Jan 19 '06 #8
tedu wrote:
Vladimir S. Oka wrote:
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations? If you try to implement this in C, and have questions, you can always
come back here.


this C program draws one circle without any fp:


This program is not correct C:

#include <stdio.h>
int main(int argc, char **argv) {
printf("o\n");
return 0;
}


Also I was not the OP.

Cheers

Vladimir

--
My e-mail address is real, and I read it.
Jan 19 '06 #9

Vladimir S. Oka wrote:
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?


Here's the LOGO / differential geometry solution:

repeat
go forward 1 unit
turn right 1 unit

Jan 19 '06 #10
Googmeister wrote:
Vladimir S. Oka wrote:
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?


Here's the LOGO / differential geometry solution:

repeat
go forward 1 unit
turn right 1 unit


Apart from the original question not being asked by me at all, this is
now way off topic in comp.lang.c! Please trim your cross-posts to
comp.programing only.

Cheers

Vladimir
--
My e-mail address is real, and I read it.
Jan 19 '06 #11
Vladimir S. Oka wrote:
tedu wrote:
this C program draws one circle without any fp:
This program is not correct C:
#include <stdio.h>
int main(int argc, char **argv) {
printf("o\n");


return 0;
}


i was hoping the on-topic requirements here were loose enough to
squeeze a little c99 into the group.
Also I was not the OP.


that post isn't visible to me, which is why i quoted the original
author as well.

Jan 19 '06 #12
tedu wrote:
Vladimir S. Oka wrote:
tedu wrote:
this C program draws one circle without any fp: This program is not correct C:
#include <stdio.h>
int main(int argc, char **argv) {
printf("o\n");

return 0;
}


i was hoping the on-topic requirements here were loose enough to
squeeze a little c99 into the group.


You're right about the C99. I guess I'll get used to it when there's
more compilers supporting it. I still think that it's good practice to
have something returned from a function that does have a return value.
Also I was not the OP.


that post isn't visible to me, which is why i quoted the original
author as well.


Sorry for jumping the gun.

Cheers

Vladimir

--
My e-mail address is real, and I read it.
Jan 19 '06 #13

<ch*******@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad


32 seconds with Google returned this excellent page:
http://www.cs.unc.edu/~mcmillan/comp...e7/circle.html
Rod Pemberton
Jan 19 '06 #14
"Default User" <de***********@yahoo.com> writes:
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?


Why? That seems a fairly useless thing to do.


It could be very useful for a graphics program running on a system
where integer arithmetic is significantly faster than floating-point
arithmetic. (That doesn't make it topical here, of course.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 19 '06 #15
"Rod Pemberton" <do*******@bitbucket.cmm> writes:

<ch*******@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googleg roups.com...
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad
32 seconds with Google returned this excellent page:
http://www.cs.unc.edu/~mcmillan/comp...e7/circle.html

No wonder the OP couldn't find his homework solution using Google -
that page doesn't even use the word 'float'.

--
Chris.
Jan 19 '06 #16
On 2006-01-19, ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
long radius = 100, point;
if ( argc > 1 ) radius = strtol(argv[1],NULL,10);
point = radius + 18;
printf( "%!\n%d %d %d 0 360 arc stroke showpage\n", point, point, radius);
return 0;
}
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Jan 19 '06 #17
On 2006-01-19, Ico <us****@zevv.nl> wrote:
ch*******@yahoo.com <ch*******@yahoo.com> wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?
Thanks
Prasad

Solution #1:
------------

#include <stdio.h>

int main(void)
{
putchar('O');
}


You need to also output a newline, otherwise the output might never
show. In particular, my system's interactive shell prints a carriage
return and overwrites an unterminated last line of output with its
prompt. Other systems may not flush an unterminated last line to the
output device at all.
Jan 19 '06 #18
Ico
Jordan Abel <ra*******@gmail.com> wrote:

#include <stdio.h>

int main(void)
{
putchar('O');
}


You need to also output a newline, otherwise the output might never
show. In particular, my system's interactive shell prints a carriage
return and overwrites an unterminated last line of output with its
prompt. Other systems may not flush an unterminated last line to the
output device at all.


Yes, you are completely right. I guess my suggesions are just bad
examples for the OP's homework.
--
:wq
^X^Cy^K^X^C^C^C^C
Jan 20 '06 #19
"tedu" <tu@zeitbombe.org> wrote:
Vladimir S. Oka wrote:
ch*******@yahoo.com wrote:
Can anyone give me an idea for drawing a circle without making use of
any floating point computations?


If you try to implement this in C, and have questions, you can always
come back here.


this C program draws one circle without any fp:

#include <stdio.h>
int main(int argc, char **argv) {
printf("o\n");
}


Whether that draws a true circle or only an approximation is
implementation-dependent. On non-Western or oddly configured systems it
could even result in a completely different drawing.

Richard
Jan 20 '06 #20
Ico wrote:

Jordan Abel <ra*******@gmail.com> wrote:

#include <stdio.h>

int main(void)
{
putchar('O');
}


You need to also output a newline, otherwise the output might never
show. In particular, my system's interactive shell prints a carriage
return and overwrites an unterminated last line of output with its
prompt. Other systems may not flush an unterminated last line to the
output device at all.


Yes, you are completely right. I guess my suggesions are just bad
examples for the OP's homework.


Well, my DS-6000 draws a perfect circle given the following:

void main(void)
{
int i = i++;
}

Unfortunately, the DS-6000b draws an ellipse. Should I submit a bug
report to the DS-6000b developers?

:-) :-) :-) :-)

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jan 20 '06 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Talon | last post by:
Hi all, I am new to Tk, so please bear with me. I need someone better at math than me to help me figure this out. I am drawing multiple arcs on the same circle. All arcs start at 90 and have...
8
by: Stub | last post by:
In statement: Circle c1=c2; Is the assignment operator= of Circle called? In statement Circle c1(c2); Is the copy constructor called?
1
by: rdeaton | last post by:
I need to design and code a Java program that calculates and prints the (D) diameter, the (C) circumference, or the (A) area of a circle, given the radius. The program inputs two data items: the...
14
by: Pythor | last post by:
I wrote the following code for a personal project. I need a function that will plot a filled circle in a two dimensional array. I found Bresenham's algorithm, and produced this code. Please tell...
38
by: jdcrief | last post by:
Complier: Visual C++ 2005 Express Edition The program I wrote will compile and execute, but the output is always the same, no matter what number is entered in for the radius of the circle. ...
0
by: Carl Gilbert | last post by:
Hi I am trying to plot a series of shapes in a circular fashion. All shapes are evenly spaced with lines going between each shape. At present, all shapes are the same size so I can easily plot...
9
by: saraaana | last post by:
Given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts the user to enter the center and a point on the circle. The program...
7
by: heterodon7 | last post by:
hello, can anyone give me a clue or simple code on task: for example we have in 2D an equation fo circle: (x - 3)^2 + (y - 4)^2 = 25. now the program must return for example a 40 pairs of...
10
by: Greg (codepug | last post by:
I would like to simulate an LED light. Actually need a few of them on my form to serve as indicator lights. I can easily place rectangle labels to make this happen, and turn the color On or OFF,...
26
by: OzzyB | last post by:
This is another problem in the Zelle book. def drawCircle(win, centre, radius, colour): circle = Circle(radius) circle.setFill(colour) circle.setWidth(2) circle.draw(win) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.