SineBall

From MHCGraphics

Jump to: navigation, search
; Mead example file -- a ball tracing out a path defined
; by a sine wave
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
;
; $Id: SineBall.scm 643 2008-04-20 19:04:45Z terescoj $
;
(require (lib "Defs.ss" "Mead"))

; Some image settings appropriate for animations
(tell image
      (fileName "SineBall")
      (frameNumber 0)
      (viewResult #f)
      (background white)
      )

; make a little red sphere
(object littleRedSphere Sphere
        (scale .1 .1 .1)
        (material redPlaster)
        )

; and put it in the scene -- we'll position it later
; also remember a name for this instance so we don't
; have to re-scale it at each step of the way
(define ball
  (tell scene (add littleRedSphere))
)

(define pi 3.14159265358979323846264338327950288) ; or so

; our adjustment function will position the ball
; for a given theta at ((* 50 theta) (* 100 (sin theta)) 0)
(define (sinBall theta)
  (tell ball
        (absoluteXform
         (translate (* 50 theta) (* 100 (sin theta)) 0)
         )
        )
  )

(tell camera
      (angle 80)
      ; film from -2*pi to 2*pi
      (film 100 sinBall (list (* -2 pi) (* 2 pi)))
      (buildMovie)
      )
Personal tools