3D Grapher and Insufficient Memory « Next Oldest | Next Newest »

 ▼ Han Unregistered Posts: 709 Threads: 104 Joined: Nov 2005 09-24-2013, 06:45 PM Hi all, I have created the skeleton of a 3D grapher (still learning how to convert over to an app). The program runs fine, except when creating a wireframe with large meshes. The program creates an n x n matrix to store the z-values (later to be used for a "trace" subroutine). If I try 35x35 then I run into an insufficient memory error. However, when I check the actual matrix, it is less than 10kB in size. How in the world is 32MB of RAM getting filled up with such a simple routine? Below is the source code. Before running the program, make sure to create a function named FXY whose formula is 1/390*(X^3*Y-X*Y^3). You can accomplish this via [SHIFT][xt(theta)n] -- aka the Define app. The program assumes FXY is already created and will use it to generate Z-values. a, b, and c are the rotation angles about the x, y, and z axes using the right hand rule (hold your right hand with your fingers pointing at you, and index finger pointing to the sky -- your thumb is y, your middle finger is x, and index finger is z n is the grid size Some starting values: xmin:=-10; xmax:=10; ymin:=-10; ymax:=10; n:=15; a:=0; b:=-10; c:=10; zoom:=10; Edit: Hm.. the "store" symbol got translated over into ▶ a quick search and replace should do the trick if you are copying ```export GRAPH3D(xmin,xmax,ymin,ymax,n,a,b,c,zoom) begin local i,j,dx,dy,x0,y0; local xeye,yeye,zeye; local xl,xr,yl,yr; xl:=-1.; xr:=1.; yl:=-1.; yr:=1.; dx:=(xmax-xmin)/n; dy:=(ymax-ymin)/n; // eyepoint xeye:=xmax+5; yeye:=0; zeye:=0; // rotation angles a*π/180.▶A; b*π/180.▶B; c*π/180.▶C; expr("[[1.,0.,0.],[0.,COS(A),-SIN(A)],[0.,SIN(A),COS(A)]]▶M1"); expr(" [[COS(B),0.,-SIN(B)],[0.,1.,0.],[SIN(B),0.,COS(B)]]▶M2"); expr("[[COS(C),-SIN(C),0.],[SIN(C),COS(C),0.],[0.,0.,1.]]▶M3"); for j from 0 to n do for i from 0 to n do xmin+dx*i▶X; ymin+dy*j▶Y; FXY(X,Y)▶Z; Z▶M0(i+1,j+1); (n+1)*j+i+1▶K; expr("M1*M2*M3*[[X],[Y],[Z]]▶M4"); abs(xeye-M4(1,1))▶Z; M4(2,1)/Z*zoom▶X; M4(3,1)/Z*zoom▶Y; (X,Y)▶L1(K); if i then re(L1(K-1))▶x0; im(L1(K-1))▶y0; line(X,Y,x0,y0,RGB(i/n*255,0,j/n*255)); end; if j then re(L1(K-n-1))▶x0; im(L1(K-n-1))▶y0; line(X,Y,x0,y0,RGB(i/n*255,0,j/n*255)); end; // if Xxr then X▶xr; end; // if Yyr then Y▶yr; end; end; end; freeze; end; ``` Thanks in advance for testing this out! Han Edited: 24 Sept 2013, 6:52 p.m. ▼ Han Unregistered Posts: 709 Threads: 104 Joined: Nov 2005 09-24-2013, 06:59 PM Nevermind, I found the culrpit -- lists can only have at most 999 objects! =( Edited: 24 Sept 2013, 7:00 p.m. ▼ Han Unregistered Posts: 709 Threads: 104 Joined: Nov 2005 09-24-2013, 07:07 PM ```export GRAPH3D(xmin,xmax,ymin,ymax,n,a,b,c,zoom) begin local i,j,dx,dy,x0,y0; local xeye,yeye,zeye; local xl,xr,yl,yr; xl:=-1.; xr:=1.; yl:=-1.; yr:=1.; dx:=(xmax-xmin)/n; dy:=(ymax-ymin)/n; // eyepoint xeye:=xmax+5; yeye:=0; zeye:=0; // rotation angles a*π/180.▶A; b*π/180.▶B; c*π/180.▶C; expr("[[1.,0.,0.],[0.,COS(A),-SIN(A)],[0.,SIN(A),COS(A)]]▶M1"); expr(" [[COS(B),0.,-SIN(B)],[0.,1.,0.],[SIN(B),0.,COS(B)]]▶M2"); expr("[[COS(C),-SIN(C),0.],[SIN(C),COS(C),0.],[0.,0.,1.]]▶M3"); L1:={}; L2:={}; for j from 0 to n do L2▶L1; for i from 0 to n do xmin+dx*i▶X; ymin+dy*j▶Y; FXY(X,Y)▶Z; Z▶M0(i+1,j+1); expr("M1*M2*M3*[[X],[Y],[Z]]▶M4"); abs(xeye-M4(1,1))▶Z; M4(2,1)/Z*zoom▶X; M4(3,1)/Z*zoom▶Y; (X,Y)▶L2(i+1); if i then re(L2(i))▶x0; im(L2(i))▶y0; line(X,Y,x0,y0,RGB(i/n*255,0,j/n*255)); end; if j then re(L1(i+1))▶x0; im(L1(i+1))▶y0; line(X,Y,x0,y0,RGB(i/n*255,0,j/n*255)); end; // if Xxr then X▶xr; end; // if Yyr then Y▶yr; end; end; end; freeze; end; ``` Define FXY to be 1/390*(X^3*Y-X*Y^3) and try: xmin=ymin=-10; xmax=ymax=10; n=50 (for a 50x50 wireframe grid), a=0, b=-10, c=5, zoom=10 Tim Wessman Unregistered Posts: 1,278 Threads: 44 Joined: Jul 2007 09-24-2013, 11:56 PM Yeah, sorry about that. Basically was a forgotten limit leftover from the 39gII... TW ▼ Han Unregistered Posts: 709 Threads: 104 Joined: Nov 2005 09-25-2013, 12:05 AM Does this mean a future update will remove this limit? ▼ Tim Wessman Unregistered Posts: 1,278 Threads: 44 Joined: Jul 2007 09-25-2013, 12:12 AM Can't ever promise anything, but provided there is an update I would think likely that change would be in it. This also is starting to show the "age" of Dave's forum software. Being not able to handle unicode could shortly prove to be very, very annoying with prime pastings. :-) TW Edited: 25 Sept 2013, 2:46 a.m. cyrille de Brébisson Unregistered Posts: 193 Threads: 10 Joined: Mar 2008 09-25-2013, 01:46 AM Hello, In order to block people to do stupid things (and in most cases, creating lists with more than 999 elements or matrices with more than 512 elements happends when someone tries to either break things or because they messed up), there is a limit on the size of such objects... 1 things that you can do to bypass it: - create a list of list (or a list of matrices) cyrille ▼ Gilles Carpentier Unregistered Posts: 468 Threads: 17 Joined: May 2011 09-25-2013, 07:41 AM Hi Cyrille, I strongly hope that this will be changed. This is for example a very annoying limitation with the DIMGROB command. ▼ steindid Unregistered Posts: 19 Threads: 5 Joined: Sep 2013 09-25-2013, 08:32 AM +1 Didier Han Unregistered Posts: 709 Threads: 104 Joined: Nov 2005 09-26-2013, 11:00 PM Quote: Hello, In order to block people to do stupid things (and in most cases, creating lists with more than 999 elements or matrices with more than 512 elements happends when someone tries to either break things or because they messed up), there is a limit on the size of such objects... 1 things that you can do to bypass it: - create a list of list (or a list of matrices) cyrille This severely limits the ability of the calculator. One cannot evaluate sums having more than 1,000 terms using the summation symbol "sigma" due to this limitation. Pier Aiello Unregistered Posts: 120 Threads: 14 Joined: May 2013 09-27-2013, 06:39 AM I beg to differ. Expand the object until the memory is free it's a better choice (imo).

 Possibly Related Threads… Thread Author Replies Views Last Post 3D graphing planned for HP Prime Mic 5 2,065 11-11-2013, 10:17 AM Last Post: Tim Wessman 3D graphing on HP Prime Glenn Becker 2 1,326 09-11-2013, 06:08 AM Last Post: Don Shepherd WP-34S: Program for vector (3D) manipulation Marcel Samek 4 1,838 09-05-2013, 05:29 AM Last Post: Marcus von Cube, Germany 3D printing custom molds Han 3 1,679 08-02-2013, 03:26 AM Last Post: Bruce Larrabee 3D-printed calculator parts? John Ioannidis 13 3,788 05-24-2013, 12:32 PM Last Post: Bruce Larrabee OT: 3D Calculator Remakes hugh steers 26 7,007 01-31-2013, 09:12 AM Last Post: Eddie W. Shore 3D Model - HP 50g 49G+ 39G+ 48Gii JJB299 3 1,488 01-18-2013, 11:51 PM Last Post: Raymond Del Tondo 41 User Memory vs System Memory Gerry Schultz 6 2,441 07-01-2012, 12:02 AM Last Post: Monte Dalrymple 41-MCODE Vector Calculator (3D) Ángel Martin 0 774 11-16-2011, 08:15 AM Last Post: Ángel Martin [OT] New Casio Grapher Tim Wessman 40 8,420 10-13-2010, 04:22 PM Last Post: Jimi

Forum Jump: