Introducing my new program: Graph'n 3D!
The Github is here

I should probably finish old programs before moving on to new ones...

This is intended to be an updated version of Kerm's Graph3D program.

Here is an image (finally adding an image XD):


prgmGRAPHN3D

Code:
ClrHome
Input "Z=",Str1
startTmr->T
21->D:441->N
N->dim(|LX:N->dim(|LY
N->dim(|LZ
Radian
DelVar P
For(X,~10,10
   For(Y,~10,10
      P+1->P
      Output(3,1,int(P/4.41
      X->|LX(P:Y->|LY(P
      expr(Str1->|LZ(P
End:End
Disp checkTmr(T
ClrDraw
{Navy,Blue,LtBlue,Green,Yellow,Orange,Red,Magenta,White->|LC
cos(30^^o)(|LX+|LY->|LXP
sin(20^^o)(|LZ+(|LX-|LY->|LYP
seq(E,E,min(|LZ),max(|LZ),(abs(min(|LZ))+abs(max(|LZ)))/dim(|LC->|LE
ClrDraw
For(X,20,1,~1
   For(Z,21,1,~1
      DX+Z->L
      If D(X-1)+Z<=N:Then
         min(|LZ(L),|LZ(D(X-1)+Z->E
         For(A,1,dim(|LE
            If E>=|LE(A:|LC(A->C
         End
         Line(|LXP(L),|LYP(L),|LXP(D(X-1)+Z),|LYP(D(X-1)+Z),C
      End
      If L>1 and Z!=1:Then
         min(|LZ(L),|LZ(L-1->E
         For(A,1,dim(|LE
            If E>=|LE(A:|LC(A->C
         End
         Line(|LXP(L),|LYP(L),|LXP(L-1),|LYP(L-1),C
End:End:End
checkTmr(T->T
Disp Ans


For the optimization gods:
Using Z=sin(X)+2cos(Y)
    Calculate time: 25 seconds
    Draw time: 128 seconds


Planned features:
    Rotating View?
    Optimizations
    Better Progress bar
    Better UI
    Ability to change Xmin, Xmax, Ymin, and Ymax
Nice work, Iíll have to try this out. So can you plug in equations then?

Also, any chance this could be made in ICE or C so itís faster?
1) Yes you can plug in equations (only one at a time for now, more would take a lot more time and idk how i could draw them and still make them look nice)

2) Probably. But I want to see how I can do in TI-Basic. (Also I don't feel like getting into C right now)
Here, halved the displaying time:


Code:
ClrHome
Input "Z=",Str1
startTmr->T
21->D:441->N
N->dim(|LX:N->dim(|LY
N->dim(|LZ
Radian
DelVar P
For(X,~10,10
   For(Y,~10,10
      P+1->P
      X->|LX(P
      expr(Str1->|LZ(P
   End
End
seq(remainder(X,21)-10,X,0,440->Y
Disp checkTmr(T
ClrDraw
{Navy,Blue,LtBlue,Green,Yellow,Orange,Red,Magenta,White->C
cos(30^^o)(|LX+|LY->XP
sin(20^^o)(|LZ+(|LX-|LY->YP
{min(|LZ),max(|LZ
seq(E,E,Ans(1),Ans(2),sum(abs(Ans))/dim(|LC->E
ClrDraw
For(X,20,1,~1
   For(Z,21,1,~1
      D(X-1)+Z->F
      Ans+D
      If N>=F
      Line(|LXP(Ans),|LYP(Ans),|LXP(F),|LYP(F),|LC(sum(|LE<=min(|LZ(Ans),|LZ(F
      If Ans>1 and Z!=1
      Line(|LXP(Ans),|LYP(Ans),|LXP(Ans-1),|LYP(Ans-1),|LC(sum(|LE<=min(|LZ(Ans),|LZ(Ans-1
   End
End
checkTmr(T->T
Disp Ans
Sorry it isn't a big update, I spent a long time trying to get some things to work, and wasn't able to.
Github

Planned features:
    Rotating View
    Handle error conditions (stuff like dividing by Zero and nonreal answers)
    Optimizations
    Ability to show/hide axis
    Ability to change Xmin, Xmax, Ymin, and Ymax


Feel free to share how I would handle error conditions, rotate view, and change the window size, but please don't do anything other than optimize it if you want, because I would like to learn these things for myself. I just need to be pointed in the right direction.


Code:
" "->Str1:21->D
{Navy,Blue,LtBlue,Green,Yellow,Orange,Red,Magenta,White->|LC
Lbl M
ClrHome
Menu("GRAPH'N 3D","Z="+Str1,Z,"BUILD GRAPH",B,"DISPLAY GRAPH",E,"QUIT",Q
Lbl Z
Input "Z=",Str1
Goto M
Lbl B
If Str1=" ":Then
   Output(1,1,"NOTHING TO GRAPH!"
   Wait 1
   Goto M
End
startTmr->T
D^^2->N
N->dim(|LX:N->dim(|LY:N->dim(|LZ
Radian
DelVar P
For(X,~10,10
   For(Y,~10,10
      P+1->P
      X->|LX(P:Y->|LY(P
      expr(Str1->|LZ(P
      Output(1,1,"CALCULATING... "+eval(int(100P/N))+"^^o/."
End:End
Output(3,1,"CONVERTING POINTS"
Output(4,2,"FROM 3D TO 2D..."
cos(30^^o)(|LX+|LY->|LXP
sin(20^^o)(|LZ+(|LX-|LY->|LYP
Output(6,1,"CONFIGURING SCREEN..."
min(|LYP->Ymin:min(1.6Ans,min(|LXP->Xmin
max(|LYP->Ymax:max(1.6Ans,max(|LXP->Xmax
Output(8,1,"MAKING COLOR PALETTE...
{min(|LZ),max(|LZ
seq(E,E,Ans(1),Ans(2),sum(abs(Ans))/dim(|LC->|LE
Output(10,1,"DRAWING...
Lbl K
ClrDraw
For(X,D-1,0,~1
   For(Y,1,D
      D(X-1)+Y->F
      Ans+D
      If N>=F and X
      Line(|LXP(Ans),|LYP(Ans),|LXP(F),|LYP(F),|LC(sum(|LE<=min(|LZ(Ans),|LZ(F
      If Ans>1 and Y!=1 and (Y>1 or X<D-1
      Line(|LXP(Ans),|LYP(Ans),|LXP(Ans-1),|LYP(Ans-1),|LC(sum(|LE<=min(|LZ(Ans),|LZ(Ans-1
End:End
TextColor(Black
Text(0,0,"Z=",Str1
Text(12,0,"TIME: ",checkTmr(T
Lbl E
DispGraph
0->X:0->Y
Repeat Ans:getKey:End
Repeat sum(K={11,45,105
   Ans->K
   expr(Str1
   Text(150,0,"{",X,",",Y,",",round(Ans,3),"}plotpixelplotpixelplotpixelplotpixelplotpixel"
   DelVar K
Repeat Ans:getKey:End
   Ans->K
   expr(Str1
   Pt-Off(cos(30^^o)(X+Y),sin(20^^o)(Ans+(X-Y)),2
   X+(X<=9)(K=26)-(X>=~9)(K=24)->X
   Y+(Y<=9)(K=34)-(Y>=~9)(K=25)->Y
   expr(Str1
   Pt-On(cos(30^^o)(X+Y),sin(20^^o)(Ans+(X-Y)),2,Black
End
Goto M
Lbl Q
Output(3,4,"GRAPH'N 3D
Output(4,5,"BY KOSMIC
DelVar |LXPDelVar |LYPDelVar |LXDelVar |LCDelVar |LEDelVar |LXDelVar |LYDelVar |LZ
Wait 1
ClrHome:ClrDraw


Edit by PT_: added quotes for post formatting
You should get Kerm to try it
Replace this:

Code:
N->dim(|LX:N->dim(|LY:N->dim(|LZ
Radian
DelVar P
For(X,~10,10
   For(Y,~10,10
      P+1->P
      X->|LX(P:Y->|LY(P
      expr(Str1->|LZ(P
      Output(1,1,"CALCULATING... "+eval(int(100P/N))+"^^o/.
End:End

With this:

Code:
Radian
~10->X
Ansbinomcdf(20,0->X
seq(expr(Str1),Y,X,10->Z
For(X,~9,10
   augment(|LX,Xbinomcdf(20,0->X
   augment(|LZ,seq(expr(Str1),Y,~10,10->Z
   Output(1,1,"CALCULATING... "+toString(5X+50)+"^^o/.
End
~10+remainder(~1+cumSum(binomcdf(230,0)),21
augment(Ans,Ans->Y
N->dim(|LY

It'll save ~25 seconds at the cost of about 30 bytes Wink

On line 49,

Code:
      If |N>1 and Y!=1 and (Y>1 or X<D-1

The |N>1 condition could only be true if Y was 1, but the 2nd condition prevents that, so it could be

Code:
      If Y!=1 and (Y>1 or X<D-1

You can rearrange the math in the drawing loop to be more optimal like this:

Code:
      DX+Y->|N
      Ans-D
      If X
      Line(|LXP(|N),|LYP(|N),|LXP(Ans),|LYP(Ans),|LC(sum(|LE<=min(|LZ(|N),|LZ(Ans
      If |N>1 and Y!=1 and (Y>1 or X<D-1
      Line(|LXP(|N),|LYP(|N),|LXP(|N-1),|LYP(|N-1),|LC(sum(|LE<=min(|LZ(|N),|LZ(|N-1

There is less math and finance vars are faster than Ans so this will save 2 seconds.

Like I said in sax, using L1-L6 is faster than custom list names, particularly if the name of the list is more than one byte long since token lookups are very expensive so I would strongly recommend using those since its a very easy improvement.
If you want to push a little bit more for speed, you can always use system variables instead of OS variables, which save about 0.5ms per call, generally this type of optimization is only worth it if its in a big loop, so the drawing loop is really the only place I would consider using these.

I also really like the way it looks with thin lines instead of thick ones.

There is also the matter of:

Code:

For(X,D-1,0,~1
   For(Y,1,D
      D(X-1)+Y->F
      Ans+D


You might speed it up with:

Code:

N-D->G
For(X,D-1,0,~1
   G-D->G
   For(Y,1,D
      G+Y->F
      Ans+D


(I hope that works, I was still using an older version of he code).

EDIT:
Actually, this might work:

Code:

0->F
For(X,1,D-1
   For(Y,1,D
      F+1->F
      Ans+D
Code with womp's optimizations:

Code:
" "->Str1:21->D
{Navy,Blue,LtBlue,Green,Yellow,Orange,Red,Magenta,White->|LC
Lbl M
ClrHome
Menu("Graph'n 3D","Z="+Str1,Z,"Build Graph",B,"Display Graph",D,"Quit",Q
Lbl Z
Input "Z=",Str1
Goto M
Lbl B
If Str1=" ":Then
   Output(3,6,"ID:10-T Error
   Output(5,4,"(Nothing to graph)"
   Wait 1
   Goto M
End
startTmr->T
D^^2->N
Radian
~10->X
Ansbinomcdf(20,0->X
seq(expr(Str1),Y,X,10->Z
For(X,~9,10
   augment(|LX,Xbinomcdf(20,0->X
   augment(|LZ,seq(expr(Str1),Y,~10,10->Z
   Output(1,1,"Calculating... "+toString(5X+50)+"%
End
~10+remainder(~1+cumSum(binomcdf(230,0)),21
augment(Ans,Ans->Y
N->dim(|LY
Output(3,1,"Converting points"
Output(4,2,"from 3D to 2D..."
cos(30^^o)(|LX+|LY->|LXP
sin(20^^o)(|LZ+(|LX-|LY->|LYP
Output(6,1,"Configuring Screen..."
min(|LYP->Ymin:min(1.6Ans,min(|LXP->Xmin
max(|LYP->Ymax:max(1.6Ans,max(|LXP->Xmax
Output(8,1,"Making Color Palette...
{min(|LZ),max(|LZ
seq(E,E,Ans(1),Ans(2),sum(abs(Ans))/dim(|LC->|LE
Output(10,1,"Drawing...
ClrDraw
For(X,D-1,0,~1
   For(Y,1,D
      DX+Y->|N
      Ans-D
      If N>=|N and X
      Line(|LXP(|N),|LYP(|N),|LXP(Ans),|LYP(Ans),|LC(sum(|LE<=min(|LZ(|N),|LZ(Ans)))),1
      If |N>1 and Y!=1 and (Y>1 or X<D-1
      Line(|LXP(|N),|LYP(|N),|LXP(|N-1),|LYP(|N-1),|LC(sum(|LE<=min(|LZ(|N),|LZ(|N-1)))),1
End:End
TextColor(Black
Text(0,0,"Z=",Str1
Text(12,0,"Time: ",checkTmr(T
Lbl D
DispGraph
0->X:0->Y
Repeat Ans:getKey:End
Ans->K
If K=14:Then
   While K!=11
      expr(Str1
      Text(150,0,"{",X,",",Y,",",round(Ans,3),"}plotpixelplotpixelplotpixelplotpixelplotpixel
      DelVar K
   Repeat Ans:getKey:End
      Ans->K
      expr(Str1
      Pt-Off(cos(30^^o)(X+Y),sin(20^^o)(Ans+(X-Y)),2
      X+(X<=9)(K=26)-(X>=~9)(K=24)->X
      Y+(Y<=9)(K=34)-(Y>=~9)(K=25)->Y
      expr(Str1
      Pt-On(cos(30^^o)(X+Y),sin(20^^o)(Ans+(X-Y)),2,Black
   End
   Pt-Off(cos(30^^o)(X+Y),sin(20^^o)(Ans+(X-Y)),2
End
Goto M
Lbl Q
Output(3,4,"Graph'n 3D
Output(4,5,"By Kosmic
DelVar |LXPDelVar |LYPDelVar |LCDelVar |LEDelVar |LXDelVar |LYDelVar |LZ
Wait 1
ClrHome:ClrDraw
Looking good! Weren't you going to replace the custom lists with L1-L6 though? That could speed it up a bit.

Really loving experimenting with this:
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement