Ultimate Amiga
Network Boards => AMOS Language Discussion => AMOS Factory => AMOS Professional Forum => Topic started by: Lonewolf10 on August 05, 2011, 06:24:32 PM
-
Hi
I have been studying up on trigonometry and displacement vectors in order to try to rotate a cube in my assembler demo I am working on. However, before writing the ASM code I was trying to use AMOS to make sure that the maths was all correct.
The good news is that the maths seems to be correct, but when AMOS reaches the line COORDS(S,1)=NEW_X it seems to crash (actually, it seems to go into an infinite loop and then it crashes about 10 seconds later).
I thought it might have been a problem storing negative numbers, but a quick 3 line program proved that not to be the case.
Any ideas anyone?
ROTATE_CUBE:
Dim COORDS(8,3)
'
' Rotating angles...
'
A1=90 : A2=90 : A3=90
'
' Calculate constants for new angle
'
Print "Calculating constants for new angle..."
Print : Print "C1,C2,C3 and S1,S2,S3"
C1=Cos(A1) : C2=Cos(A2) : C3=Cos(A3)
S1=Sin(A1) : S2=Sin(A2) : S3=Sin(A3)
'
'
Print : Print "XX,XY,XZ"
XX=C2*C1
XY=C2*S1
XZ=S2
'
Print : Print "YX,";
YX1=C3*S1
YX2=S3*S2*C1
YX=YX1+YX2
'
Print "YY,";
YY1=-C3*C1
YY2=S3*S2*S1
YY=YY1+YY2
'
Print "YZ"
YZ=-S3*C2
'
'
Print : Print "ZX,";
ZX1=S3*S1
ZX2=C3*S2*C1 : Rem ;s2*c1+c3*s1
ZX=ZX1-ZX2
'
Print "ZY,";
ZY1=-S3*C1
ZY2=C3*S2*S1 : Rem ;c3*c1-s2*s1
ZY=ZY1-ZY2
'
Print "ZZ"
ZZ=C3*C2
'
' Calculate new coordinates using new angle
'
For S=1 To 8
Read X,Y,Z
Print : Print "S=";S;" - X,";
X1=XX*X
X2=XY*Y
X3=XZ*Z
NEW_X=X1+X2+X3
'
Print "Y,";
Y1=YX*X
Y2=YY*Y
Y3=YZ*Z
NEW_Y=Y1+Y2+Y3
'
Print "Z"
Z1=ZX*X
Z2=ZY*Y
Z3=ZZ*Z
NEW_Z=Z1+Z2+Z3
Print "S=";S
Print "NEW_X=";NEW_X
Print "NEW_Y=";NEW_Y
Print "NEW_Z=";NEW_Z
End
'
Print : Print "Storing new coords..."
COORDS(S,1)=NEW_X
COORDS(S,2)=NEW_Y
COORDS(S,3)=NEW_Z
Next S
'
Data -10,-10,10 : Rem top-left (front)
Data 10,-10,10 : Rem top-right (front)
Data -10,10,10 : Rem bottom-left (front)
Data 10,10,10 : Rem bottom-right (front)
Data -10,-10,-10 : Rem top-left (back)
Data 10,-10,-10 : Rem top-right (back)
Data -10,10,-10 : Rem bottom-left (back)
Data 10,10,-10 : Rem bottom-right (back)
Regards,
Lonewolf10
-
Arggghhhh! >:(
I have been programming in assembler for so long (last 9 months) that I forgot one of the bugs in AMOS - anything after a Data statement causes AMOS to crash :(
Edit:
Errr... it seems something is wrong with the maths.
A=90, B=0,C=0 coords returned are:
1 = -10,-10
2 = 10,-10
3 = 10,-10
4 = 10,10
In short, points 2 (top-right @ front) and 3 (bottom-left @ front) have swapped positions!! I'm trying to rotate point 1 to 2, 2 to 3 etc.
A=90, B=90, C=90 coords returned are:
1 = 10,-10,-10
2 = 10,-10,10
3 = 10,10,-10
4 = 10,10,10
This isn't right, is it?
Regards,
Lonewolf10
-
Ummmm... Have you checked the AMCAF demo source? I'm pretty sure it had a few rotating cubes in it.
-
The only AMCAF demo's I have are:
Fire.AMOS
ScreenTrans.AMOS
Neither have rotating cubes, but they do have cool effects though :)
Regards,
Lonewolf10