Radian Circles
Author |
Message |
TheZsterBunny
![](http://www.members.shaw.ca/rfolz/zstervava2.jpg)
|
Posted: Mon Jul 26, 2004 1:52 am Post subject: Radian Circles |
|
|
The problem with incomplete circles was overcome by using radians and not degrees. with degrees one is stuck using only 360 points per circle, and with radians, one can use (Pi*2*(10^16)) points. I think.
try this
code: |
setscreen ("nobuttonbar")
var radius := 30
var angle : real
var clr : int := 4
colorback (black)
cls
loop
%angle := Rand.Real * (2 * Math.PI) % radians
angle := Rand.Int (0, 360) % degrees
drawdot (round (sin (angle) * radius) + maxx div 2, round (cos (angle) * radius) + maxy div 2, clr)
radius += 1
radius := (radius mod 180) + 15
clr += 1
clr := clr mod maxcolor
end loop
|
now, when you run this, look at the outermost circle, you will find that it is not a circle, but series of 360 points. also, allow me to direct your attention to the innermost circle, which would appear to be doubly thick due to the limitations of rounding trig functions in degrees.
enter the radian!
uncomment the radian line and comment the degree line
run the program again
note that the outermost circle is complete in its construction and the innermost a fine line.
this is why radians are superiour to degrees. thank you
-Z (2:47 AM) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Mon Jul 26, 2004 8:56 am Post subject: Re: Radian Circles |
|
|
TheZsterBunny wrote: with degrees one is stuck using only 360 points per circle
Assuming you use whole numbers. Why can't I use measures like .001 degree increments? Oh wait, I can.
TheZsterBunny wrote: and with radians, one can use (Pi*2*(10^16)) points. I think.
What?
TheZsterBunny wrote:
%angle := Rand.Real * (2 * Math.PI) % radians
What was the point of picking random angles?
TheZsterBunny wrote:
angle := Rand.Int (0, 360) % degrees
Again, now you're only going in one degree increments.
TheZsterBunny wrote:
drawdot (round (sin (angle) * radius) + maxx div 2, round (cos (angle) * radius) + maxy div 2, clr)
It's hardly fair to be using a sin function with degrees when its angle parameter is taken in radians. Please use sind() instead.
TheZsterBunny wrote: this is why radians are superiour to degrees. thank you
Ugh, please no. Every time I hear something like that I feel like I'm in Middle Earth doing battle against this huge ugly orc in a shirt and tie babbling about the problem with using "Babylonian religious units." You know what? Maybe radians are more precise, in some stupid way, than degrees. If you plan to draw a circle on a computer screen, exactly HOW precise do you need to be?
I'm sorry if it sounds like I'm flaming you, it's just that you brought back some bad (and hellishly annoying) memories.
code: |
for i : 0..360*100
drawdot ( maxx div 2 + cosd(i/100)*80, maxy div 2 + sind(i/100)*80, 7) % decimals are your friend.
end for
|
In the above example, we make a for loop from 0 to 360 (yum, degrees...). Except that it actually goes to 360*100. Why? Because later on we will be dividing by 100 in order to get some decimal places in there, so we'll get things from 0 to 360 and a little bit more in between. So we draw the dot and use cosd() and sind() functions to calculate the cos and sin respectively using degrees as opposed to radians.
PS: radians aren't actually that accurate. Math.PI stores a real number, which means it only goes up to something like 3.14159265 (if I remember correctly), whereas the digits of PI continue on infinitely. Also, the only time you're using radians in math class or sunday math or wherever you go to hear the orc speak, they are using in situations where the angle either corresponds to 0, 30, 60, or 90 degrees (or some complement of that), or when the problem allows for the angles to cancel out.
Again, I'm not trying to piss you off, as I'm not pissed off at you... just somebody you know.
Hail. |
|
|
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Mon Jul 26, 2004 5:20 pm Post subject: (No subject) |
|
|
not the radians > degree thing again, I had enough of that in math class, sunday math, night math, banters of my math friends...you get the drift. I'm pretty sure if you are into the whole definition thing then radians is the right way for anything circular, but as long as something works, and it works well, then people are still going to use it. Babylonian units works fine, and it doesn't lag down your program or cause it to crash (and since we are programmers remember, I know, I know, it's hard for you to accept being one, when you deperately want to be a mathlete), so there is no need for the "Radian > Degree" thingie.
I thought I'd comment on this because of the horrible horrible experiences I've had in the past...... |
|
|
|
|
![](images/spacer.gif) |
TheZsterBunny
![](http://www.members.shaw.ca/rfolz/zstervava2.jpg)
|
Posted: Mon Jul 26, 2004 9:05 pm Post subject: (No subject) |
|
|
lack of sleep does this kind of stuff to people.
i wasn't trying to prove a point with this post. what i meant to say was something along the lines of this:
in this post, in this program, in this situation, when coded like this, radians give a nicer effect than degrees do.
i'm looking at it further and have realized that with one simple change to my code (not limiting it to whole number degrees), it doesn't matter whether or not one uses radians or degrees. 180 degrees = PI
the Rand.Real * X gives you a random number from above 0 to X. its my way of doing a random real number.
I also use random for the following reason. Cool Factor
code: |
setscreen ("nobuttonbar")
var radius := 30
var angle : real
var clr : int := 4
colorback (black)
cls
drawfilloval (maxx div 2, maxy div 2, 8, 8, brightred)
loop
angle := (Rand.Real * (Math.PI / 8) - Math.PI / 16) % radians
RGB.SetColor (clr, (radius + 18 / 194 + 18), Rand.Real, (194 + 18 - radius + 18 / 194 + 18))
drawdot (round (sin (angle) * radius) + maxx div 2, round (cos (angle) * radius) + maxy div 2, clr)
radius := (radius mod 182) + 16
end loop
|
psh. ogre he is.
-Z |
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Tue Jul 27, 2004 7:00 am Post subject: (No subject) |
|
|
AsianSensation wrote: Babylonian units
HCF MP+HK QCB HK QCB HP;
Stop calling them that, Meng. I will be forced to hunt you down. You won't see the ninja. |
|
|
|
|
![](images/spacer.gif) |
|
|