Phy Start
sync on
sync rate 60
make object cube 1,10
make object cube 2,10
position object 1,-15,0,0
position object 2,15,0,0
phy make rigid body dynamic box 1
phy set rigid body kinematic 1,1
move camera -50
do
`Increase X angle
Xangle#=Xangle#+10
`Set the rotation of the kinematic Object
phy set rigid body kinematic rotation 1,Xangle#,0,0
`Get the Angular Velocity data for the Kinematic object
KinOmega#=Phy get rigid body angular velocity X (1)
`Rotate Object 2
XRotate Object 2,Xangle#
`Get the new value of X, after the program loops. Needed to find out the value of Delta Theta
ObjXNew#=Object angle X(2)
`Calclulate Delta Theta
DeltaTheta#=ObjXNew#-ObjXOld#
`Get the "Old" value of the X angle, used in the calculation above to get Delta Theta
ObjXOld#=Object angle X(2)
`Convert the Angle we calculated (DeltaTheta) into Radians
DeltaThetaRAD#=DeltaTheta#/180*3.14159265358979323846264338327950288419716939937510
`Omega is defined as: w=d0/dt. d0=Change in angle (DeltaTheta), dt=Change in time.
`As we are calculating Omega every loop, dt=1/Screen FPS. w=d0/1/screen FPS ===> w=d0*Screen FPS
`I have used "60" to match the value of KinOmega#. but you can use Screen FPS for a more accurate result
ObjOmega#=DeltaThetaRAD#*60
`Display the values
set cursor 0,0
Print "X angle: " + str$(Xangle#)
Center Text Object Screen X(1),Object Screen Y(1)+50,"Kinematic Object"
Center Text Object Screen X(1),Object Screen Y(1)+65,"Omega (w): " + str$(KinOmega#,5)
Center Text Object Screen X(2),Object Screen Y(2)+50,"Normal Object"
Center Text Object Screen X(2),Object Screen Y(2)+65,"Omega (w): " + str$(ObjOmega#,5)
Phy Update
sync
loop
This is a little code snippet on how I would go about it.
For a vehicle you would change Object angle X(a), to Limb Angle X(a), If your wheels are limbs.
It basically finds the change in angle of the object per loop, and multiplies it by the Screen FPS.
omega (w)=Change in Angle (d0)/Change in Time(dt)
As we are calculating the omega every loop, the change in time is 1/Screen FPS.
Hope it helps.