Author Topic: Gauche Scheme  (Read 15364 times)

0 Members and 3 Guests are viewing this topic.

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #45 on: February 02, 2015, 03:49:31 PM »
Hi John,

A Rose with Julia -- I'm afraid not , the problem is  that Julia generates an infinite number of attractors (except C=(0,0) and then it only will generate (boring) concentric circles)  --  but a rose within a rose ...  within a rose ... etc , yes. 
But , I can work something out   ( i need a few days for it --  only a few years ago they could make some code generating a (more or less realistic) snow flake ..

there are more than enough tries around :
http://th04.deviantart.net/fs70/PRE/f/2011/122/1/f/fractal_rose_by_thorbet-d3fetl3.png

but these are not petal shapes (but of course beautiful)

let's try

Rob



JRS

  • Guest
Re: Gauche Scheme
« Reply #46 on: February 02, 2015, 03:58:34 PM »
WOW!

I'm already happy with that. If you can improve on that rose, I'm sitting on the edge of my chair.  :)

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #47 on: February 05, 2015, 07:58:46 AM »
Well, I started with the basics ..

found a formula that generates something flower like , it's based on the cardiode , but i changed the parameter that does the cycles ( 6 i.o. 2)
This is just a shape, the gradients , distortions , rotations , scaling etc come later.

but, but - written in Racket Scheme - i'm very surprised how slow this language is (you will notice when running the code (Win32 or Wine) )
The whole concept of Racket imho is very academic

: colors are objects
: for gaining some speed I work on a bitmap -- to be able to transfer the bitmap to the canvas you have to set up a callback which is triggered by on-paint
: the pixel setting on the bmp is also slow -- this should give hope there is some boundery checking,but there is none

(any good scripting language should outperform this ...  )

: the processor activity during editing , coding , running any scheme source is upto the limit any time.

maybe not the good start for a rose --  more a papaver/poppy --  but in my langauge it is called " klaproos or kollenbloem " (kol = heks = old english hex i think   ...    so a hexflower

patience is needed when running attached code (wine or win32)   -- it's nothing yet , just the geometry


best Rob

.

JRS

  • Guest
Re: Gauche Scheme
« Reply #48 on: February 05, 2015, 10:59:33 AM »
Looks like a great start Rob! Please keep us updated as this unfolds.


Mike Lobanovsky

  • Guest
Re: Gauche Scheme
« Reply #49 on: February 06, 2015, 12:41:56 AM »
Awesome indeed! Can't wait to see the final shape. :)

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #50 on: February 06, 2015, 02:42:03 AM »
Thanks  ;)

In glorious 3D now - mixed it with a paraboloid (Z value) --  compiled with GFA under Wine (the nice thing is , here the hlp files do work)

More later - the number of petals can be changed now (not included in the interface) -- compositions next (spirals , concentric etc ...)


best Rob
(will convert to Gauche as a test - already around 110.000 points calculated)

added : the exec. 9 petals  (somewhat nicer)  -- runs from the flower3D.exe locations 

addendum : the Gauche Scheme script -- amazingly fast speed (measured on setting up the GL_COMPILE list ) -- easy interface :
use the mouse to start / stop rotation (left/right)  -- (display (number->string pi))  may be removed from the script (just checking the value)
identical script runs on Win32 / Wine / Linux
-------------------------------
(use gl)
(use gl.glut)

(define pi (* 2.0 (acos 0)))

(display (number->string pi))

(define (Fflower a t nr)
  (let ((x (* a (- (* nr (cos t)) (cos (* nr t)))))
        (y (* a (- (* nr (sin t)) (sin (* nr t)))))
        (z (* a a 0.5) ))
    (list x y z)))


(define *spin* 0.0)
(define *title* "Left mouse to start rotation - Right to stop")

(define (init)
  (gl-clear-color 0.0 0.0 0.0 0.0)
  (gl-shade-model GL_FLAT)
  )

(define (make-list)
   (gl-new-list 1 GL_COMPILE)
   (gl-begin GL_POINTS)
     
     (do ((a 0.2 (+ a 0.06)))
      ((> a 5.0))
      (do ((t 0.0 (+ t (/ pi 500))))
        ((> t (* 2 pi)))
      (let ((res (Fflower a t 8.0)) (color (/ a 5.0)) )
      (gl-color color (- 1 color) 0.0)
      (gl-vertex (car res) (cadr res) (caddr res) ))))
   (gl-end)
   (gl-end-list))   



(define (disp)
  (gl-clear GL_COLOR_BUFFER_BIT)
  (gl-push-matrix)
 
  (gl-rotate *spin* 1.0 1.0 1.0)
  (gl-call-list 1)
  (gl-pop-matrix)
  (glut-swap-buffers)
  )

(define (spin-display)
  (set! *spin* (modulo (+ *spin* 2.0) 360.0))
  (glut-post-redisplay)
  )

(define (reshape w h)
  (gl-viewport 0 0 w h)
  (gl-matrix-mode GL_PROJECTION)
  (gl-load-identity)
  (gl-ortho -50.0 50.0 -50.0 50.0 -100.0 100.0)
  (gl-matrix-mode GL_MODELVIEW)
  (gl-load-identity)
  )

(define (mouse button state x y)
  (cond
    ((= button GLUT_LEFT_BUTTON)
     (when (= state GLUT_DOWN) (glut-idle-func spin-display)))
    ((= button GLUT_RIGHT_BUTTON)
     (when (= state GLUT_DOWN) (glut-idle-func #f))))
  )

(define (keyboard key x y)
  (cond
   ((= key 27) (exit 0))
   ))

(define (main args)
  (glut-init args)
  (glut-init-display-mode (logior GLUT_DOUBLE GLUT_RGB))
  (glut-init-window-size 500 500)
  (glut-init-window-position 100 100)
  (glut-create-window *title*)
  (init)
  (glut-display-func disp)
  (glut-reshape-func reshape)
  (glut-keyboard-func keyboard)
  (glut-mouse-func mouse)
  (make-list)
  (glut-main-loop)
  0)
---------------------------------------------------------------------

.
« Last Edit: February 06, 2015, 08:56:38 AM by RobbeK »

JRS

  • Guest
Re: Gauche Scheme
« Reply #51 on: February 06, 2015, 11:19:42 AM »
I see this trending to an animated bloom.  8)

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #52 on: February 07, 2015, 05:41:15 AM »
possibly it may become a late bloomer  8)

What's your opinion about the tk interface , John --  something worthy -- it only needs one scm source into the lib directory , very easy (tk/tcl should be present on most UNIX distributions)


attached the scm script ,  changed to solids now (quads) -- everything ready to produce some more complex (even fractal) constructions.
Possibly input interfacing with the ogl windows is too devious ??  (some buttons, textfields could be set up -- in the examples there's something with bitmap font char's that can be used )

best Rob   

already made something worth looking at :  compoFlower.scm (imho a good start for some serious work)

.
« Last Edit: February 07, 2015, 06:28:02 AM by RobbeK »