If (mww And mouseDown) or init Then
mww="false"
'GraphicsWindow.BrushColor = bg
'GraphicsWindow.FillRectangle(0,0,gw,gh)
GraphicsWindow.Clear ()
If init then
init="false"
else
theta = -(GraphicsWindow.MouseX-mouseX)/gw*PI
phi = -(GraphicsWindow.MouseY-mouseY)/gh*PI/2
cth=cth+theta
cpi=cpi+phi
'GraphicsWindow.Title =theta +":"+phi
setRotation()
matrix1 = matrix
matrix2 = rotationOLD
multiply()
rotation = matrix
endif
matrix = rotation
For pz=0 to 13
For py= ymax to 0 Step -1
For px=xmax -1 to 0 Step -1
bs=LDArray.GetValue (bll 14-pz)
bs1=LDArray.GetValue (bll 13-pz)
If tt=" " then
else
For iBall = 1 To dtc
X = ballX[iBall]+px
Y = ballY[iBall]+py
Z = ballZ[iBall]+pz
getScreen()
LDArray.SetValue(ballSX iBall sx)
LDArray.SetValue(ballSY iBall sy)
LDArray.SetValue(ballSZ iBall sz)
Sub multiply
For i = 1 To 3
For j = 1 To 3
matrix[i][j] = 0
For k = 1 To 3
matrix[i][j] = matrix[i][j] + matrix1[i][k]*matrix2[k][j]
EndFor
EndFor
EndFor
EndSub
Sub getAngles 'Input : matrix Output theta, phi
phi = Math.ArcCos(Math.Min(1.0,Math.Max(-1.0,matrix[3][3])))
theta = Math.ArcCos(Math.Min(1.0,Math.Max(-1.0,matrix[2][2])))
If (matrix[1][2] < 0) Then
theta = theta+PI
EndIf
EndSub
Sub getScreen 'Input matrix, scale, centreX, centreY, centreZ, X, Y, Z
'Output SX, SY, SZ(depth)
DX = (X-centreX)*scale
DY = (Y-centreY)*scale
DZ = (Z-centreZ)*scale
SX = gw/2 + DX*matrix[2][1] + DY*matrix[2][2] + DZ*matrix[2][3]
SY = gh/2 + DX*matrix[3][1] + DY*matrix[3][2] + DZ*matrix[3][3]
SZ = (DX*matrix[1][1] + DY*matrix[1][2] + DZ*matrix[1][3])/255/scale
EndSub
Sub inithen
bll=LDArray.Create (15)
' > . . . . . . .
block[13]= " O OOO O O OOO O "
block[12]= " O O "
block[11]= " O O "
block[10]= " W W "
block [9]= " WW WW WWW WWWWWW WWWWWW WWWWWW WW WW WW "
block [8]= " WWWW W W W W W W W W W W WWWW "
block [7]= " WWWWW W W W W W W W W W W WWWWW "
block [6]= " WWWWWW WWWWWwW wWWWWwW WWWWWwW WWWWWW "
block [5]= " WWW WW WWWR WWW "
block [4]= " WWW W R WWW "
block [3]= " WBW W OO WBW "
block [2]= " WWW WWRR WWW "
block [1]= " RR "
block [0]= " "
xmax = 11
ymax = 6
zmax = 12
For x=0 To 13
LDArray.SetValue (bll x+1 block[x])
EndFor
EndSub