http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Drawing a circle



If I remember correctly, sin and cos are reflective around a point (i.e. if
you multiply the value of X by the cosine of 90 for your X position at 90
degrees, your X position at 270 degrees is X * (-cosine (90))).  This
matters for two reasons; 1. Speed, sin and cos are relatively slow
operations, so you really want to keep their computation to a minimum by
computing them once for each degree (0 - 89) and storing the values in a
lookup table and just access them for a given angle, which leads to reason
2. You can make your lookup table 4 times smaller by only storing the values
from 0 - 89 degrees and using them properly, instead of 0 - 359 degrees.

Hope this is correct, I haven't thought about it for a while, and hope it
helps!

Kevin Wolfskill
JADE Solutions
Office US   (303) 448-1019 ext. 23
Fax US      (303) 449-1548
Kevin.Wolfskill@jadesolutions.com
______________________________________
WARNING - THIS E-MAIL TRANSMISSION IS CONFIDENTIAL.
This e-mail transmission (including any accompanying attachments)
contains confidential information which is intended for the named addressee
only. If you are not the intended recipient, you are hereby notified that
any use, dissemination, distribution or reproduction of this e-mail is
prohibited. If you have received this e-mail in error please contact
me immediately. Thank you.
_______________________________________





-----Original Message-----
From: Ryan Moe [mailto:moe_ryan@hotmail.com]
Sent: Thursday, July 06, 2000 9:25 AM
To: gameprogrammer@gameprogrammer.com
Subject: Re: Drawing a circle





>Well, to draw a circle, all you need to do is just draw a point, and then
>rotate that point around the center.
>
>
>You pick a center point (x, y)  , then you just choose a radius.
>
>x = radius * cosine (the angle)
>y = radius * sine (the angle)
>
>you familiar with sine and cosine functions?
>
>cos(), and sin() for C/C++.
>
>Just increase the angle and it will draw in a circle.  You can start the
>angle at 0, then stop it at 360.
>
>a full circle :)
>
>Does that help? :)  I could write a simple little app for it.....
>
>Rotations were hard for me to understand at first too.
>
>You just have to write a little program using them, and see what they do,
>that way you will truly understand them,
>so it just won't be some math problem out of a book ... :)

That's the way to draw a circle but I believe the sin(), cos() in c/c++ take

radian values.  So to convert to degrees you need to multiply your radian 
value by PI/180.  sin( Angle * (PI/180) )

>
>Ben Humphrey
>Game Programmer
>WebHost of www.GameTutorials.com
>benh@humongous.com
>benjina@mindspring.com
>
>----- Original Message -----
>From: Lionel Pinkhard <lionelpi@mweb.co.za>
>To: <gameprogrammer@gameprogrammer.com>
>Sent: Saturday, July 05, 1980 3:04 AM
>Subject: Drawing a circle
>
>
> > Hi,
> >
> > Can somebody please tell me how to draw a circle in C++/Assembler 
>without
>using any graphics libraries (so far my game's not using any)? (under DOS).
> >
> > Kind regards,
> >
> > Lionel Pinkhard
> > =================================================================
> > The GameProgrammer.Com mailing list is for the open discussion
> > of any topic related to the art, science, and business of
> > programming games. This list is especially tolerant of beginners.
> > We were all beginners once
> >
> > To SUBSCRIBE or UNSUBSCRIBE please visit:
> > http://gameprogrammer.com/mailinglist.html
>
>=================================================================
>The GameProgrammer.Com mailing list is for the open discussion
>of any topic related to the art, science, and business of
>programming games. This list is especially tolerant of beginners.
>We were all beginners once
>
>To SUBSCRIBE or UNSUBSCRIBE please visit:
>http://gameprogrammer.com/mailinglist.html

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html