[Fluxus] how to get the local rotation of a primitive as a vector??
Rob Bothof
rbothof at xs4all.nl
Tue Jan 26 06:54:31 PST 2010
thanx!
this is helpful
For finally setting the rotation i am using the (maim) matrix-aim
function, but the birds are still flipping over their backs from time to
time
I've been reading on quaternions but this is still beyond my
understanding of 3d math.
I've build each birdy according to a struct:
(define-struct Birdy (
(pos #:mutable) ; position vector
(vel #:mutable) ; velocity vector
(mass #:mutable) ; const
....
(Oforward #:mutable) ; local x vector
(Oup #:mutable) ; local y vector
(Oside #:mutable); local z vector
...
(body) ; prim
)
my failsafe would be to get the orientation from the struct-list of
another Birdy
But with this I can get the local orientation-axisses of an object that
is not build with these struct parameters!
forward-orientation:
(vtransform-rot (vector 1 0 0) (with-primitive p (get-global-transform)))
up-orientation:
(vtransform-rot (vector 0 1 0) (with-primitive p (get-global-transform)))
side-orientation:
(vtransform-rot (vector 0 0 1) (with-primitive p (get-global-transform)))
greets and thanx, Rob
> hi Rob,
>
>> some starting pics: http://www.flickr.com/photos/superrobber/4305067091/
> looks really nice. congrats.
>
>> i've tried the (vtransform-rot) but with this function somehow i just
>> can't get the rotation out of the (get-transform) matrix
>> the manual says it's kinda ment for use with normals ?
> i believe you can get the direction vector like this:
>
> (define (global-dir p)
> (vtransform-rot (vector 0 1 0)
> (with-primitive p
> (get-global-transform))))
>
> ; to draw it
> (let ([dir (global-dir p)])
> (with-primitive (build-ribbon 2)
> (hint-unlit)
> (hint-wire)
> (pdata-set! "p" 0 (vector 0 0 0))
> (pdata-set! "p" 1 (vmul dir 5))))
>
> but i'm not sure that this would be very useful in your case, because
> this is just a direction vector and not a rotation vector. if you want
> the rotation angles, you can try (matrix->euler). but since you want
> to interpolate between rotation matrices, you might need quaternions.
>
> best,
> gabor
>
More information about the Fluxus
mailing list