[Fluxus] pfunc question

Dave Griffiths dave at pawfal.org
Thu Apr 2 07:42:14 PDT 2009


Hi Gabor,

Thats probably the only way to do it right now. This whole area is quite
interesting I think, as it's almost like we need a language to describe
simd operations on pdata from scheme.

In the meantime, more pragmatically speaking - we probably want to make
a collection of these pfunc operations where they become necessary. I
think this is a common enough problem to warrant a 'lerp' pfunc to be
made.

cheers,

dave

On Wed, 2009-04-01 at 14:48 +0200, gabor papp wrote:
> i'm trying to get accustomed to pfunc. i'm trying to use it to
> interpolate between two sets of positions ("p0" and "p1"). i guess this
> cannot be done with pdata-op. am i right? i had to use 3 pfuncs and 2
> temporary pdata fields to do this. "t0" = (1 - t) * "p0", "t1" = t *
> "p1", and "p" = "t0" + "t1". is there a simpler way?
> 
> best,
> gabor
> 
> ;----------------------------------
> (clear)
> 
> (define p (build-particles 256))
> 
> (with-primitive p
>     ; pdata storing positions to interpolate between
>     (pdata-add "p0" "v")
>     (pdata-add "p1" "v")
>     ; random sphere
>     (pdata-map! (lambda (p) (srndvec)) "p0")
>     ; random cube
>     (pdata-map! (lambda (p) (crndvec)) "p1")
>     ; temporary data for interpolation
>     (pdata-add "t0" "v")
>     (pdata-add "t1" "v")
>     (pdata-map! (lambda (c) (vector 1 .5)) "c"))
> 
> (define p0f (make-pfunc 'arithmetic))
> (define p1f (make-pfunc 'arithmetic))
> (define pf (make-pfunc 'arithmetic))
> 
> ; p = t0 + t1
> (pfunc-set! pf (list 'operator "add"
>                      'src "t0"
>                      'other "t1"
>                      'dst "p"))
> 
> (define (animate)
>     (let ([t (+ .5 (* .5 (sin (time))))])
>         ; t0 = (1 - t) * p0
>         (pfunc-set! p0f (list 'operator "mul"
>                               'src "p0"
>                               'constant (- 1 t)
>                               'dst "t0"))
>         ; t1 = t * p1
>         (pfunc-set! p1f (list 'operator "mul"
>                               'src "p1"
>                               'constant t
>                               'dst "t1"))
>         (with-primitive p
>             (pfunc-run p0f)
> 	    (pfunc-run p1f)
>             (pfunc-run pf))))
> 
> (every-frame (animate))
> 




More information about the Fluxus mailing list