This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > April 2005 > Converting Degree based data set to Rotation set





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Converting Degree based data set to Rotation set
Drew Baker

2005-04-26, 7:42 pm

Okay I have a large ammount of data capture which gives rotation as x y z in
degrees (ie -4.48 - 67.77 2.41) does anyone have a uitlity that can convert
en masse to x y z a (ie - 0.8806 -0.0158 0.4735 0.0888) for use in vrml
automaticaly? as the data set is 19 * 1349 rotations it will take me for
ever to do it manualy though one of the calculors

Regs D

--
===================================================
"the soul never thinks without an image"
Aristotle, De Anima, 431a16
----------------------------------------------------------------------------
Drew Baker, Multimedia Designer
3D Visualisation Group, The School of Theatre Studies
University of Warwick. Coventry, The United Kingdom
Tel : +44 (0) 24 7657 4272 Fax : +44 (0) 24 7652 3267
Email : d.baker@warwick.ac.uk Web : http://www.warwick.ac.uk/3D
===================================================


fabricator

2005-04-26, 11:47 pm

There is a PERL based bvh>vrml utility as part of this system. Perhaps
you can adapt it for your purpose.

http://ovrt.nist.gov/projects/wear/mocap/

Steve Smith

2005-04-27, 5:55 am

Here is a VBA function which you could use in MS Access.

Steve

Sub xyzRotate( _
ByVal x As Double, ByVal y As Double, ByVal z As Double, _
ByRef ox As Double, ByRef oy As Double, ByRef oz As Double, ByRef w As
Double)

' computes one orientation and rotations from rotations about x,y,z
' rotation is passed back byRef in ox,oy,oz,w

Dim i As Integer
Dim b As Double
Dim axisX(3) As Double, axisY(3) As Double, axisZ(3) As Double
Dim angle(9) As Double, q(4) As Double, r(4) As Double, a(4) As Double,
c(4) As Double

axisX(1) = 1: angle(1) = x
axisY(3) = 1: angle(3) = y
axisZ(2) = 1: angle(2) = z

For i = 1 To 3: q(i) = axisX(i) * Sin(angle(1) / 2): Next: q(4) =
Cos(angle(1) / 2)
For i = 1 To 3: r(i) = axisY(i) * Sin(angle(2) / 2): Next: r(4) =
Cos(angle(2) / 2)

a(1) = r(4) * q(1) + r(1) * q(4) + r(2) * q(3) - r(3) * q(2)
a(2) = r(4) * q(2) + r(2) * q(4) + r(3) * q(1) - r(1) * q(3)
a(3) = r(4) * q(3) + r(3) * q(4) + r(1) * q(2) - r(2) * q(1)
a(4) = r(4) * q(4) - r(1) * q(1) - r(2) * q(2) - r(3) * q(3)

For i = 1 To 3: r(i) = axisZ(i) * Sin(angle(3) / 2): Next: r(4) =
Cos(angle(3) / 2)

c(1) = r(4) * a(1) + r(1) * a(4) + r(2) * a(3) - r(3) * a(2)
c(2) = r(4) * a(2) + r(2) * a(4) + r(3) * a(1) - r(1) * a(3)
c(3) = r(4) * a(3) + r(3) * a(4) + r(1) * a(2) - r(2) * a(1)
c(4) = r(4) * a(4) - r(1) * a(1) - r(2) * a(2) - r(3) * a(3)

w = math.Acos(c(4)) * 2
b = Sin(w / 2)
If b = 0 Then b = 0.000001
ox = c(1) / b
oy = c(2) / b
oz = c(3) / b
End Sub




"Drew Baker" <d.baker@warwick.ac.uk> wrote in message
news:d4lq9j$od8$1@wisteria.csv.warwick.ac.uk...
> Okay I have a large ammount of data capture which gives rotation as x y z
> in degrees (ie -4.48 - 67.77 2.41) does anyone have a uitlity that can
> convert en masse to x y z a (ie - 0.8806 -0.0158 0.4735 0.0888) for use in
> vrml automaticaly? as the data set is 19 * 1349 rotations it will take me
> for ever to do it manualy though one of the calculors
>
> Regs D
>
> --
> ===================================================
> "the soul never thinks without an image"
> Aristotle, De Anima, 431a16
> ----------------------------------------------------------------------------
> Drew Baker, Multimedia Designer
> 3D Visualisation Group, The School of Theatre Studies
> University of Warwick. Coventry, The United Kingdom
> Tel : +44 (0) 24 7657 4272 Fax : +44 (0) 24 7652 3267
> Email : d.baker@warwick.ac.uk Web : http://www.warwick.ac.uk/3D
> ===================================================
>



Steve Smith

2005-04-27, 5:55 am

The previous VBA code sample was not quite complete.
Steve

Sub xyzRotate( _
ByVal x As Double, ByVal y As Double, ByVal z As Double, _
ByRef ox As Double, ByRef oy As Double, ByRef oz As Double, ByRef w As
Double)

' computes one orientation and rotations from rotations about x,y,z
' rotation is passed back byRef in ox,oy,oz,w

Dim i As Integer
Dim b As Double
Dim axisX(3) As Double, axisY(3) As Double, axisZ(3) As Double
Dim angle(9) As Double, q(4) As Double, r(4) As Double, a(4) As Double,
c(4) As Double

axisX(1) = 1: angle(1) = x
axisY(3) = 1: angle(3) = y
axisZ(2) = 1: angle(2) = z

For i = 1 To 3: q(i) = axisX(i) * Sin(angle(1) / 2): Next: q(4) =
Cos(angle(1) / 2)
For i = 1 To 3: r(i) = axisY(i) * Sin(angle(2) / 2): Next: r(4) =
Cos(angle(2) / 2)

a(1) = r(4) * q(1) + r(1) * q(4) + r(2) * q(3) - r(3) * q(2)
a(2) = r(4) * q(2) + r(2) * q(4) + r(3) * q(1) - r(1) * q(3)
a(3) = r(4) * q(3) + r(3) * q(4) + r(1) * q(2) - r(2) * q(1)
a(4) = r(4) * q(4) - r(1) * q(1) - r(2) * q(2) - r(3) * q(3)

For i = 1 To 3: r(i) = axisZ(i) * Sin(angle(3) / 2): Next: r(4) =
Cos(angle(3) / 2)

c(1) = r(4) * a(1) + r(1) * a(4) + r(2) * a(3) - r(3) * a(2)
c(2) = r(4) * a(2) + r(2) * a(4) + r(3) * a(1) - r(1) * a(3)
c(3) = r(4) * a(3) + r(3) * a(4) + r(1) * a(2) - r(2) * a(1)
c(4) = r(4) * a(4) - r(1) * a(1) - r(2) * a(2) - r(3) * a(3)

w = Acos(c(4)) * 2
b = Sin(w / 2)
If b = 0 Then b = 0.000001
ox = c(1) / b
oy = c(2) / b
oz = c(3) / b
End Sub

Public Function Acos(ByVal x As Double) As Double
Acos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function



"Drew Baker" <d.baker@warwick.ac.uk> wrote in message
news:d4lq9j$od8$1@wisteria.csv.warwick.ac.uk...
> Okay I have a large ammount of data capture which gives rotation as x y z
> in degrees (ie -4.48 - 67.77 2.41) does anyone have a uitlity that can
> convert en masse to x y z a (ie - 0.8806 -0.0158 0.4735 0.0888) for use in
> vrml automaticaly? as the data set is 19 * 1349 rotations it will take me
> for ever to do it manualy though one of the calculors
>
> Regs D
>
> --
> ===================================================
> "the soul never thinks without an image"
> Aristotle, De Anima, 431a16
> ----------------------------------------------------------------------------
> Drew Baker, Multimedia Designer
> 3D Visualisation Group, The School of Theatre Studies
> University of Warwick. Coventry, The United Kingdom
> Tel : +44 (0) 24 7657 4272 Fax : +44 (0) 24 7652 3267
> Email : d.baker@warwick.ac.uk Web : http://www.warwick.ac.uk/3D
> ===================================================
>



Joerg Scheurich aka MUFTI

2005-04-27, 7:31 am

> Okay I have a large ammount of data capture which gives rotation as x y z in
> degrees (ie -4.48 - 67.77 2.41) does anyone have a uitlity that can convert
> en masse to x y z a (ie - 0.8806 -0.0158 0.4735 0.0888) for use in vrml
> automaticaly?


Use function Eul_ToQuat() from

http://www1.acm.org/pubs/tog/Graphi...iv/euler_angle/

but the most interesting question is impossible to answer automatically:

rotation as x y z in degrees (ie -4.48 - 67.77 2.41) do not tell anything
about the order how the different angles have to be applied.

If you rotate

first about -4.48 degree around the X axis,
then -67.77 degree around the Y direction
and then 2.41 degree around the Z axis

it would not be identical in general if you rotate

first about -67.77 degree around the Y direction,
then 2.41 degree around the Z axis
and then -4.48 degree around the X axis

The Eul_ToQuat() function handles this with the EulOrdXYZs, EulOrdZYXr
etc. "order code"

so long
MUFTI
--
Warning: This paper on SETI@home is written for scientists and engineers.
In order to confuse and obfuscate the public, we utilize substantial
technical jargon.
(Vorwort eines technischen Dokuments)
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews