Sine and Cosine are rebelling!

BlitzMax Forums/BlitzMax Beginners Area/Sine and Cosine are rebelling!

Dubious Drewski(Posted 2005) [#1]
Could someone please tell me why the following code creates a square instead of a round ring?

Graphics 320, 200
For Local a = 0 To 900
Local x:Float = 20* Sin(Rnd(360))
Local y:Float = 20* Cos(Rnd(360))
Plot 160+x,100+y
Next
Flip
WaitKey

This works with any variable, but once I have an Rnd as
the angle, as above, it goes square, and I can't figure out why.


[edit]

For example, this code works perfectly fine:

Graphics 320, 200
For Local a = 0 To 360
Local x:Float = 20* Sin(a)
Local y:Float = 20* Cos(a)
Plot 160+x,100+y
Next
Flip
WaitKey


Diablo(Posted 2005) [#2]
try

Graphics 320, 200
For Local a = 0 To 900
Local r:Float = Rnd(360)
Local x:Float = 20* Sin(r)
Local y:Float = 20* Cos(r)
Plot 160+x,100+y
Next
Flip
WaitKey

you need to make sure your cos'ing and sin'ing the same number

Edit Even:
Graphics 320, 200
For Local a = 0 To 900
Local r:Float = Rnd(360)
Local d:Float = Rnd(20)
Local x:Float = d* Sin(r)
Local y:Float = d* Cos(r)
Plot 160+x,100+y
Next
Flip
WaitKey


Dubious Drewski(Posted 2005) [#3]
Oh geez, I figured it out as I was submitting.

After a whole day wasted.

Both values for the sin and cos have to be the same number.

Duh.


Dubious Drewski(Posted 2005) [#4]
Thank you as well, diablo.