build_pyramid   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/external/xtmrender4.xtm

Implementation

(bind-func build_pyramid
  (lambda (size:float)
    (let ((dat:float* (salloc (* 3 12)))
          (height (sqrt (- (* size size) (* (* .5 size) (* .5 size)))))
          (hp (* height .5)) (hn (* height -.5))
          (n (* -0.5 size)) (p (* 0.5 size)))
      ;; 0  0. hp 0.
      ;; 1  p  hn p
      ;; 2  n  hn p
      ;; 3  0. hn n
      (pfill! dat
              p hn p n hn p 0. hp 0.  ;; 1 2 0
              0. hn n 0. hp 0. n hn p ;; 3 0 2
              n hn p p hn p 0. hn n   ;; 2 1 3
              p hn p 0. hp 0. 0. hn n ;; 1 0 3
              )
      (xtm_make_model (Str "pyramid") dat 12 1.0 0.0 1.0))))


Back to Index

Similar Entries