Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Created January 27, 2010 00:29
Show Gist options
  • Save dharmatech/287412 to your computer and use it in GitHub Desktop.
Save dharmatech/287412 to your computer and use it in GitHub Desktop.
(import (rnrs)
(gl)
(glut)
(agave glu)
(agave glamour window)
(agave glamour misc)
(agave glamour mouse))
(initialize-glut)
(window (size 500 500)
(title "R[ sin( theta + i * phi ) ]")
(reshape (width height)
(lambda (w h)
(glLoadIdentity)
(glFrustum -1.0 1.0 -1.0 1.0 1.5 20.0))))
(define mouse-x 0.0)
(define mouse-y 0.0)
(glutPassiveMotionFunc
(lambda (x y)
(set! mouse-x x)
;; (set! mouse-y y)
(set! mouse-y (- height y))
(glutPostRedisplay)))
(define pi 3.14159265358979323846)
(define two-pi (* 2 pi))
(define (deg x)
(* x (/ 180.0 pi)))
(define (rad x)
(* x (/ pi 180.0)))
(buffered-display-procedure
(lambda ()
(background 0.0)
;; viewing transformation
(gluLookAt (* 5 (sin (* (/ mouse-x width) two-pi)))
(+ -5.0 (* (/ mouse-y height) 10.0))
(* 5 (cos (* (/ mouse-x width) two-pi)))
0.0 0.0 0.0
0.0 1.0 0.0)
;; modeling transformation
(glColor3d 1.0 1.0 1.0)
(do ((phi (* -1/4 two-pi) (+ phi (* 1/20 two-pi))))
((> phi (* 1/4 two-pi)))
(gl-begin GL_LINE_STRIP
(do ((theta 0.0 (+ theta (* 1/100 two-pi))))
((>= theta two-pi))
(let ((radius (real-part (sin (+ theta (* 1i phi))))))
(glVertex3d (* radius (sin theta) (cos phi))
(* radius (sin theta) (sin phi))
(* radius (cos theta)))))))
(do ((theta 0.0 (+ theta (* 1/100 two-pi))))
((>= theta two-pi))
(gl-begin GL_LINE_STRIP
(do ((phi (* -1/4 two-pi) (+ phi (* 1/20 two-pi))))
((> phi (* 1/4 two-pi)))
(let ((radius (real-part (sin (+ theta (* 1i phi))))))
(glVertex3d (* radius (sin theta) (cos phi))
(* radius (sin theta) (sin phi))
(* radius (cos theta)))))))
))
(glutMainLoop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment