Basic Sierpinski triangle fractal demo

#1CanisLupis78Posted 9/22/2012 10:48:15 PM
This uses Chaos Game method to plot points. Still working on understanding the formulas for the Mandlebrot and Julia sets.

ACLS:CLEAR
X2=127:Y2=95
@MAIN
V=RND(3)
IF V==0 THEN X=0:Y=191:C=2
IF V==1 THEN X=255:Y=191:C=4
IF V==2 THEN X=127:Y=0:C=8
X2=(X2+X)/2:Y2=(Y2+Y)/2
GPSET X2,Y2,C
GOTO @MAIN
#2Lovelife090994Posted 9/23/2012 6:10:57 AM
CanisLupis78 posted...
This uses Chaos Game method to plot points. Still working on understanding the formulas for the Mandlebrot and Julia sets.

ACLS:CLEAR
X2=127:Y2=95
@MAIN
V=RND(3)
IF V==0 THEN X=0:Y=191:C=2
IF V==1 THEN X=255:Y=191:C=4
IF V==2 THEN X=127:Y=0:C=8
X2=(X2+X)/2:Y2=(Y2+Y)/2
GPSET X2,Y2,C
GOTO @MAIN


I love it!
---
I follow The Divine, His Majesty in Heaven, of the Heavens and the Earth.
If you never ask you'll never know, if you ask but never know, you gain insight.
#3SamKitsunePosted 9/23/2012 9:30:45 AM
That's great! I do like seeing something like this, knowing that anyone can make artworks out of math. I would like to try, but . . . I'm caught on the game I'm working on. Hehe!
#4CanisLupis78(Topic Creator)Posted 9/23/2012 5:06:21 PM
I have an updated version that allows you to make your own fractals by plotting points on the touch screen. It makes some very cool designs. I'll need to get to a computer and post the QR code. Sadly, I keep getting overflow errors while trying to use the Julia set or Mandlebrot set. The numbers get too big for Petit Computer to handle. If anyone knows a lot about coding the Julia or Mandlebrot set, send me a PM. I'd like to pick your brain.
#5metagross111Posted 9/23/2012 5:51:07 PM
From: CanisLupis78 | #004
I have an updated version that allows you to make your own fractals by plotting points on the touch screen. It makes some very cool designs. I'll need to get to a computer and post the QR code. Sadly, I keep getting overflow errors while trying to use the Julia set or Mandlebrot set. The numbers get too big for Petit Computer to handle. If anyone knows a lot about coding the Julia or Mandlebrot set, send me a PM. I'd like to pick your brain.



I would love to see this.
---
Heck no. I absolutely despise good decks. --- soccerprodi
#6snailfaqsPosted 9/23/2012 5:51:50 PM
CanisLupis78 posted...
I have an updated version that allows you to make your own fractals by plotting points on the touch screen. It makes some very cool designs. I'll need to get to a computer and post the QR code. Sadly, I keep getting overflow errors while trying to use the Julia set or Mandlebrot set. The numbers get too big for Petit Computer to handle. If anyone knows a lot about coding the Julia or Mandlebrot set, send me a PM. I'd like to pick your brain.

Use this pseudocode from wikipedia -- it should set you in the right direction. If that isn't enough help, you can find my example qr by googling "gbatemp petit mandelbrot".
(post #12)


For each pixel on the screen do:
{
x0 = scaled x coordinate of pixel (must be scaled to lie somewhere in the mandelbrot X scale (-2.5, 1)
y0 = scaled y coordinate of pixel (must be scaled to lie somewhere in the mandelbrot Y scale (-1, 1)

x = 0
y = 0

iteration = 0
max_iteration = 1000

while ( x*x + y*y < 2*2 AND iteration < max_iteration )
{
xtemp = x*x - y*y + x0
y = 2*x*y + y0

x = xtemp

iteration = iteration + 1
}

color = iteration

plot(x0,y0,color)
}


Hope this helps : )
#7CanisLupis78(Topic Creator)Posted 9/23/2012 6:16:56 PM
snailfaqs posted...
CanisLupis78 posted...
I have an updated version that allows you to make your own fractals by plotting points on the touch screen. It makes some very cool designs. I'll need to get to a computer and post the QR code. Sadly, I keep getting overflow errors while trying to use the Julia set or Mandlebrot set. The numbers get too big for Petit Computer to handle. If anyone knows a lot about coding the Julia or Mandlebrot set, send me a PM. I'd like to pick your brain.

Use this pseudocode from wikipedia -- it should set you in the right direction. If that isn't enough help, you can find my example qr by googling "gbatemp petit mandelbrot".
(post #12)


For each pixel on the screen do:
{
x0 = scaled x coordinate of pixel (must be scaled to lie somewhere in the mandelbrot X scale (-2.5, 1)
y0 = scaled y coordinate of pixel (must be scaled to lie somewhere in the mandelbrot Y scale (-1, 1)

x = 0
y = 0

iteration = 0
max_iteration = 1000

while ( x*x + y*y < 2*2 AND iteration < max_iteration )
{
xtemp = x*x - y*y + x0
y = 2*x*y + y0

x = xtemp

iteration = iteration + 1
}

color = iteration

plot(x0,y0,color)
}


Hope this helps : )


Awesome. I tried a few different QBASIC ports for Julia sets, same overflow errors. From you QR code and port it obviously can be done without overflow problems. Thanks that helps a lot.
#8Lovelife090994Posted 9/24/2012 5:10:27 PM
Funny, Fractals is my plan for a fractal puzzle game...
/3 /5
1-2---3
\3 \5
Add previous number, branch and again for the puzzle complete
---
I follow The Divine, His Majesty in Heaven, of the Heavens and the Earth.
If you never ask you'll never know, if you ask but never know, you gain insight.
#9Lovelife090994Posted 9/25/2012 4:51:34 PM
'FRACTIOUS FRACTAL PUZZLES
'---DISABLE-BEEPS-CLS-SCREEN---
ACLS:CLS
SYSBEEP=FALSE
'---END-DISABLE-MARKER---

'---LOADING?---
@LOADING
ACLS:CLS
WAIT 10
BEEP 2
LOAD"GRP0:WHORUBG1",FALSE
LOCATE 6,5:COLOR 0:PRINT "LOADING..."
WAIT 180
BEEP 4
ACLS:CLS
GOTO @MAINFR
'---END-LOADING?---

'---MAIN-PAGE1-BELOW---
@MAINFR
'---DECORATIVE BANNER
(A DECORATIVE TEXT I CAN'T TYPE!)
'---END DECORATIVE BANNER---

'----MENU


'----END MENU

'----------END-MAIN PAGE1-----

'----DEMO
@SHOWME
ACLS:CLS
(PLANNED SPRITE APPEAR AND DISAPPEAR DEMONSTRATION)

'----END DEMO----

'---INFO---
@INFO
ACLS:CLS

'----END INFO

'-----PLAY
@PLAY
(PUZZLES HERE)

'-----END-PLAY

'END

This is a print (sort-of) of what I am working on, I may post a QR to www.artboy-2.deviantart.com and I need to figure out how my fractal puzzles will work.
I know how fractals work in math, but I need to figure out how to have it as an INPUT.
0,1,1,2,3,5,7,11,18,29,47,76... so on, adding the two previous numbers for the next, this seems easy but I will manipulate it to be in a puzzle. I think I can do this with INPUT and PRINTS for the (/) to imitate branches but later I will do this...
---
I follow The Divine, His Majesty in Heaven, of the Heavens and the Earth.
If you never ask you'll never know, if you ask but never know, you gain insight.
#10CanisLupis78(Topic Creator)Posted 9/25/2012 6:57:46 PM
Lovelife090994 posted...
'FRACTIOUS FRACTAL PUZZLES
'---DISABLE-BEEPS-CLS-SCREEN---
ACLS:CLS
SYSBEEP=FALSE
'---END-DISABLE-MARKER---

'---LOADING?---
@LOADING
ACLS:CLS
WAIT 10
BEEP 2
LOAD"GRP0:WHORUBG1",FALSE
LOCATE 6,5:COLOR 0:PRINT "LOADING..."
WAIT 180
BEEP 4
ACLS:CLS
GOTO @MAINFR
'---END-LOADING?---

'---MAIN-PAGE1-BELOW---
@MAINFR
'---DECORATIVE BANNER
(A DECORATIVE TEXT I CAN'T TYPE!)
'---END DECORATIVE BANNER---

'----MENU


'----END MENU

'----------END-MAIN PAGE1-----

'----DEMO
@SHOWME
ACLS:CLS
(PLANNED SPRITE APPEAR AND DISAPPEAR DEMONSTRATION)

'----END DEMO----

'---INFO---
@INFO
ACLS:CLS

'----END INFO

'-----PLAY
@PLAY
(PUZZLES HERE)

'-----END-PLAY

'END

This is a print (sort-of) of what I am working on, I may post a QR to www.artboy-2.deviantart.com and I need to figure out how my fractal puzzles will work.
I know how fractals work in math, but I need to figure out how to have it as an INPUT.
0,1,1,2,3,5,7,11,18,29,47,76... so on, adding the two previous numbers for the next, this seems easy but I will manipulate it to be in a puzzle. I think I can do this with INPUT and PRINTS for the (/) to imitate branches but later I will do this...


This all depends on the type of fractals you want to use. my example is one of the most simple to program. EX:
1. set 3 points on the screen in a triangle shape.
2. Pick a point inside of the triangle.
3. Pick one of the triangle corner points(vertices?) at random.
4. Move your point halfway to any of the corners and plot it(GPSET)
5. Take this new point and run it through the same process by going to step 4

Simple as that. That method for plotting points in that fractal is called the "Chaos Game"

For the more complex fractals like the julia or mandlebrot, you need to understand "complex" numbers and the new rules they follow. You end up running each pixel on the screen through several operations. More iterations means more operations per pixel and higher detail. The problem is that basic is not very effective crunching that many numbers at a time. The effect is a very slow render of any complex fractal.