[fluxus] vector->list ?

Dave Griffiths dave at pawfal.org
Wed Jul 12 01:57:14 PDT 2006


Hi Claude,

> I tried to do something like this:
>
> ;-----------
> (define (point-func v)
>    (let ((l (vector->list v)))
>      (let ((x (car l)) (y (car (cdr l))) (z (car (cdr (cdr l)))))
>        (vector (f1 x y z) (f2 x y z) (f3 x y z))
>      )
>    )
> )
> (define (point-iter n)
>     (pdata-set "t" n (point-func (pdata-get "t" n)))
>     (if (< n 1) 0 (point-iter (- n 1)))
> )
> ;-----------
>
> and got error messages like:
>
> ERROR: Wrong type (expecting non-uniform array): #f32(0.0 0.0 0.0)
>
> I found a method that works, which is actually more human-readable:
>
> ;-----------
> (let ((x (vdot v (vector 1 0 0)))
>        (y (vdot v (vector 0 1 0)))
>        (z (vdot v (vector 0 0 1))))
>    ...
> )
> ;-----------
>
> but I was wondering whether there was something to directly index a
> vector?

I think what you are after is commonly:

(vector-ref vector index)
and
(vector-set! vector index value)

but as fluxus reads/writes 32bit float vectors you have to use:

(f32vector-ref vector index)
and
(f32vector-set! vector index value)

The typed vectors are much faster to use (the elements are contiguous
memory) but they are treated as a different type. I haven't had a
definitive answer why from the guile list yet, perhaps I should ask again.

> Anyway, here are some images (well, one so far) made with texture
> warping, plus the texture I used:
>
> http://claudiusmaximus.goto10.org/index.php?page=gallery/digital/cyclepix
>
> (code forthcoming as soon as I remember how to save it ;-)).

ctrl s?
great to see some pics :)

cheers,

dave




More information about the Fluxus mailing list