### Author Topic: Schranzors Rand und Gernots Kreis  (Read 11521 times)

#### Quentin

• Prof. Inline
• Posts: 915
##### Schranzors Rand und Gernots Kreis
« on: 2008-Jan-10 »
Code: (glbasic) [Select]
`LIMITFPS 20fac = 50WHILE TRUE  FOR i = 0 TO 359    x = fac * SIN(i) + 320     y = fac * COS(i) + 240     SETPIXEL x + RAND(-5, 5), y + RAND(-5, 5), RGB(128, 128, 128)    SETPIXEL x + RAND(-10, 10), y + RAND(-10, 10), RGB(176, 176, 176)    SETPIXEL x + RAND(-20, 20), y + RAND(-20, 20), RGB(208, 208, 208)    SETPIXEL x + RAND(-30, 30), y + RAND(-30, 30), RGB(240, 240, 240)    SETPIXEL x + RAND(-40, 40), y + RAND(-40, 40), RGB(255, 255, 255)  NEXT  INC fac, 10  IF fac > 500 THEN fac = 10  SHOWSCREENWENDFUNCTION RAND: minimum, maximum  RETURN minimum + RND(-minimum + maximum)ENDFUNCTION`

#### Schranz0r

• Prof. Inline
• Posts: 5116
• O Rly?
##### Schranzors Rand und Gernots Kreis
« Reply #1 on: 2008-Jan-10 »
cool ^^
I DGArray's

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1621
• Particle Hawk
##### Re: Schranzors Rand und Gernots Kreis
« Reply #2 on: 2008-Aug-15 »
Very Cool, i like both, the rand function and the sprites.

Not to be picky, but this is the math section afterall...
Standard Math for SIN and COS are as follows:

COS()x
SIN()y

If you switch them, your angles get transformed incorrectly, and result in a 90 degree transformation.

Typically all 0 angle naturally point to the right, as with all standard math,  writing, and technology.

In this case it doesnt matter because it is used in a full circles.
If you use this function with standard angles and non circles,
it is recommended you standard the math for debugging and cross referencing information.

SIN COS TAN Defined:
http://www.gcseguide.co.uk/sin,_cos,_tan.htm

Also i made a tutorial in this math section for using SIN and COS in circular math.
« Last Edit: 2008-Aug-16 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### aonyn

• Mr. Polyvector
• Posts: 136
##### Re: Schranzors Rand und Gernots Kreis
« Reply #3 on: 2011-Feb-15 »
Hi Hemlos,

I just looked through several sections, and it is all very well explained and easy to follow.

regards,
Dave
For by grace are ye saved through faith, and that not of yourselves: it is the gift of God: Not of works, lest any man should boast. -Ephesians 2:8-9

#### monono

• Mr. Polyvector
• Posts: 213
##### Re: Schranzors Rand und Gernots Kreis
« Reply #4 on: 2011-Feb-15 »
Nice combination! Easy and good looking.

I am going to shamelessly use this thread to advert my beloved little rand function

Code: (glbasic) [Select]
`FUNCTION QRND: b, e=0 , scale=1 LOCAL n = ABS(e-b) RETURN b+ n/(scale*n)*RND(scale*n)ENDFUNCTION`
Examples:
QRND(20) - nothing special, like RND(20)
QRND(20,100) - numbers between 20 and 100
QRND(20,100,10) -numbers between 20 and 100 and 10 steps from one number to the next one  20,20.1...99.9,100
and so on..
Works with negative numbers, too.

How cool is that, uh?

#### Moebius

• Dr. Type
• Posts: 315
##### Re: Schranzors Rand und Gernots Kreis
« Reply #5 on: 2011-Feb-16 »
Useful, but with one problem:
QRND(100) returns values from 100-200 instead of 0-100...
QRND(n) returns values from n to 2*n instead of 0 to n...

`FUNCTION QRND: b, e=0 , scale=1 LOCAL n = ABS(e-b) RETURN e + n/(scale*n)*RND(scale*n)ENDFUNCTION`