Online Shopping : Science : Physics : Mechanics : Dynamics : 3D

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 7 people (43%) answered Yes
Recently 3 of 7 people (43%) answered Yes

Entry

Physics: Dynamics: 3D: Rotation: Can you give BBCBASIC program to solve Euler rotation equations?

Mar 31st, 2009 10:42
engatoo engatoo, Roj Merry, alex martin, John Martin, Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 05 March 2006 - 02:08 am ----------------------
Physics: Dynamics: 3D: Rotation: Can you give BBCBASIC program to 
solve Euler rotation equations?
---
--- cut here: begin --------------------------------------------------
REM use double precision
*FLOAT 64
:
dataB% = TRUE
dimB% = TRUE
printB% = TRUE
:
IxxR = 1
IyyR = 2
IzzR = 3
:
xAngularVelocityR = 4
yAngularVelocityR = 5
zAngularVelocityR = 6
:
xTorqueSumR = 7
yTorqueSumR = 8
zTorqueSumR = 9
:
timeBeginR = 0
timeEndR = 10
timeStepTotalI% = 500 : REM choose a small step size for this Euler 
method, or it will quickly give too big values
:
x0 = 1
y0 = 1
z0 = 1
:
IF dimB% THEN PROCMathCalculateEquationEulerRotationDim( 
timeStepTotalI% )
PROCMathCalculateEquationEulerRotationMain( IxxR, IyyR, IzzR, 
xAngularVelocityR, yAngularVelocityR, zAngularVelocityR, xTorqueSumR, 
yTorqueSumR, zTorqueSumR, x0, y0, z0, timeBeginR, timeEndR, 
timeStepTotalI%, dataB%, dimB%, printB% )
END
:
:
DEF PROCMathCalculateEquationEulerRotationDim( timeStepTotalI% )
DIM x0R( timeStepTotalI% + 1 )
DIM y0R( timeStepTotalI% + 1 )
DIM z0R( timeStepTotalI% + 1 )
:
DIM x1R( timeStepTotalI% + 1 )
DIM y1R( timeStepTotalI% + 1 )
DIM z1R( timeStepTotalI% + 1 )
:
DIM x2R( timeStepTotalI% + 1 )
DIM y2R( timeStepTotalI% + 1 )
DIM z2R( timeStepTotalI% + 1 )
ENDPROC
:
DEF PROCMathCalculateEquationEulerRotationMain( IxxR, IyyR, IzzR, 
xAngularVelocityR, yAngularVelocityR, zAngularVelocityR, xTorqueSumR, 
yTorqueSumR, zTorqueSumR, x0, y0, z0, timeBeginR, timeEndR, 
timeStepTotalI%, dataB%, dimB%, printB% )
LOCAL a11R
LOCAL a12R
LOCAL a13R
LOCAL a21R
LOCAL a22R
LOCAL a23R
LOCAL a31R
LOCAL a32R
LOCAL a33R
:
REM fill in the given data in the appropriate parameters in the 3 
Euler rotation equations
a11R = IxxR
a12R = ( IzzR - IyyR ) * zAngularVelocityR * yAngularVelocityR
a13R = xTorqueSumR
:
a21R = IyyR
a22R = ( IxxR - IzzR ) * xAngularVelocityR * zAngularVelocityR
a23R = yTorqueSumR
:
a31R = IzzR
a32R = ( IyyR - IxxR ) * yAngularVelocityR * xAngularVelocityR
a33R = zTorqueSumR
:
PRINT a11R; " * x' + "; a12R; " * y * z = "; a13R
PRINT
PRINT a21R; " * y' + "; a22R; " * x * z = "; a23R
PRINT
PRINT a31R; " * z' + "; a32R; " * x * y = "; a33R
PRINT
PRINT "---"
:
PROCMathCalculateEquationDifferentialSystemVariableIndependent3Euler( 
a11R, a12R, a13R, a21R, a22R, a23R, a31R, a32R, a33R, x0, y0, z0, 
timeBeginR, timeEndR, timeStepTotalI% )
ENDPROC
:
DEF 
PROCMathCalculateEquationDifferentialSystemVariableIndependent3Euler( 
a11R, a12R, a13R, a21R, a22R, a23R, a31R, a32R, a33R, x0, y0, z0, 
timeBeginR, timeEndR, timeStepTotalI% )
REM Steps: Overview:
REM
REM This description is just a possible (general) approach
REM (e.g. using the Euler method or Runge-Kutta method)
REM to solve a system (in this case ) of differential equations
REM
REM ---
REM
REM 1. Given the 3 Euler rotation differential equations
REM
REM       .
REM a11 . x + a12 . y . z = 
a13                                                 (1)
REM
REM       .
REM a21 . y + a22 . x . z = 
a23                                                 (2)
REM
REM       .
REM a31 . z + a32 . x . y = 
a33                                                 (3)
REM
REM where a11, a12, a13, a21, a22, a23, a33 can be seen as constants 
here
REM where x, y and z are the 3 dependent variables
REM where the time t is the independent variable
REM
REM ---
REM
REM 2. To solve this equations numerically
REM
REM ---
REM
REM    1. Write the equations explicit in the highest derivative
REM       (in other words, put the highest derivative on one side, say 
the left side,
REM        of your equation)
REM
REM        .
REM        x = ( a13 - a12 . y . z ) / 
a11                                      (4)
REM
REM
REM        .
REM        y = ( a23 - a22 . x . z ) / 
a21                                      (5)
REM
REM
REM        .
REM        z = ( a33 - a32 . x . y ) / 
a31                                      (6)
REM
REM
REM
REM 3. Give the variables in the right side of your equation their 
given
REM    initial values
REM
REM    1. given the constants (these follow here, in this special 
case, from the given momentary moments of inertia, products of 
inertia, torques)
REM
REM       
a11                                                                   
(7)
REM
REM       
a12                                                                   
(8)
REM
REM       
a13                                                                   
(9)
REM
REM       
a21                                                                   
(10)
REM
REM       
a22                                                                   
(11)
REM
REM       
a23                                                                   
(12)
REM
REM       x (let call this first initial value 
x0)                              (13)
REM
REM       y (let call this first initial value 
y0)                              (14)
REM
REM       z (let call this first initial value 
z0)                              (15)
REM
REM    2. Filling this in for this first calculation gives
REM
REM       .   .      .
REM       x0, y0 and z0 respectively:
REM
REM
REM        .
REM        x0 = ( a13 - a12 . y0 . z0 ) / 
a11                                   (16)
REM
REM
REM        .
REM        y0 = ( a23 - a22 . x0 . z0 ) / 
a21                                   (17)
REM
REM
REM        .
REM        z0 = ( a33 - a32 . x0 . y0 ) / 
a31                                   (18)
REM
REM
REM 4. -Calculate the next x, y and z using this values
REM
REM    1. -The simplest method (called the Euler method)
REM        (but also very inaccurate method, you will have to use
REM        a very small stepsize, and there will quickly be a
REM        rather large error, that is deviation away from the correct 
values).
REM        You use only 1 evaluation of the derivative in this method.
REM
REM                   .
REM         x1 = x0 + x0 . 
dt                                                   (19)
REM
REM                   .
REM         y1 = y0 + y0 . 
dt                                                   (20)
REM
REM                   .
REM         z1 = z0 + z0 . 
dt                                                   (21)
REM
REM        A better method would be to use a Runge-Kutta method
REM        (which uses more than 1 evaluation of the derivative to 
calculate the
REM         next value)
REM
REM    2. -The dt, or thus small time step, follows from the given
REM        time begin value, time end value, and the total amount of 
steps
REM
REM         dt = ( ( time begin ) - ( time end ) / ( time total 
steps ) )       (22)
REM
REM 5. -This x1, y1, z1 become your new x, y and z values
REM
REM                              .   .   .
REM     (with this you calculate x1, y1, z1, and so on)
REM
REM 6. -Go back to step 3, and repeat steps 3 to 6 to get next values
REM     (and this stops when you have runned all time values from
REM      time begin to time end (adding each time the time step dt to 
it))
REM
REM ---
REM
REM
LOCAL timeStepR
LOCAL timeR
LOCAL I%
LOCAL minI%
LOCAL maxI%
:
timeStepR = FNMathCalculateStepR( timeBeginR, timeEndR, 
timeStepTotalI% )
:
minI% = 0
maxI% = timeStepTotalI%
:
x1R( minI% ) = x0
y1R( minI% ) = y0
z1R( minI% ) = z0
:
FOR I% = minI% TO maxI%
:
timeR = timeBeginR + I% * timeStepR : REM calculate the current value 
of the independent variable (but value not used further)
:
REM calculate the x'', y'' and z'' in the 3 Euler rotation equations, 
using the given values (or thus the angular acceleration)
x2R( I% ) = ( a13R - a12R * y1R( I% ) * z1R( I% ) ) / a11R
y2R( I% ) = ( a23R - a22R * x1R( I% ) * z1R( I% ) ) / a21R
z2R( I% ) = ( a33R - a32R * x1R( I% ) * y1R( I% ) ) / a31R
:
REM Use thus the (inaccurate, but simple) Euler method to calculate 
the next x', y' and z' values (or thus the angular velocity)
REM  x' new = x' old + ( x'' old ) . dt
REM  y' new = y' old + ( y'' old ) . dt
REM  z' new = z' old + ( z'' old ) . dt
REM this basically says: the new value is the old value + a straight 
line approximation using its derivative value times the step
:
x1R( I% + 1 ) = x1R( I% ) + x2R( I% ) * timeStepR
y1R( I% + 1 ) = y1R( I% ) + y2R( I% ) * timeStepR
z1R( I% + 1 ) = z1R( I% ) + z2R( I% ) * timeStepR
:
REM Use again thus the (inaccurate, but simple) Euler method to 
calculate the next x, y and z values to calculate the angles
REM  x new = x old + ( x' old ) . dt
REM  y new = y old + ( y' old ) . dt
REM  z new = z old + ( z' old ) . dt
REM this basically says: the new value is the old value + a straight 
line approximation using its derivative value times the step
:
x0R( I% + 1 ) = x0R( I% ) + x1R( I% ) * timeStepR
y0R( I% + 1 ) = y0R( I% ) + y1R( I% ) * timeStepR
z0R( I% + 1 ) = z0R( I% ) + z1R( I% ) * timeStepR
:
PRINT "time"; " "; "="; " "; timeR
PRINT "x''"; " "; "="; " "; x2R( I% )
PRINT "y''"; " "; "="; " "; y2R( I% )
PRINT "z''"; " "; "="; " "; z2R( I% )
:
PRINT "x'"; " "; "="; " "; x1R( I% )
PRINT "y'"; " "; "="; " "; y1R( I% )
PRINT "z'"; " "; "="; " "; z1R( I% )
:
PRINT "x"; " "; "="; " "; x0R( I% )
PRINT "y"; " "; "="; " "; y0R( I% )
PRINT "z"; " "; "="; " "; z0R( I% )
:
PRINT "---"
:
REPEAT UNTIL GET
:
NEXT I%
:
ENDPROC
:
REM --- LIBRARY --- REM
:
http://automobile.easyfindindia.com/
http://bollywood.easyfindindia.com/
http://cloth-shopping.onlineindiadiary.com/
http://easyfind.j4ulive.com/
http://www.onlineindiadiary.com/
http://finance-guide.easyfindindia.com/
http://freelance-jobs.onlineindiadiary.com/
http://gadgets.easyfindindia.com/
http://www.easyfindindia.com/
http://gift-ideas.easyfindindia.com/
http://health-fitness.easyfindindia.com/
http://home-improvement.j4ulive.com/
http://homedecor.easyfindindia.com/
http://mortgage.onlineindiadiary.com/
http://online-business.j4ulive.com/
http://online-education.j4ulive.com/
http://onlinein.j4ulive.com/
http://pets-online.easyfindindia.com/
http://realestate.easyfindindia.com/
http://sports-in-india.easyfindindia.com/
http://travel-guide.easyfindindia.com/
http://wedding-shopping.j4ulive.com/
http://www.j4ulive.com/
REM library: math: STEP when begin, end and maximum steps are choosen 
[kn, zoe, tu, 07-11-2000 20:31:02]
DEF FNMathCalculateStepR( beginR, endR, stepMaxI% )
LOCAL deltaR
deltaR = endR - beginR
IF ( deltaR = 0 ) THEN PRINT "do not choose begin interval and end 
interval the same" : STOP : = 0
IF ( stepMaxI% <= 0 ) THEN PRINT "please choose total amount of steps 
greater than zero" : STOP : = 0
= ABS( deltaR / stepMaxI% )
:
--- cut here: end ----------------------------------------------------
===
Internet: see also:
---
http://www.roo7e.com
http://www.roo7e.com
http://www.al33ab.com
http://ksacam.com
http://chat.ksacam.com
http://ksacam.info
http://oo2o.com
http://s4cam.com
http://saudi4cam.com				
http://voice.ksacam.com
http://سعودي-كام.oo2o.com
http://سعوديكام.com
http://xn--mgbply5cnrr.com
http://www.3rabstarz.com/vb
http://www.3rabstarz.com/vb
http://www.3rabstarz.com/
http://www.3rabstarz.com/vb
http://www.3rabstarz.com/
http://www.dir.3rabstarz.com/
http://www.up.3rabstarz.com
http://www.3rabstarz.com/vb/forumdisplay.php?f=5
http://www.3rabstarz.com/vb/forumdisplay.php?f=116
http://www.3rabstarz.com/vb/forumdisplay.php?f=66
http://www.3rabstarz.com/vb/forumdisplay.php?f=78
http://www.3rabstarz.com/vb/forumdisplay.php?f=147
http://www.3rabstarz.com/vb/forumdisplay.php?f=2
http://www.3rabstarz.com/vb/forumdisplay.php?f=31
http://www.3rabstarz.com/vb/forumdisplay.php?f=136
http://www.3rabstarz.com/vb/forumdisplay.php?f=34
http://www.3rabstarz.com/vb/forumdisplay.php?f=89
http://www.3rabstarz.com/vb/forumdisplay.php?f=26
http://www.3rabstarz.com/vb/forumdisplay.php?f=72
http://www.3rabstarz.com/vb/forumdisplay.php?f=73
http://www.3rabstarz.com/vb/forumdisplay.php?f=149
http://www.3rabstarz.com/vb/forumdisplay.php?f=150
http://www.3rabstarz.com/vb/forumdisplay.php?f=151
http://www.3rabstarz.com/vb/forumdisplay.php?f=152
http://www.3rabstarz.com/vb/forumdisplay.php?f=67
http://www.3rabstarz.com/vb/forumdisplay.php?f=3
http://www.3rabstarz.com/vb/forumdisplay.php?f=37
http://www.3rabstarz.com/vb/forumdisplay.php?f=115
http://www.3rabstarz.com/vb/forumdisplay.php?f=76
http://www.3rabstarz.com/vb/forumdisplay.php?f=77
http://www.3rabstarz.com/vb/forumdisplay.php?f=36
http://www.3rabstarz.com/vb/forumdisplay.php?f=153
http://www.3rabstarz.com/vb/forumdisplay.php?f=122
http://www.3rabstarz.com/vb/forumdisplay.php?f=118
http://www.3rabstarz.com/vb/forumdisplay.php?f=119
http://www.3rabstarz.com/vb/forumdisplay.php?f=120
http://www.3rabstarz.com/vb/forumdisplay.php?f=121
http://www.3rabstarz.com/vb/forumdisplay.php?f=35
http://www.3rabstarz.com/vb/forumdisplay.php?f=65
http://www.3rabstarz.com/vb/forumdisplay.php?f=7
http://www.3rabstarz.com/vb/forumdisplay.php?f=9
http://www.3rabstarz.com/vb/forumdisplay.php?f=11
http://www.3rabstarz.com/vb/forumdisplay.php?f=142
http://www.3rabstarz.com/vb/forumdisplay.php?f=143
http://www.3rabstarz.com/vb/forumdisplay.php?f=146
http://www.3rabstarz.com/vb/forumdisplay.php?f=140
http://www.3rabstarz.com/vb/forumdisplay.php?f=137
http://www.3rabstarz.com/vb/forumdisplay.php?f=114
http://www.3rabstarz.com/vb/forumdisplay.php?f=117
http://www.3rabstarz.com/vb/forumdisplay.php?f=113
http://www.3rabstarz.com/vb/forumdisplay.php?f=51
http://www.3rabstarz.com/vb/forumdisplay.php?f=84
http://www.3rabstarz.com/vb/forumdisplay.php?f=138
http://www.3rabstarz.com/vb/forumdisplay.php?f=139
http://www.3rabstarz.com/vb/forumdisplay.php?f=15
http://www.3rabstarz.com/vb/forumdisplay.php?f=130
http://www.3rabstarz.com/vb/forumdisplay.php?f=97
http://www.3rabstarz.com/vb/forumdisplay.php?f=102
http://www.3rabstarz.com/vb/forumdisplay.php?f=101
http://www.3rabstarz.com/vb/forumdisplay.php?f=104
http://www.3rabstarz.com/vb/forumdisplay.php?f=131
http://www.3rabstarz.com/vb/forumdisplay.php?f=103
http://www.3rabstarz.com/vb/forumdisplay.php?f=99
http://www.3rabstarz.com/vb/forumdisplay.php?f=59
http://www.3rabstarz.com/vb/forumdisplay.php?f=60
http://www.3rabstarz.com/vb/forumdisplay.php?f=39
http://www.3rabstarz.com/vb/forumdisplay.php?f=40
http://www.3rabstarz.com/vb/forumdisplay.php?f=42
http://www.3rabstarz.com/vb/forumdisplay.php?f=4
http://www.3rabstarz.com/vb/forumdisplay.php?f=1
http://www.3rabstarz.com/vb/forumdisplay.php?f=88
http://www.3rabstarz.com/vb/forumdisplay.php?f=148
http://www.3rabstarz.com/vb/forumdisplay.php?f=62
http://www.3rabstarz.com/vb/forumdisplay.php?f=63
http://www.3rabstarz.com/vb/forumdisplay.php?f=64
http://www.3rabstarz.com/vb/forumdisplay.php?f=6
http://www.3rabstarz.com/vb/forumdisplay.php?f=12
http://www.3rabstarz.com/vb/forumdisplay.php?f=96
http://www.3rabstarz.com/vb/forumdisplay.php?f=58
http://www.3rabstarz.com/vb/forumdisplay.php?f=38