I've been having trouble with rotation.
In my code I need to turn a set of X and Y angles into
a vector. Getting the YRotation to represent the vector
has been pretty easy. Getting the XRotation to translate into
a YValue has been difficult.
At first I tried this expression hoping that I could divide my
rotation 'sphere' into a circle of a smaller proportional size
where I could then gather X and Y values with this code:
Function AngToVect.Vector(YAngle#, XAngle#)
Y# = sin(XAngle#)
Radius# = 1.0-Abs(Cos(XAngle#))
X# = cos(YAngle#)*Radius#
Z# = sin(YAngle#)*Radius#
NewVect.Vector = New Vector
NewVect\X# = X#
NewVect\Y# = Y#
NewVect\Z# = Z#
Return NewVect
End Function
Unfortunately that didn't work at all.
So then I gave up on math and tried using the Move function with pivot
entities to try to gain coordinate values like:
Function AngToVect.Vector(yAngle#, xAngle#)
MovePivot = CreatePivot()
PositionEntity(MovePivot, 0, 0, 0)
RotateEntity(MovePivot, xAngle#, yAngle#, 0)
MoveEntity(MovePivot, 0, 0, 1)
;Turn the pivot results into the vector
NewVect.Vector = New Vector
NewVect\X# = EntityX(MovePivot)
NewVect\Y# = EntityY(MovePivot)
NewVect\Z# = EntityZ(MovePivot)
FreeEntity MovePivot
Return NewVect
End Function
Nope, that doesn't work either...
So now, here I am asking for some help. Can anyone tell me how I can
convert a set of angles into a normalized 3D vector?
I'd like to do it with math preferably, but getting it working is more important
than whether I take longer and use pivot entities or not...
I'd like to make my first week using Blitz a good one. :)
In my code I need to turn a set of X and Y angles into
a vector. Getting the YRotation to represent the vector
has been pretty easy. Getting the XRotation to translate into
a YValue has been difficult.
At first I tried this expression hoping that I could divide my
rotation 'sphere' into a circle of a smaller proportional size
where I could then gather X and Y values with this code:
Function AngToVect.Vector(YAngle#, XAngle#)
Y# = sin(XAngle#)
Radius# = 1.0-Abs(Cos(XAngle#))
X# = cos(YAngle#)*Radius#
Z# = sin(YAngle#)*Radius#
NewVect.Vector = New Vector
NewVect\X# = X#
NewVect\Y# = Y#
NewVect\Z# = Z#
Return NewVect
End Function
Unfortunately that didn't work at all.
So then I gave up on math and tried using the Move function with pivot
entities to try to gain coordinate values like:
Function AngToVect.Vector(yAngle#, xAngle#)
MovePivot = CreatePivot()
PositionEntity(MovePivot, 0, 0, 0)
RotateEntity(MovePivot, xAngle#, yAngle#, 0)
MoveEntity(MovePivot, 0, 0, 1)
;Turn the pivot results into the vector
NewVect.Vector = New Vector
NewVect\X# = EntityX(MovePivot)
NewVect\Y# = EntityY(MovePivot)
NewVect\Z# = EntityZ(MovePivot)
FreeEntity MovePivot
Return NewVect
End Function
Nope, that doesn't work either...
So now, here I am asking for some help. Can anyone tell me how I can
convert a set of angles into a normalized 3D vector?
I'd like to do it with math preferably, but getting it working is more important
than whether I take longer and use pivot entities or not...
I'd like to make my first week using Blitz a good one. :)