WindTurbine

From MHCGraphics

Jump to: navigation, search
; Mead example file - a wind turbine
; an example of an animation that can use
; relative transformations
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
;
; $Id: WindTurbine.scm 623 2008-04-11 01:39:49Z terescoj $
;
(require (lib "Defs.ss" "Mead"))

(define bladeLength 100)
(define bladeThickness (/ bladeLength 10))
(define supportHeight 200)
(define supportThickness (/ supportHeight 10))

; first, build a wind turbine blade (just a
; narrow cone for our purposes
(object blade Cone
        (scale .01 .01 .01)
        (scale bladeThickness bladeLength bladeThickness)
        (translate 0 (/ bladeLength 2) (/ supportThickness -2))
        )

; put three together in a group
(object threeBlades Group
        (add blade)
        (add blade (zRot 120))
        (add blade (zRot 240))
        )

; put together a turbine that sits upon the xz-plane
(object turbine Group
        (add threeBlades
             (translate 0 supportHeight 0))
        (add cylinder
             (scale .01 .01 .01)
             (scale supportThickness supportHeight supportThickness)
             (translate 0 (/ supportHeight 2) 0)
             )
        )

; put our turbine in the scene
(tell scene
      (add turbine whitePlastic)
      )

(tell image
      (background '(.5 .5 1))
      (fileName "WindTurbine")
      (frameNumber 0)
      (viewResult #f)
      )

; our adjustment function -- just moves the blades
; by rotating some number of degrees about z
(define (rotateBlade degreesPerFrame)
  ; note that this is a relativeXform!
  ; but our threeBlades object is not at the
  ; origin -- so why is this rotating properly?
  ; see the animation topic notes for more!
  (tell threeBlades (zRot degreesPerFrame))
  )

(tell camera
      (pos '(0 200 -500))
      (coi (list 0 supportHeight 0))
      (film 60 rotateBlade 2)
      (buildMovie)
      )
Personal tools