Squares

General FreeBASIC programming questions.
Locked
integer
Posts: 408
Joined: Feb 01, 2007 16:54
Location: usa

Re: Squares

Post by integer »

That's fantastic looking !!!
ditto
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat

I think a got a Data_Compressor algorithim worked out , but I got to write a de-compressor first to see if its working..
It seems to compress *.exe's to roughly 1/3 size and ascii text files to about 1/2 size.


I'll probably have the de-compressor written by tomorrow.

The problem I'm having right now is the compressor is way too slow...1/2 hour to compress 230KB *.bmp
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat

I found the bottle neck , it just happens to be your Base2() converter function you posted a couple pages back..
I Don't know how to speed it up.?

I got to speed up my own code before it as well, as it takes about 5 mins to run through a 230 KB *.bmp.

Its the testing of segments to see if they have already occurred, so you have to loop through the file and loop through that, to see if it already occurred. so it loop and loops and I have to figure a better way to convert the output to binary.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Post by dodicat »

Hi Albert.
Have you got zlib.a in your lib folder?
http://sourceforge.net/projects/fbc/fil ... Libraries/
Here are two files, a compressor and a decompressor.
Compile each to .exe and use drag and drop to compress/uncompress.
COMPRESS

Code: Select all

'Uses libz.a, FreeBasic static library file.
'http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/Libraries/
'The required download is: FB-win32-zlib-1.2.7.zip
'put libz.a into your Freebasic lib folder
'=======================================================

'Call this file compress.bas
'COMPILE TO EXE
'USE DRAG AND DROP TO compress.exe to produce a zlib compressed file
dim as string file
file=command(1)
dim shared as integer f

#include once "zlib.bi"
declare Sub string_split(s_in As String,char As String,result() As String)
if len(file)=0 then
    print "no input file"
    sleep
    end
end if
if instr(file,"ComPressed_")  then
    if instr(file,"UN_")=0 then
    redim as string temp(0)
    string_split(file,"\",temp())
    print temp(ubound(temp)) & " has already been compressed by zlib"
    sleep
    end
end if
end if
print "PLEASE WAIT ..."

Sub string_split(s_in As String,char As String,result() As String)
    Dim As String s=s_in,var1,var2
Dim As Long n,pst
      #macro split(stri,char,var1,var2)
    pst=Instr(stri,char)
    var1="":var2=""
    If pst<>0 Then
    var1=Mid(stri,1,pst-1)
    var2=Mid(stri,pst+1)
Else
    var1=stri
    Endif
    Redim preserve result(1 To 1+n-((Len(var1)>0)+(Len(var2)>0)))
    result(n+1)=var1
    #endmacro
   Do
   split(s,char,var1,var2):n=n+1:s=var2
Loop Until var2=""
Redim preserve result(1 To Ubound(result)-1)
End Sub
function getfile2(file as string) as string
     f=freefile
    Open file For Binary Access Read As #f
    Dim As String text
    If Lof(1) > 0 Then
      text = String(Lof(f), 0)
      Get #f, , text
    End If
    Close #f
    return text
    end function
var text=getfile2(file)
dim as integer stringlength,destinationlength
stringlength=len(text)

destinationlength = compressBound(stringlength)

Dim As UByte Ptr source = Allocate(stringlength)
Dim As UByte Ptr destination = Allocate(destinationlength)
source=@text[0]

var mistake=compress(destination, @destinationlength, source, stringlength)
redim as string temp()

string_split(file,"\",temp())

var filename=mid(temp(ubound(temp)),len(ubound(temp))-3)

print filename & " Compressed"
print
print filename & "            Length = ";len(text)
print
print filename & " Compressed length = ";destinationlength
print
print "Compression = ";destinationlength/len(text)
if mistake <>0 then print "There was an error"

dim as string compressed=string(destinationlength,0)

for n as integer=0 to destinationlength-1
    compressed[n]=destination[n]
next n

f=freefile
open "ComPressed_"+filename for output as #f
    print #f,stringlength &"|";
    print #f,compressed
close #f
print "The compressed file is "&"ComPressed_"+filename

print"Press any key"
'delete[] destination
'delete[] source
sleep
  
UNCOMPRESS

Code: Select all

'Uses libz.a, FreeBasic static library file.
'http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/Libraries/
'The required download is: FB-win32-zlib-1.2.7.zip
'put libz.a into your Freebasic lib folder
'===========================================================


'call this file uncompress.bas
'COMPILE TO EXE
'USE DRAG AND DROP ON uncompress.exe to uncompress a zlib compressed file.
dim as string file
dim shared as integer f
dim shared as integer passed_length

file=command(1)

#include once "zlib.bi"
declare Sub string_split(s_in As String,char As String,result() As String)

if len(file)=0 then
    print "no input file"
    sleep
    end
end if
'if instr(file,"ComPressed_")=0 or instr(file,"UN_ComPressed")<>0 then
    'if left(file,11)<>"ComPressed_" then
    redim as string temp(0)
    string_split(file,"\",temp())
    if left(temp(ubound(temp)),11)<>"ComPressed_" then
    print temp(ubound(temp)) & " hasn't been compressed by zlib"
    sleep
    end
    end if
print "PLEASE WAIT ..."

Sub string_split(s_in As String,char As String,result() As String)
    Dim As String s=s_in,var1,var2
Dim As Long n,pst
      #macro split(stri,char,var1,var2)
    pst=Instr(stri,char)
    var1="":var2=""
    If pst<>0 Then
    var1=Mid(stri,1,pst-1)
    var2=Mid(stri,pst+1)
Else
    var1=stri
    End if
    Redim preserve result(1 To 1+n-((Len(var1)>0)+(Len(var2)>0)))
    result(n+1)=var1
    #endmacro
   Do
   split(s,char,var1,var2):n=n+1:s=var2
Loop Until var2=""
Redim preserve result(1 To Ubound(result)-1)
End Sub

function getfile2(file as string) as string
    dim as string var1,var2
    dim as integer pst
     #macro splice(stri,char,var1,var2)
    pst=Instr(stri,char)
    var1="":var2=""
    If pst<>0 Then
    var1=Mid(stri,1,pst-1)
    var2=Mid(stri,pst+1)
Else
    var1=stri
    End if
    #endmacro
    f=freefile
    Open file For Binary access read As #f
    'Dim As Integer count
    Dim As String text
    If Lof(f) > 0 Then
      text = String(Lof(f), 0)
      Get #f, , text
    End If
    Close #f
    splice(text,"|",var1,var2)
    text=var2
    passed_length=valint(var1)
    return text
end function



var text=getfile2(file)

dim as integer stringlength,destinationlength
stringlength=len(text)
destinationlength =passed_length

Dim As UByte Ptr source = Allocate(stringlength)
Dim As UByte Ptr destination =Allocate(destinationlength)

source=@text[0]

var mistake=uncompress(destination,@destinationlength, source, stringlength)
if mistake<>0 then print "There was an error":sleep:end
dim as string uncompressed

'Build the uncompressed string
uncompressed=string(destinationlength,0)

For i As Integer = 0 To destinationlength- 1
    uncompressed[i]=(destination[i])
Next

var filename=mid(temp(ubound(temp)),len(ubound(temp))-3)


f=freefile
open "UN_"+filename for output as #f
    print #f,uncompressed
close #f
print "The UNcompressed file is "&"UN_"+filename

print"Press any key"
'delete[] destination
'delete[] source
sleep

 
I've tested with many files including .exe.
I've yet to figure out how to compress a folder containing some files.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat

The reason I was working on compression was , that if you can outdo the others , you could get to be quite rich. Like Phil Katz and PKZIP / PKUNZIP , would become ARZIP / ARUNZIP

If I actually succeeded in a compression technique , I don't know if I would post it here , out of altruism , or even use FB to generate the *.exe , maybe I would use C or C++ and keep the source code as a company secret.

Maybe I would post it here though?
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Post by dodicat »

I'll have a think about speeding up base2.
There is another method, but I have forgotten it.

Altruism - (your code is for the benefit of others at your expense) --. But you want to get rich?
Altruism is most definitely out.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat

It was a failure , compression equaled file size , and I couldn't get it to uncompress to the right bytes.
About 2/3 of the file was correct but then I got a bunch of garbage at the end..

It was just a 2 byte SAR configuration.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Abstract doodle #584

Code: Select all

'abstract trig art #584

'Written if FreeBasic for Windows

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres,8,1,8
'===============================================================================
'===============================================================================
dim as double rad1=atn(1)/-45
dim as double deg1
dim as double deg1_start =  0
dim as double deg1_end   =360
dim as double deg1_inc   =  1


dim as double rad2=atn(1)/-180
dim as double deg2
dim as double deg2_start=  0
dim as double deg2_end  =360
dim as double deg2_inc  =  1

dim as double c1
dim as double c2
dim as double s1
dim as double s2

dim as double x1
dim as double y1
dim as double x2
dim as double y2

dim as double radius=175
dim as double xctr=xres/2
dim as double yctr=yres/2

for deg1 = 0 to 90 step .1
    
    c1=cos(deg1*rad1)
    s1=sin(deg1*rad1)
    
    x1=radius*c1-atn(log(tan(deg2*rad2*c2)/57))
    y1=radius*s1-atn(log(tan(deg2*rad2*c2)/57))
        
    for deg2 = 0 to 360 step 1
        
        c2 = cos(deg2*rad2*c1+deg2)
        s2 = sin(deg2*rad2*s1+deg2)
        
        x2=radius*c2^2-atn(log(tan(deg2*rad2*c2)/57))^10
        y2=radius*s2^2-atn(log(tan(deg2*rad2*c2)/57))^10
        
        pset( xctr+ (y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+ (y1+y2) ) , deg2
        pset( xctr+-(y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+ (y1+y2) ) , deg2
       
        pset( xctr+-(y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+-(y1+y2) ) , deg2
        pset( xctr+ (y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+-(y1+y2) ) , deg2
    
    next
    sleep 1

next

SLEEP
END

Abstract Doodle #585

Code: Select all

'abstract trig art #585

'Written if FreeBasic for Windows

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres,8,1,8
'===============================================================================
'===============================================================================
dim as double rad1=atn(1)/-45
dim as double deg1
dim as double deg1_start =  0
dim as double deg1_end   =360
dim as double deg1_inc   =  1


dim as double rad2=atn(1)/-180
dim as double deg2
dim as double deg2_start=  0
dim as double deg2_end  =360
dim as double deg2_inc  =  1

dim as double c1
dim as double c2
dim as double s1
dim as double s2

dim as double x1
dim as double y1
dim as double x2
dim as double y2

dim as double radius=175
dim as double xctr=xres/2
dim as double yctr=yres/2

for deg1 = 45 to 90 step .1
    
    c1=cos(deg1*rad1)
    s1=sin(deg1*rad1)
    
    x1=radius*c1-atn(log(tan(deg2*rad2*c2)/57))
    y1=radius*s1-atn(log(tan(deg2*rad2*c2)/57))
        
    for deg2 = 0 to 720 step 1
        
        c2 = cos(deg2*rad2*c1+deg2)
        s2 = sin(deg2*rad2*s1+deg2)
        
        x2=radius*c2^2-atn(log(tan(deg2*rad2*c2)/57))^10
        y2=radius*s2^2-atn(log(tan(deg2*rad2*c2)/57))^10
        
        pset( xctr+ (y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+ (y1+y2) ) , deg2
        pset( xctr+-(y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+ (y1+y2) ) , deg2
       
        pset( xctr+-(y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+-(y1+y2) ) , deg2
        pset( xctr+ (y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+-(y1+y2) ) , deg2
    
    next
    sleep 1

next

SLEEP
END

dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Post by dodicat »

Hi Albert.
Thanks for the new abstracts.
You alone are keeping Squares alive these days.
Where is everybody?
No arguments, no new theories, sorry about the compressor, maybe you'll get a working model soon.
The heart of squares i.e. the square heart still beats though.

Code: Select all


Type V3
    As Single x,y,z
    As Uinteger col
    Declare Function rotate(As V3,As V3,As V3) As V3
    Declare Function apply_perspective(As V3) As V3
End Type

Function V3.rotate(c As V3,angle As V3,scale As V3=Type<V3>(1,1,1)) As V3
    Dim As Single sx=Sin(angle.x),sy=Sin(angle.y),sz=Sin(angle.z)
    Dim As Single cx=Cos(angle.x),cy=Cos(angle.y),cz=Cos(angle.z)
    Dim As Single dx=this.x-c.x,dy=this.y-c.y,dz=this.z-c.z
    Return Type<V3>((scale.x)*((cy*cz)*dx+(-cx*sz+sx*sy*cz)*dy+(sx*sz+cx*sy*cz)*dz)+c.x,_
    (scale.y)*((cy*sz)*dx+(cx*cz+sx*sy*sz)*dy+(-sx*cz+cx*sy*sz)*dz)+c.y,_
    (scale.z)*((-sy)*dx+(sx*cy)*dy+(cx*cy)*dz)+c.z,this.col)
End Function

Function V3.apply_perspective(eyepoint As V3) As V3
    Dim As Single   w=1+(this.z/eyepoint.z)
    Return Type<V3>((this.x-eyepoint.x)/w+eyepoint.x,(this.y-eyepoint.y)/w+eyepoint.y,(this.z-eyepoint.z)/w+eyepoint.z,this.col)
End Function

Function length(v1 As V3,v2 As V3) As Single
    Return Sqr((v1.x-v2.x)*(v1.x-v2.x)+(v1.y-v2.y)*(v1.y-v2.y)+(v1.z-v2.z)*(v1.z-v2.z))
End Function

Sub Qsort(array() As V3,begin As Integer,Finish As Uinteger)
    Dim As Integer i=begin,j=finish 
    Dim As V3 x =array(((I+J)\2))
    While  I <= J
        While array(I).z > X.z:I+=1:Wend
            While array(J).z < X.z:J-=1:Wend
                If I<=J Then Swap array(I),array(J): I+=1:J-=1
            Wend
            If J > begin Then Qsort(array(),begin,J)
            If I < Finish Then Qsort(array(),I,Finish)
        End Sub
        
        
  '=================================================================      
        #define Intrange(f,l) Int(Rnd*((l+1)-(f))+(f))
        #define map(a,b,x,c,d) ((d)-(c))*((x)-(a))\((b)-(a))+(c)
        
        Dim As Integer num=25000
        Redim As V3 a(1 To num),r(1 To num)
        For n As Integer=1 To num
            With a(n)
                .x=IntRange(300,500)
                .y=IntRange(200,400)
                .z=IntRange(-100,100)
                var d=length(a(n),Type<V3>(400,300,0))
                .col=Rgb(255,255-d,d/2)
            End With
        Next n
        
        Screenres 800,600,32
        color ,rgb(255,255,255)
        Dim As V3 ang,centre=Type<V3>(400,300,0),eye=Type<V3>(400,300,500)
        Dim As Single sz=1,k=1
        Do
            sz=sz+.1*k
            If sz>2 Then k=-k
            If sz<1 Then k=-k
            ang=Type<V3>(ang.x+.01,ang.y+.01,ang.z+.01)
            For n As Integer=Lbound(a) To Ubound(a)
                r(n)=a(n).rotate(centre,ang,Type<V3>(1,1,sz))
                r(n)=r(n).apply_perspective(eye)
            Next n
            Qsort(r(),Lbound(r),Ubound(r))
            Screenlock
            Cls
            For n As Integer=Lbound(r) To Ubound(r)
                var rad=map(-100,100,r(n).z,4,2)
                Circle(r(n).x,r(n).y),rad,r(n).col,,,,f
            Next n
            Screenunlock
            Sleep 1,1
        Loop Until Len(Inkey)
        
         
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat

It looks like a nuclear reactor...

My compressor, in trying to make a dictionary , the size of it , is about half the file size, so I haven't got a working model yet.
It seems like I got a lot more brain storming to do.

I thought of making a bar chart of the data +-16 , and saving it as a small *.bmp's , I don't know if that would compress or not.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Abstract Doodle #586

Code: Select all

'abstract trig art #586

'Written in FreeBasic for Windows

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres,8,1,8
'===============================================================================
'===============================================================================
dim as double rad1=atn(1)/-45
dim as double deg1
dim as double deg1_start =  0
dim as double deg1_end   =360
dim as double deg1_inc   =  1


dim as double rad2=atn(1)/-45
dim as double deg2
dim as double deg2_start=  0
dim as double deg2_end  =360
dim as double deg2_inc  =  1

dim as double c1
dim as double c2
dim as double s1
dim as double s2

dim as double x1
dim as double y1
dim as double x2
dim as double y2

dim as double radius=150
dim as double xctr=xres/2
dim as double yctr=yres/2

for deg1 = 0 to 90 step 1
    
    c1=cos(deg1*rad1+deg1^50)
    s1=sin(deg1*rad1+deg1^50)
    
    x1=radius*c1
    y1=radius*s1
        
    for deg2 = 0 to 720 step .1
        
        c2 = cos(deg2*rad2+deg1)
        s2 = sin(deg2*rad2+deg1)
        
        x2=radius*c2-atn(log(tan(deg2*rad2*c2)/57))^10
        y2=radius*s2-atn(log(tan(deg2*rad2*c2)/57))^10
        
        pset( xctr+ (y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+ (y1+y2) ) , deg2
        pset( xctr+-(y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+ (y1+y2) ) , deg2
       
        pset( xctr+-(y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+-(y1+y2) ) , deg2
        pset( xctr+ (y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+-(y1+y2) ) , deg2
    
    next
    sleep 1

next

SLEEP
END

Cool cross shape.. I think it would look cool printed on T-Shirts

A little variant #587

Code: Select all

'abstract trig art #587

'Written if FreeBasic for Windows

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres,8,1,8
'===============================================================================
'===============================================================================
dim as double rad1=atn(1)/-45
dim as double deg1
dim as double deg1_start =  0
dim as double deg1_end   =360
dim as double deg1_inc   =  1


dim as double rad2=atn(1)/-45
dim as double deg2
dim as double deg2_start=  0
dim as double deg2_end  =360
dim as double deg2_inc  =  1

dim as double c1
dim as double c2
dim as double s1
dim as double s2

dim as double x1
dim as double y1
dim as double x2
dim as double y2

dim as double radius=150
dim as double xctr=xres/2
dim as double yctr=yres/2

for deg1 = 0 to 90 step 1
    
    c1=cos(deg1*rad1+deg1^50)
    s1=sin(deg1*rad1+deg1^50)
    
    x1=radius*c1
    y1=radius*s1-atn(log(tan(deg2*rad2*c1)/57))^10
        
    for deg2 = 0 to 720 step .1
        
        c2 = cos(deg2*rad2+deg1^10)
        s2 = sin(deg2*rad2+deg1^10)
        
        x2=radius*c2'-atn(log(tan(deg2*rad2*c2)/57))^10
        y2=radius*s2-atn(log(tan(deg2*rad2*c2)/57))^10
        
        pset( xctr+ (y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+ (y1+y2) ) , deg2
        pset( xctr+-(y1+y2) , yctr+ (x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+ (y1+y2) ) , deg2
       
        pset( xctr+-(y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+-(x1+x2) , yctr+-(y1+y2) ) , deg2
        pset( xctr+ (y1+y2) , yctr+-(x1+x2) ) , deg2
        pset( xctr+ (x1+x2) , yctr+-(y1+y2) ) , deg2
    
    next
    sleep 1

next

SLEEP
END

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Doodle #588

Code: Select all

'abstract trig art #588

'Written if FreeBasic for Windows

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres,8,1,8
'===============================================================================
'===============================================================================
dim as double rad1=atn(1)/-45
dim as double deg1
dim as double deg1_start =  0
dim as double deg1_end   =360
dim as double deg1_inc   =  1


dim as double rad2=atn(1)/-45
dim as double deg2
dim as double deg2_start=  0
dim as double deg2_end  =360
dim as double deg2_inc  =  1

dim as double c1
dim as double c2
dim as double s1
dim as double s2

dim as double x1
dim as double y1
dim as double x2
dim as double y2

dim as double radius=250
dim as double xctr=xres/2
dim as double yctr=yres/2

for deg1 = 0 to 360 step .1
    
    c1=cos(deg1*rad1)
    s1=sin(deg1*rad1)
    
    x1=radius*c1^50
    y1=radius*s1^50
        
    for deg2 = 0 to 90 step 5
        
        c2 = cos(deg2*rad2+deg2*rad2)
        s2 = sin(deg2*rad2+deg2*rad2)
        
        x2=radius*c2*c1*atan2(c1,c2)*-(atn(deg2*rad2*s1))
        y2=radius*s2*s1*atan2(s1,s2)*-(atn(deg2*rad2*c1))
        
        pset( xctr++(y1+x2) , yctr++(x1+y2) ) , 9
        pset( xctr++(x1+y2) , yctr++(y1+x2) ) , 9
    
        pset( xctr+-(y1+x2) , yctr+-(x1+y2) ) , 9
        pset( xctr+-(x1+y2) , yctr+-(y1+x2) ) , 9
    next
    
    sleep 1

next

SLEEP
END

Doodle #589

Code: Select all

'abstract trig art #589

'Written if FreeBasic for Windows

dim as integer xres,yres
'screen 19
screeninfo xres,yres
screenres xres,yres,8,1,8
'===============================================================================
'===============================================================================
dim as double rad1=atn(1)/-45
dim as double deg1
dim as double deg1_start =  0
dim as double deg1_end   =360
dim as double deg1_inc   =  1


dim as double rad2=atn(1)/-45
dim as double deg2
dim as double deg2_start=  0
dim as double deg2_end  =360
dim as double deg2_inc  =  1

dim as double c1
dim as double c2
dim as double s1
dim as double s2

dim as double x1
dim as double y1
dim as double x2
dim as double y2

dim as double radius=250
dim as double xctr=xres/2
dim as double yctr=yres/2

for deg1 = 0 to 360 step .1
    
    c1=cos(deg1*rad1)
    s1=sin(deg1*rad1)
    
    x1=radius*c1^50
    y1=radius*s1^50
        
    for deg2 = 0 to 180 step 5
        
        c2 = cos(deg2*rad2+deg2*rad2*2)
        s2 = sin(deg2*rad2+deg2*rad2*2)
        
        x2=radius*c2*c1^2
        y2=radius*s2*s1^2
        
        pset( xctr++(y1+x2) , yctr++(x1+y2) ) , 9
        pset( xctr++(x1+y2) , yctr++(y1+x2) ) , 9
    
        pset( xctr+-(y1+x2) , yctr+-(x1+y2) ) , 9
        pset( xctr+-(x1+y2) , yctr+-(y1+x2) ) , 9
    next
    
    sleep 1

next

SLEEP
END

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Richard

How do they do the integer mul in the processor in 1 clock cycle? is it just a lookup table?
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Post by dodicat »

Hi Albert
Hope all is well with Richard, he's been gone a while.
Hi Dafhi
I'm following your asm tutorial, but I'll not post there lest I muck up the continuity.
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: Squares

Post by dafhi »

don't worry about it. continuity is handled from first post.
like your 3d basket.
Locked