This code is surprisingly fast, but as it was published in 2013, it probably can get a ton of optimizations, improvements, and new features.
(I did make 1 minor edit to this code, and that was making the axis have individual colors, to tell them apart easier)
Ideas: More user-friendly UI, quicker generation and drawing, easier camera-changes
Code:
(I did make 1 minor edit to this code, and that was making the axis have individual colors, to tell them apart easier)
Ideas: More user-friendly UI, quicker generation and drawing, easier camera-changes
Code:
"3D~"->Str0
19->dim(|LG3D
{11,0,14,0,10}->|LAXIS
If not(|LG3D(1
Then
{9,9,~7,7,~7,7,0,0,0,0,0,0,0,0,0,0,1,1,1}->|LG3D
"::::::::::"->Str1
ClrHome
Disp "WELCOME TO GRAPH3D 4.1 FOR","THE TI-84+CSE. FOR HELP,","VISIT WWW.CEMETECH.NET
Pause :End
StoreGDB 0
FnOff :PlotsOff
BackgroundOff
sin(pi->|N
AxesOff:Radian
ZStandard:0->Q
Lbl AZ:ClrDraw
TextColor(DarkGray
Text(84,0,"USE [Y=],[WINDOW],[ZOOM],[TRACE],
Text(96,0,"[GRAPH],[2nd][FORMAT], [2nd][QUIT],
Text(108,0,"[CLEAR] AS YOU WOULD FOR 2D GRAPHING.
Text(120,0,"[ENTER] INSERTS OR CHANGES AN
Text(132,0,"EQUATION HERE, AND ARROWS ROTATE
Text(144,0,"A GRAPH. HELP: WWW.CEMETECH.NET
TextColor(Black
~1->|LG3D(17
1->N:For(X,0,5
Text(13X,1,"Z",X+1,"=
If 1=|LG3D(7+X
Then
For(Y,13X+2,13X+13
For(Z,16,23
Pxl-On(Y,Z,12+8pxl-Test(Y,Z
End:End:End
If sub(Str1,N,1)=":
Then:N+1->N:Else:0->O
While sub(Str1,N+O,1)!=":
O+1->O:End
Text(13X,30,sub(Str1,N,O
N+O+1->N:End:End:Lbl A
0->K:While K=0
For(Y,13Q+2,13Q+13
Pxl-On(Y,26,Blue
Pxl-On(Y,27,Blue
End
If 1=|LG3D(17
Text(0,255,"^
For(Y,1,50:End
getKey->K
For(Y,13Q+2,13Q+13
Pxl-Off(Y,26
Pxl-Off(Y,27
End
If 1=|LG3D(17
Text(0,255,"
For(Y,1,50:End
End
If K=12 and ~1=|LG3D(17
Goto WA:If K=13 and ~1=|LG3D(17
Goto ZA
If K=13 and 1=|LG3D(17
Goto FA
If K=14:Goto D
If K=15:Goto E
If K=21:~|LG3D(17)->|LG3D(17
If K=22 and 1=|LG3D(17
Goto Q
If K=25 and Q!=0:Q-1->Q
If K=34 and Q!=5:Q+1->Q
If K=45 and 1=|LG3D(7+Q
Goto XY
If K!=105:Goto A
If 1=|LG3D(7+Q
Goto XY:Lbl AY
ClrHome
Disp "
Output(1,1,"Z =
Output(1,2,Q
Input Str0
0->N:1->O
While N!=Q
If sub(Str1,O,1)=":
N+1->N:O+1->O:End:If O!=1:Then
sub(Str1,1,O-1)+Str0+sub(Str1,O,length(Str1)-O+1)->Str1
Else
Str0+sub(Str1,O,length(Str1)-O+1)->Str1
End
1->|LG3D(7+Q
Goto AZ
Lbl XY
0->|LG3D(7+Q
0->N:1->O
While N!=Q
If sub(Str1,O,1)=":
N+1->N:O+1->O:End:1->P
While sub(Str1,O+P,1)!=":
P+1->P:End
If O!=1:Then
sub(Str1,1,O-1)+sub(Str1,O+P,length(Str1)-O-P+1)->Str1
Else
sub(Str1,P+1,length(Str1)-P)->Str1
End
If K=105
Goto AY:Goto AZ:Lbl Q:AxesOn
ClrHome
DelVar |LG3DX
DelVar |LG3DXA
DelVar |LG3DY
DelVar |LG3DYA
DelVar |LG3DZ
DelVar |LG3DZA
RecallGDB 0
If N:Degree
Disp "GRAPH 3D |v4.1","BY KERM MARTIAN
Return:Lbl FA
~1->|LG3D(17
ClrDraw
Text(1,1,"3D FORMAT
Text(15,4,"AxesOff AxesOn
Text(27,4,"CoordOff CoordOn
For(X,1,2
For(W,73|LG3D(17+X)+3,73|LG3D(17+X)+68
For(Y,12X+4,12X+15
Pxl-On(Y,W,12+8pxl-Test(Y,W
End:End:End
DelVar A1->theta
Lbl F
If 1=|LG3D(17
Text(0,255,"^
For(W,73A,73A+68,68
For(Y,12theta+4,12theta+15
Pxl-On(Y,W+1,Red
Pxl-On(Y,W+2,Red
End:End
0->K:While not(K
getKey->K:End
For(W,73A,73A+68,68
For(Y,12theta+4,12theta+15
Pxl-Off(Y,W+1
Pxl-Off(Y,W+2
End:End
If 1=|LG3D(17
Text(0,255,"
If K=21:~|LG3D(17)->|LG3D(17
If K=24 and A=1:0->A
If K=26 and A=0:1->A
If K=25 and theta=2:1->theta
If K=34 and theta=1:2->theta
If K=45 or (K=22 and 1=|LG3D(17
Goto Q
If K=11:Goto AZ:If K=15:Goto E
If K=13 and ~1=|LG3D(17
Goto ZA
If K=12:Goto WA:If K=14:Goto D
If K!=105
Goto F
A->|LG3D(17+theta
If theta=2:Then
If A=0:CoordOff:If A=1:CoordOn
End:Goto FA
Lbl E
~1->|LG3D(17
|LG3D(1)|LG3D(2->X
1->A:ClrDraw
1->Y:Pt-Off(Xmin+DeltaX,Ymin+DeltaY:2->Y
Line(Xmin+78DeltaX,Ymin+7DeltaY,Xmin+186DeltaX,Ymin+7DeltaY
Line(Xmin+78DeltaX,Ymin+7DeltaY,Xmin+78DeltaX,Ymin+23DeltaY
Line(Xmin+186DeltaX,Ymin+23DeltaY,Xmin+78DeltaX,Ymin+23DeltaY
Line(Xmin+186DeltaX,Ymin+23DeltaY,Xmin+186DeltaX,Ymin+7DeltaY
Text(1,1,"CREATING MATRIX...
Text(13,1,"POLYGON
|LG3D(7)+|LG3D(8)+|LG3D(9)+|LG3D(10)+|LG3D(11)+|LG3D(12)+|LG3D(13)+|LG3D(14)+|LG3D(15)+|LG3D(16->theta
Xtheta->dim(|LG3DX
Xtheta->dim(|LG3DY
Xtheta->dim(|LG3DZ
If |N:Degree
1->C
For(B,0,9
C->D
While sub(Str1,D,1)!=":
D+1->D:End
If C!=D
sub(Str1,C,D-C->Str0
If 1=|LG3D(7+B
Then
For(Z,|LG3D(5),|LG3D(6),(|LG3D(6)-|LG3D(5))/(|LG3D(2)-0.98
For(X,|LG3D(3),|LG3D(4),(|LG3D(4)-|LG3D(3))/(|LG3D(1)-0.98
Xmin+DeltaX(82+int(100(A/dim(|LG3DX
Line(Ans,Ymin+10DeltaY,Ans,Ymin+20DeltaY
Text(13,63,A," OF ",|LG3D(1)|LG3D(2)theta
X->|LG3DX(A
Z->|LG3DZ(A
Z->Y:expr(Str0->|LG3DY(A
A+1->A
End:End:End
D+1->C:End
Text(25,1,"COMPUTING COLORS...
{min(|LG3DY),max(|LG3DY->L1
{16,11,15,19,14,18,10,17->L2
1+round(7(|LG3DY-L1(1))/(L1(2)-L1(1)),0
seq(L2(Ans(X)),X,1,dim(|LG3DY->|LGC
{0,0,min(|LG3DX),max(|LG3DX),0,0->|LG3DXA
{0,0,0,0,min(|LG3DY),max(|LG3DY)->|LG3DYA
{min(|LG3DZ),max(|LG3DZ),0,0,0,0->|LG3DZA
Radian
Lbl E2
ClrDraw
If 1=|LG3D(18
Then
For(Y,1,5,2
Line(|LG3DXA(Y)+.5|LG3DZA(Y),|LG3DYA(Y)-.2|LG3DZA(Y),|LG3DXA(Y+1)+.5|LG3DZA(Y+1),|LG3DYA(Y+1)-.2|LG3DZA(Y+1),1,|LAXIS(Y)
End
End
~|LG3D(1)|LG3D(2->C
For(B,1,theta
C+|LG3D(1)|LG3D(2->C
For(A,1,|LG3D(1)(|LG3D(2)-1)+1,|LG3D(1
For(X,A,A-1+|LG3D(1
{|LG3DX(X+C),|LG3DY(X+C),|LG3DZ(X+C)
If |LG3D(1)(|LG3D(2)-1)+1>A
Then
augment(Ans,{|LG3DX(X+|LG3D(1)+C),|LG3DY(X+|LG3D(1)+C),|LG3DZ(X+C+|LG3D(1
Line(Ans(1)+.5Ans(3),Ans(2)-.2Ans(3),Ans(4)+.5Ans(6),Ans(5)-.2Ans(6),1,|LGC(X+C),1
End
If X<A-1+|LG3D(1:Then
{Ans(1),Ans(2),Ans(3),|LG3DX(X+1+C),|LG3DY(X+1+C),|LG3DZ(X+1+C
Line(Ans(1)+.5Ans(3),Ans(2)-.2Ans(3),Ans(4)+.5Ans(6),Ans(5)-.2Ans(6),1,|LGC(X+C),1
End
End:End
End
Lbl G:DelVar KIf 1=|LG3D(17
Text(0,255,"^
"3Dplotcross"->Str0
While not(K
getKey->K:End
If 1=|LG3D(17
Text(0,255,"
If K=21
~|LG3D(17->|LG3D(17
If K=45 or (K=22 and 1=|LG3D(17
Goto Q
If K=14:Goto D
"3D~->Str0
If K=11:Goto AZ
If K=12:Goto WA
If K=13 and ~1=|LG3D(17
Goto ZA
If K=13 and 1=|LG3D(17
Goto FA
0->A:0->B
pi/8((K=26)-(K=24->B
pi/8((K=25)-(K=34->A
If A or B:Then
{.5(max(|LG3DX)+min(|LG3DX)),.5(max(|LG3DY)+min(|LG3DY)),0->L1
L1(1)+(|LG3DX-L1(1))*cos(B)+(|LG3DZ-L1(3))*sin(B)->L4
L1(2)-(|LG3DX-L1(1))*sin(A)*sin(B)+(|LG3DY-L1(2))*cos(A)+(|LG3DZ-L1(3))*cos(B)*sin(A->L5
L1(3)-(|LG3DX-L1(1))*cos(A)*sin(B)-(|LG3DY-L1(2))*sin(A)+(|LG3DZ-L1(3))*cos(A)*cos(B->|LG3DZ
L5->|LG3DY
L4->|LG3DX
L1(1)+(|LG3DXA-L1(1))*cos(B)+(|LG3DZA-L1(3))*sin(B)->L4
L1(2)-(|LG3DXA-L1(1))*sin(A)*sin(B)+(|LG3DYA-L1(2))*cos(A)+(|LG3DZA-L1(3))*cos(B)*sin(A->L5
L1(3)-(|LG3DXA-L1(1))*cos(A)*sin(B)-(|LG3DYA-L1(2))*sin(A)+(|LG3DZA-L1(3))*cos(A)*cos(B->|LG3DZA
L5->|LG3DYA
L4->|LG3DXA
End
If A or B:Goto E2
Goto G
Lbl WA:1->W:Lbl W:ClrDraw:Text(1,1,"3D WINDOW
Text(15,4,"Xmin = ",Xmin
Text(27,4,"Xmax = ",Xmax
Text(39,4,"X[p][|c][n] = ",|LG3D(1
Text(51,4,"Ymin = ",Ymin
Text(63,4,"Ymax= ",Ymax
Text(75,4,"Y[p][|c][n] = ",|LG3D(2
Lbl W1
DelVar KWhile not(K
For(Y,12W+3,12W+15
Pxl-On(Y,53,Blue
Pxl-On(Y,54,Blue
End
If 1=|LG3D(17
Text(0,255,"^
rand(5
getKey->K
For(Y,12W+3,12W+15
Pxl-Off(Y,53
Pxl-Off(Y,54
End
If 1=|LG3D(17
Text(0,255,"
rand(5
End
If K=21:~|LG3D(17)->|LG3D(17
If K=45 or (K=22 and 1=|LG3D(17
Goto Q
If K=11:Goto AZ:If K=13 and ~1=|LG3D(17
Goto ZA
If K=13 and 1=|LG3D(17
Goto FA
If K=14:Goto D
If K=15:Goto E
If K=25 and W!=1:W-1->W
If K=34 and W!=6:W+1->W
If K!=105
Goto W1:Lbl WB
ClrHome
Disp "3D WINDOW","
If W=1:"Xmin=
If W=2:"Xmax=
If W=3:"X[p][|c][n]=
If W=4:"Ymin=
If W=5:"Ymax=
If W=6:"Y[p][|c][n]=
Output(2,1,Ans
Input "",Y
If W=1:Y->Xmin
If W=2:Y->Xmax
If W=4:Y->Ymin
If W=5:Y->Ymax
If (W/3)=int(W/3) and Y!=int(Y
Goto WI
If (W/3)=int(W*3) and Y<=0
Goto WI
If W=3
Y->|LG3D(1
If W=6
Y->|LG3D(2
Xmin+.15(Xmax-Xmin)->|LG3D(3
Xmax-.15(Xmax-Xmin)->|LG3D(4
Ymin+.15(Ymax-Ymin)->|LG3D(5
Ymax-.15(Ymax-Ymin)->|LG3D(6
Goto W:Lbl WI
Pause "INVALID
Goto WB
Lbl ZA:ClrDraw
~1->|LG3D(17
Text(1,1,"ZOOM WINDOW
Text(15,12,"ZBox
Text(27,12,"Zoom In
Text(39,12,"Zoom Out
Text(51,12,"ZDecimal
Text(63,12,"ZInteger
Text(75,12,"ZSquare
Text(87,12,"ZStandard
1->W:Lbl Z
0->K:While K=0
Text(12W+3,1,">
If 1=|LG3D(17
Text(0,255,"^
rand(5
getKey->K
Text(12W+3,1,"
If 1=|LG3D(17
Text(0,255,"
rand(5
End
If K=21:~|LG3D(17)->|LG3D(17
If K=45 or (K=22 and 1=|LG3D(17
Goto Q
If K=25 and W!=1:W-1->W
If K=34 and W!=7:W+1->W
If K=11:Goto AZ:If K=13 and ~1=|LG3D(17
Goto ZA
If K=13 and 1=|LG3D(17
Goto FA
If K=14:Goto D
If K=15:Goto E
If K=12:Goto WA
If K!=105:Goto Z
If W=2:Goto Z2
If W=3:Goto Z3
If W=4:Goto Z4
If W=5:Goto Z5
If W=6:Goto Z6
If W=7:Goto Z7
ClrDraw
CoordOn:Input
Pt-On(X,Y,3
X->A:Y->B
Input
Pt-On(X,Y,3
Line(X,Y,X,B
Line(X,Y,A,Y
Line(A,B,A,Y
Line(A,B,X,B
rand(30
If X=A or Y=B
Goto E
max(X,A->Xmax
min(X,A->Xmin
max(Y,B->Ymax
min(Y,B->Ymin
Goto ZS
Lbl Z2:Zoom In
Goto ZS
Lbl Z3:Zoom Out:Goto ZS
Lbl Z4:ZDecimal:Goto ZS
Lbl Z5:ZInteger:Goto ZS
Lbl Z6:ZSquare
Goto ZS
Lbl Z7:ZStandard:Lbl ZS
Xmin+.15(Xmax-Xmin->|LG3D(3
Xmax-.15(Xmax-Xmin->|LG3D(4
Ymin+.15(Ymax-Ymin->|LG3D(5
Ymax-.15(Ymax-Ymin->|LG3D(6
Goto E
Lbl D
~1->|LG3D(17
If 0=theta or Str0!="3Dplotcross
Goto E
"3D~"->Str0
int(.5|LG3D(1->A
int(.5|LG3D(2->B
1->W:1->D:1->C
While sub(Str1,D,1)!=":
D+1->D:End
If C!=D
sub(Str1,C,D-C->Str0
Lbl D1
If 1=|LG3D(19:Then
|LG3D(5)+(A-1)(|LG3D(6)-|LG3D(5))/(|LG3D(2)-0.98->Y
|LG3D(3)+(B-1)(|LG3D(4)-|LG3D(3))/(|LG3D(1)-0.98->X
expr(Str0->Z
Text(150,1,"X=",X," Y=",Y," Z=",Z,"
End
If 1=|LG3D(17
Text(0,255,"^
|LG3DX(|LG3D(1)A+B+(W-1)|LG3D(1)|LG3D(2->X
|LG3DY(|LG3D(1)A+B+(W-1)|LG3D(1)|LG3D(2->Y
|LG3DZ(|LG3D(1)A+B+(W-1)|LG3D(1)|LG3D(2->Z
Pt-Change(X+.5Z,Y-.2Z
Pt-Change(X+.5Z+DeltaX,Y-.2Z+DeltaY
Pt-Change(X+.5Z+DeltaX,Y-.2Z-DeltaY
Pt-Change(X+.5Z-DeltaX,Y-.2Z+DeltaY
Pt-Change(X+.5Z-DeltaX,Y-.2Z-DeltaY
Repeat K:getKey->K:End
Pt-Change(X+.5Z,Y-.2Z
Pt-Change(X+.5Z+DeltaX,Y-.2Z+DeltaY
Pt-Change(X+.5Z+DeltaX,Y-.2Z-DeltaY
Pt-Change(X+.5Z-DeltaX,Y-.2Z+DeltaY
Pt-Change(X+.5Z-DeltaX,Y-.2Z-DeltaY
If 1=|LG3D(17
Text(0,255,"
If K=11:Goto AZ:If K=21:~|LG3D(17->|LG3D(17
If K=12:Goto WA:If K=13 and ~1=|LG3D(17
Goto ZA
If K=13 and 1=|LG3D(17
Goto FA
If K=15:Goto E2
If K=45 or (K=22 and 1=|LG3D(17
Goto Q
If K=95 and W<theta:W+1->W
If K=85 and W>1:W-1->W
If K=24 and B>1:B-1->B
If K=26 and |LG3D(2)>B
B+1->B
If K=25 and A>1:A-1->A
If K=34 and |LG3D(1)>A
A+|LG3D(2->A
Goto D1