Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Mandelbrot and the Heart of Mathematics
Author | Message | ||||
Goksteroo Senior Member Joined: 15/03/2021 Location: AustraliaPosts: 110 |
A long time ago I watched this video on YouTube and was fascinated by the animations he produced - very hypnotic. https://www.youtube.com/watch?v=qhbuKbxJsk8 This video is not new and I was reminded of it when I saw a short Basic program on FaceBook to reproduce the graphics/animations. Of course I had to convert it to MMBasic. My CMM2 has issues so I have used MMB4W, but it should work on all versions with minor changes. Adjustable parameters are explained in REMs. Animation will pause while any key is pressed. Enjoy. Geoff OPTION ANGLE radians option default float ' Times Tables, Mandelbrot and the Heart of Mathematics ' https://www.youtube.com/watch?v=qhbuKbxJsk8 ' ' Modified to MMBasic ' ' Adjust parameters for your version of MM Basic/hardware. ' Initial parameters work well for MMB4W and a Gen12 I5 CPU ' Fast frame rates can skip frames and make the animation ugly! ' Slow frame rate 'til you get the best looking animation ' ' Parameters to change that effect animation quality and speed: mode -16 ' higher res looks better but is slower to draw n=400 ' number of points around the circle used in calculations ' 100 looks poor, 200 looks OK, 400 looks good, 800 very very nice del=5 ' up or down to slow frame rate for nice animation t_up=0.01' step around circle - 0.01 is good, try other values cx=MM.HRES/2 cy=MM.VRES/2 s=(2*PI)/n t=1 do page write 1 cls rgb(0,60,0) circle cx,cy,cy+2,2,1,rgb(black),rgb(0,0,80) for i=1 to n a1=s*i a2=s*i*t line cx+sin(a1)*cy,cy+cos(a1)*cy,cx+sin(a2)*cy,cy+cos(a2)*cy,1,rgb(salmon) next i print @(0,0) t inc t,t_up page copy 1 to 0,b do loop until keydown(1)=0 ' any key to pause and admire screen! pause del loop |
||||
Pluto Guru Joined: 09/06/2017 Location: FinlandPosts: 330 |
I am completely hypnotized! Nice! |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
Try this on the PicoMiteVGA. The ant-aliased lines have a nice (but slow) effect. Use OPTION CPUSPEED 378000 to avoid boredom Option default float ' Times Tables, Mandelbrot and the Heart of Mathematics ' https://www.youtube.com/watch?v=qhbuKbxJsk8 ' ' Modified to MMBasic ' ' Adjust parameters for your version of MM Basic/hardware. ' Initial parameters work well for MMB4W and a Gen12 I5 CPU ' Fast frame rates can skip frames and make the animation ugly! ' Slow frame rate 'til you get the best looking animation ' ' Parameters to change that effect animation quality and speed: MODE 2 ' higher res looks better but is slower to draw n=200 ' number of points around the circle used in calculations ' 100 looks poor, 200 looks OK, 400 looks good, 800 very very nice del=5 ' up or down to slow frame rate for nice animation t_up=0.01' step around circle - 0.01 is good, try other values cx=MM.HRes/2 cy=MM.VRes/2 s=(2*Pi)/n t=1 FRAMEBUFFER create Do FRAMEBUFFER write f CLS RGB(0,60,0) Circle cx,cy,cy+2,2,1,RGB(black),RGB(0,0,80) For i=1 To n a1=s*i a2=s*i*t Line AA cx+Sin(a1)*cy,cy+Cos(a1)*cy,cx+Sin(a2)*cy,cy+Cos(a2)*cy,1,RGB(green) Next i Print @(0,0) t Inc t,t_up FRAMEBUFFER copy f,n,b Loop Edited 2023-01-09 23:18 by matherp |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2870 |
Hi Goksteroo, What is the issue with your CMM2? I am in Melbourne if you would like me to look at it for you. If it is the main ARM chip though then I can’t help as there is no stock anywhere. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 904 |
here my adapted version for PicoMite CPUSPEED 378000 in Mode 1 ' Times Tables, Mandelbrot and the Heart of Mathematics ' https://www.youtube.com/watch?v=qhbuKbxJsk8 ' ' Modified to MMBasic ' ' Adjust parameters for your version of MM Basic/hardware. ' Initial parameters work well for MMB4W and a Gen12 I5 CPU ' Fast frame rates can skip frames and make the animation ugly! ' Slow frame rate 'til you get the best looking animation ' ' Parameters to change that effect animation quality and speed: MODE 1 ' higher res looks better but is slower to draw Dim i% As integer n=180 ' number of points around the circle used in calculations ' 100 looks poor, 200 looks OK, 400 looks good, 800 very very nice del=5 ' up or down to slow frame rate for nice animation t_up=0.02' step around circle - 0.01 is good, try other values cx=MM.HRes/2 cy=MM.VRes/2 s=(2*Pi)/n t=1 FRAMEBUFFER create Do FRAMEBUFFER write f Circle cx,cy,cy+2,2,1,RGB(white),RGB(black) For i%=1 To n: a1=s*i: a2=s*i*t Line cx+Sin(a1)*cy,cy+Cos(a1)*cy,cx+Sin(a2)*cy,cy+Cos(a2)*cy,1,RGB(white):Next Print @(0,0) t Inc t,t_up FRAMEBUFFER copy f,n Loop Edited 2023-01-11 23:28 by Martin H. 'no comment |
||||
Goksteroo Senior Member Joined: 15/03/2021 Location: AustraliaPosts: 110 |
Thanks for the offer of help Mick - very much appreciated. Fortunately 'fixing' the CMM2 is not the issue - it's the fact that I've taken the monitor and keyboard and mouse off the Maximite to fix issues the wife had with her computer. My problem is actually getting out of the house to replace those items. Hasn't been a priority for me as I've been able to use MMB4W to do the jobs I want it to as I'm only an amateur programmer, usually for my own use, and don't use the CMM2 to control any other devices. I fit the definition of a procrastinator! Again, thanks for you very kind offer. Geoff |
||||
Bleep Guru Joined: 09/01/2022 Location: United KingdomPosts: 414 |
Hi Peter, If I use Martins method of only clearing the circle, not a full CLS, if you run your AA version for a few minutes you get artefacts outside the circle, straight vertical or horizontal lines. Remove the AA option and you don't get these. This is on a VGA Picomite. Regards, Kevin. Option default float ' Times Tables, Mandelbrot and the Heart of Mathematics ' https://www.youtube.com/watch?v=qhbuKbxJsk8 ' ' Modified to MMBasic ' ' Adjust parameters for your version of MM Basic/hardware. ' Initial parameters work well for MMB4W and a Gen12 I5 CPU ' Fast frame rates can skip frames and make the animation ugly! ' Slow frame rate 'til you get the best looking animation ' ' Parameters to change that effect animation quality and speed: MODE 2 ' higher res looks better but is slower to draw Dim Integer n=150 ' number of points around the circle used in calculations ' 100 looks poor, 200 looks OK, 400 looks good, 800 very very nice t_up=0.01' step around circle - 0.01 is good, try other values Const cx=MM.HRes/2 Const cy=MM.VRes/2 s=(2*Pi)/n t=1 FRAMEBUFFER create Do FRAMEBUFFER write f Circle cx,cy,cy+2,2,1,RGB(0,0,80),RGB(black) For i=1 To n a1=s*i a2=a1*t Line AA cx+Sin(a1)*cy,cy+Cos(a1)*cy,cx+Sin(a2)*cy,cy+Cos(a2)*cy,1,RGB(green) Next Print @(0,0) t Inc t,t_up FRAMEBUFFER copy f,n Loop |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
The AA line drawing algorithm doesn't terminate the lines in a way related to the angle but chooses a vertical or horizontal depending on the slope. See the pics here |
||||
Bleep Guru Joined: 09/01/2022 Location: United KingdomPosts: 414 |
Ok, but these are long lines, sometimes all the way to the screen edge. |
||||
Goksteroo Senior Member Joined: 15/03/2021 Location: AustraliaPosts: 110 |
Here is a pic to show the artifacts when using LINE AA - at least with MMB4W. This is done with a line width of 4. Note there are also extra pixels within the circle as well. Geoff |
||||
Bleep Guru Joined: 09/01/2022 Location: United KingdomPosts: 414 |
Hi Peter, Thanks for the update with some Pixel drawing fixes, they don't seem to have cured my horizontal and vertical artefacts when using AA, see photo, if you run the code above they will start to appear within a minute or two, at least the do on my Pico. Regards, Kevin. PicoMiteVGA MMBasic Version 5.07.07b3 OPTION SYSTEM I2C GP22,GP15 OPTION COLOURCODE ON OPTION KEYBOARD UK OPTION CPUSPEED (KHz) 378000 OPTION DEFAULT MODE 2 OPTION SDCARD GP5, GP2, GP3, GP4 OPTION AUDIO GP6,GP7, ON PWM CHANNEL 3 OPTION RTC AUTO ENABLE OPTION F6 Edit 1 OPTION F7 Edit 2 OPTION DEFAULT FONT 8, 1 |
||||
Print this page |