Tformvector help

Blitz3D Forums/Blitz3D Programming/Tformvector help

FlagDKT(Posted 2008) [#1]
I need to transform a vector in worldspace to the coordinate system defined by another vector.
The standard tformvector function only works with entities.


big10p(Posted 2008) [#2]
Well, what coordinate system is your vector in?


FlagDKT(Posted 2008) [#3]
it is in worldspace


big10p(Posted 2008) [#4]
I mean what coord system is your 'destination' vector in?


FlagDKT(Posted 2008) [#5]
the dest coordinate system is defined by a vector instead of a destination entity like in tformvector function.
Sorry maybe I'm not so clear :)


big10p(Posted 2008) [#6]
Well, your dest vector must be in one coord system or another. :)


Stevie G(Posted 2008) [#7]
Use a helper pivot and align it to the vector and then tformvector

;assume d.vector3 is destination
;assume w.vector3 is the world vector
;assume n.vector3 is the new vector

global HelperPivot = createpivot()

.
.
.

aligntovector HelperPivot, d\x, d\y, d\z, 3
tformvector w\x, w\y, w\z , 0 , HelperPivot
n\x = tformedx()
n\y = tformedy()
n\z = tformedz()



You could also use Dot product for this.

Stevie


FlagDKT(Posted 2008) [#8]
I'll explain my problem in detail :)
I have my particle system where the emission dir is defined by the Z vector(-1) and use random XY (rnd(X,-X),rnd(Y,-Y)) to modify the emission cone.

Suppose I need the emission cone direction aligned to a vector that is pointing to the right; this way XY should become ZY.

The fastest way to transform XY to ZY ?