## Squares

General FreeBASIC programming questions.
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0021.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 50divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step 1               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 ^ 2 * atan2( deg1 * s1 , c1 / s1 ) / ( s1 ^ 4 )            y1=radius * s1 ^ 2 * atan2( deg1 * c1 , s1 / c1 ) / ( c1 ^ 2 )                    for deg2 = 0 to fullcircle step .5                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c2 * c1 * atan2( deg2 , c1 * 90 ) / ( s1 ^ 4 )            y2=radius * s2 * s1 * atan2( deg2 , s1 * 90 ) / ( c1 ^ 2 )                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0022.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 50divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step 1               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 ^ 2 * atan2( deg1 * s1 , c1 / s1 ) / ( s1 ^ 4 ) * atan2( c1 , s1 )            y1=radius * s1 ^ 2 * atan2( deg1 * c1 , s1 / c1 ) / ( c1 ^ 2 ) * atan2( s1 , c1 )                    for deg2 = 0 to fullcircle step .5                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c2 * c1 * atan2( deg2 , c1 * 90 ) / ( s1 ^ 4 )            y2=radius * s2 * s1 * atan2( deg2 , s1 * 90 ) / ( c1 ^ 2 )                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

I'll stop posting for a few days... You guys have a lot of formulas to look over...
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0023.bas I just had to post it.. Looks real cool , but goes way over the screen..

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 20divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step .75               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 ^ 2 * atan2( deg1 * s1 , c1 / s1 ) / ( s1 ^ 4 ) * atan2( c1 , tan( s1 ) ) * 2            y1=radius * s1 ^ 2 * atan2( deg1 * c1 , s1 / c1 ) / ( c1 ^ 2 ) * atan2( s1 , tan( c1 ) ) * 2                    for deg2 = 0 to fullcircle step 1                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c2 * c1 * atan2( deg2 , c1 * 90 ) / ( s1 ^ 4 ) * atan2( c1 , c2 ) / 2            y2=radius * s2 * s1 * atan2( deg2 , s1 * 90 ) / ( c1 ^ 2 )                         pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0024.bas

Spectacular , spiraling..

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 100divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step 1.5               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 * atan2( deg1 * s1 , c1 / s1 )            y1=radius * s1 * atan2( deg1 * c1 , s1 / c1 )                    for deg2 = 0 to fullcircle step 2                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c2 * atan2( deg2 , deg1 )            y2=radius * s2 * atan2( deg2 , deg1 )                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0025.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 90divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step 1               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 * atan2( deg1 * s1 , c1 / s1 )            y1=radius * s1 * atan2( deg1 * c1 , s1 / c1 )                    for deg2 = 0 to fullcircle step 1                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c2 * atan2( deg2 * rad1 , deg1 * s1 )            y2=radius * s2 * atan2( deg2 * rad1 , deg1 * c1 )                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`

That's enough for today..
There's a never ending number of cool trigonometry doodles possible.
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0026.bas

A little like the "Temple" one i did a while back..

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 90divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step 1               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 * atan2( deg1 * s1 , c1 / s1 )            y1=radius * s1 * atan2( deg1 * c1 , s1 / c1 )                    for deg2 = 0 to fullcircle step 3                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c1 * atan2( deg2 * c2 , deg1 * s1 )            y2=radius * s1 * atan2( deg2 * s2 , deg1 * c1 )                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0027.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 90divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step 1               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 * atan2( rad1 * s1 , c1 )            y1=radius * s1 * atan2( rad1 * c1 , s1 )                    for deg2 = 0 to fullcircle step 1                       c2=cos( deg2 * rad2 )            s2=sin( deg2 * rad2 )                   x2=radius * c2 ^ 2 * c1 * atan2( deg2 , deg1 ) / c1            y2=radius * s2 ^ 2 * s1 * atan2( deg2 , deg1 ) / s1                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`

Here's Abstract_0028.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 70divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step .5               c1 = cos( deg1 * rad1 * 45 )            s1 = sin( deg1 * rad1 * 45 )               x1 = radius * c1 * atan2( rad1 * s1 , c1 )            y1 = radius * s1 * atan2( rad1 * c1 , s1 )                    for deg2 = 0 to fullcircle step .1                       c2=cos( deg2 * rad2 * 10 )            s2=sin( deg2 * rad2 * 10 )                   x2 = radius * c2 ^ 1.5 * c1 ^ 2 * atn( deg2 * rad2 )            y2 = radius * s2 ^ 1.5 * s1 ^ 2 * atn( deg2 * rad2 )                         pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Of all the doodles I've posted so far , i think my favorite , is Abstract_0022.bas
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0033.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 60divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = atn( 1 ) * 8 / rad1do           for deg1 = 0 to fullcircle step .05               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1            y1=radius * s1                    for deg2 = 0 to fullcircle step 10                       c2=cos( deg2 * rad2 * 4 )            s2=sin( deg2 * rad2 * 4 )                   x2=radius * c2 * log( c2 * rad1 / s1 ) / 2 * atan2( deg1 , y1 / c1 )            y2=radius * s2 * log( s2 * rad1 / c1 ) / 2 * atan2( deg1 , x1 / s1 )                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0036.bas

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr, yctr, radius, divisions, fullcircle, toggledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 175divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = ( atn( 1 ) * 8 / rad1 ) / 11.25do           for deg1 = 0 to fullcircle step 1.5               c1=cos( deg1 * rad1 * 45 )            s1=sin( deg1 * rad1 * 45 )               x1=radius * c1 * tan( c1 * s1 ) * atan2( atn( deg1 * rad1 ) , c1 * deg1 ) / 2            y1=radius * s1 * tan( s1 * c1 ) * atan2( atn( deg1 * rad1 ) , s1 * deg1 ) / 2                    for deg2 = 0 to fullcircle step .05                       c2=cos( deg2 * rad2 * 90 )            s2=sin( deg2 * rad2 * 90 )                   x2=radius * c2  / 2 * atan2( deg2 , y1 / c1 ) / c1            y2=radius * s2  / 2 * atan2( deg2 , x1 / s1 ) / s1                        pset(xctr+x1+x2,yctr+y1+y2),9            pset(xctr-x1-x2,yctr+y1+y2),9                        pset(xctr+x1+x2,yctr-y1-y2),9            pset(xctr-x1-x2,yctr-y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

I haven't tried using builtin functions and logic , in my Trigonometry Doodles.

I'll play around with the logics ( and , or , xor , not ) and imp and eqv....
srvaldez
Posts: 2330
Joined: Sep 25, 2005 21:54

### Re: Squares

@Albert
since you have an interest in multiplying big numbers, here's something that may interest you, This Guy Just Found a Faster Way to Multiply
the pdf explaining Integer multiplication in time O(n log n)
since the professor is in Australia, perhaps Richard might be interested
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0037.bas

I played around with IMP and EQV , they don't really make good doodles. But this one looks interesting..

Code: Select all

`dim as single c1 , c2dim as single s1 , s2dim as single x1 , x2dim as single y1 , y2dim as single deg1 , deg2dim as single rad1dim as single rad2dim as integer xctr , yctr , radius , divisions , fullcircledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 100divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = ( atn( 1 ) * 8 / rad1 )do           for deg1 = 0 to fullcircle step .1               c1 = cos( deg1 * rad1 )            s1 = sin( deg1 * rad1 )               x1 = radius * ( c1 eqv 2 ) / 2000            y1 = radius * ( s1 eqv 2 ) / 2000                    for deg2 = 0 to fullcircle / 4 step 2                       c2 = cos( deg2 * rad2 )            s2 = sin( deg2 * rad2  )                   x2 = radius * c2 eqv deg1 imp c2 * (tan( c1 * c2 / deg2 )  / 100) / c1            y2 = radius * s2 eqv deg1 imp s2 * (tan( s1 * s2 / deg2 )  / 100) / s1                        pset( xctr +x1+x2,yctr +y1+y2),9            pset( xctr -x1-x2  ,yctr +y1+y2),9                        pset( xctr +x1+x2, yctr -y1-y2),9            pset( xctr -x1-x2  , yctr -y1-y2),9                    next       nextloop until inkey <>""`
albert
Posts: 5631
Joined: Sep 28, 2006 2:41
Location: California, USA

### Re: Squares

Here's Abstract_0038.bas

I tried playing around with triple nested loops.. using 3 sines and cosines.

Code: Select all

`dim as single c1 , c2 , c3dim as single s1 , s2 , s3dim as single x1 , x2 , x3dim as single y1 , y2 , y3dim as single deg1 , deg2 , deg3dim as single rad1dim as single rad2dim as integer xctr , yctr , radius , divisions , fullcircledim as integer xres , yres'screen 19screeninfo xres , yresscreenres xres , yres , 8 , 1 , 8xctr = ( xres / 2 ) '- 150yctr = ( yres / 2 ) ' - 100radius = ( xres * yres ) / ( (xres + yres ) * 4 )radius = 100divisions = 45rad1 = atn( 1 ) / divisionsrad2 = atn( 1 ) / ( divisions / 2 )fullcircle = ( atn( 1 ) * 8 / rad1 )do           for deg1 = 0 to fullcircle step 2               c1 = cos( deg1 * rad1 )            s1 = sin( deg1 * rad1 )               x1 = radius * c1            y1 = radius * s1                        for deg2 = 0 to fullcircle / 2 step 1                           c2 = cos( deg2 * rad2 )                s2 = sin( deg2 * rad2 )                           x2 = radius * c2 * atn( deg1 * c1 )                y2 = radius * s2 * atn( deg2 * s1 )                                for deg3 = 0 to fullcircle / 4 step 10                                   c3 = cos( deg2 * rad2 )                    s3 = sin( deg2 * rad2  )                                   x3 = radius * c3                    y3 = radius * s3                                        pset( xctr +x1+x2+x3 , yctr +y1+y2+y3),9                    pset( xctr -x1-x2-x3    , yctr +y1+y2+y3),9                    pset( xctr +x1+x2+x3 , yctr -y1-y2-y3),9                    pset( xctr -x1-x2-x3    , yctr -y1-y2-y3),9                        next                    next       nextloop until inkey <>""`