Had the following code sitting around from a while back but may be useful to you. Although it only rotates the ball around one axis it would not be hard to modify it.
Have a look under the ObjectCalcRoutine what your looking for may well be there.
Twynklet
sync on:sync rate 0
backdrop on:color backdrop rgb(53,171,250)
fog off
autocam off
position camera 90,90,-45
point camera 90,0,90
set text font "Arial":set text size 14
Gosub MakeTextures
`Create Objects
make matrix 1,180,180,6,6
position matrix 1,0,0,0
set matrix wireframe off 1
prepare matrix texture 1,1,1,1
make object sphere 1,20
texture object 1,2
position object 1,90,10,90
#Constant PI=3.14159
`Set the various routine call intervals (in ms)
inputInterval=50
`Declare Variables
ballCircumference#=20*PI
ballMaxSpeed#=150
ballSpeed#=50
ballMaxAccelerate#=1
ballMaxDecelerate#=3
ballAutoSlow=0
ballAutoSlowRate#=0.3
ballSlowText$="OFF"
ballDirection=1
lastObjMovement=Timer()
inputTimer=Timer()
`MAIN PROGRAM LOOP
Main:
Do
text 8,0,"fps : " + str$( screen fps() )
text 8,16,"Ball Speed (press A/Z) : " + left$(str$(ballSpeed#),5)
text 8,32,"Auto Slow (press S/X) : " + ballSlowText$
Gosub ObjectCalcRoutine
if inputTimer <= Timer() Then Gosub InputRoutine
Sync
Loop
`END OF MAIN PROGRAM LOOP
ObjectCalcRoutine:
objMovementTime=Timer() - lastObjMovement
lastObjMovement=Timer()
objMovementMultiplier#=1/(1000/Abs(objMovementTime))
ballMovementDistance#=ballSpeed#*objMovementMultiplier#
ballRotationAngle#=ballMovementDistance#*(360/ballCircumference#)
if object position z(1) < 0 then ballDirection=1
if object position z(1) > 180 then ballDirection=0
if ballSpeed# > 0
if ballDirection = 1
position object 1,90,10,object position z(1)+ballMovementDistance#
xrotate object 1,ballRotationAngle#
fix object pivot 1
else
position object 1,90,10,object position z(1)-ballMovementDistance#
xrotate object 1,-ballRotationAngle#
fix object pivot 1
endif
endif
Return
InputRoutine:
inputTimer=inputInterval + Timer()
if inkey$()="a" or inkey$()="A" then ballSpeed#=ballSpeed#+ballMaxAccelerate#
if inkey$()="z" or inkey$()="Z" then ballSpeed#=ballSpeed#-ballMaxDecelerate#
if inkey$()="s" or inkey$()="S"
ballAutoSlow=1
ballSlowText$ = "ON"
endif
if inkey$()="x" or inkey$()="X"
ballAutoSlow=0
ballSlowText$ = "OFF"
endif
if ballAutoSlow=1 then ballSpeed#=ballSpeed#-ballAutoSlowRate#
if ballSpeed# > ballMaxSpeed# then ballSpeed#=ballMaxSpeed#
if ballSpeed# < 0 then ballSpeed# = 0
Return
makeTextures:
`Matrix Texture
create bitmap 1,128,128
ink rgb(255,255,255),rgb(0,0,0)
box 0,0,128,128
ink rgb(255,192,255),rgb(0,0,0)
box 0,0,64,64
box 64,64,128,128
get image 1,0,0,128,128,1
`ball Texture
ink rgb(255,255,255),rgb(0,0,0)
box 0,0,128,128
ink rgb(255,0,0),rgb(0,0,0)
box 0,32,128,96
get image 2,0,0,128,128,1
`Cleanup offscreen bitmap
ink rgb(255,255,255),rgb(0,0,0)
set current bitmap 0
delete bitmap 1
Return