3D Grapher and Insufficient Memory



#2

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 X<xl then X&#9654;xl; end;
// if X>xr then X&#9654;xr; end;
// if Y<yl then Y&#9654;yl; end;
// if Y>yr then Y&#9654;yr; end;

end;
end;

freeze;
end;

Thanks in advance for testing this out!

Han


Edited: 24 Sept 2013, 6:52 p.m.


#3

Nevermind, I found the culrpit -- lists can only have at most 999 objects! =(

Edited: 24 Sept 2013, 7:00 p.m.


#4

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*&#960;/180.&#9654;A; b*&#960;/180.&#9654;B; c*&#960;/180.&#9654;C;

expr("[[1.,0.,0.],[0.,COS(A),-SIN(A)],[0.,SIN(A),COS(A)]]&#9654;M1");
expr("
[[COS(B),0.,-SIN(B)],[0.,1.,0.],[SIN(B),0.,COS(B)]]&#9654;M2");

expr("[[COS(C),-SIN(C),0.],[SIN(C),COS(C),0.],[0.,0.,1.]]&#9654;M3");

L1:={}; L2:={};

for j from 0 to n do
L2&#9654;L1;
for i from 0 to n do

xmin+dx*i&#9654;X;
ymin+dy*j&#9654;Y;
FXY(X,Y)&#9654;Z; Z&#9654;M0(i+1,j+1);

expr("M1*M2*M3*[[X],[Y],[Z]]&#9654;M4");
abs(xeye-M4(1,1))&#9654;Z;
M4(2,1)/Z*zoom&#9654;X; M4(3,1)/Z*zoom&#9654;Y;
(X,Y)&#9654;L2(i+1);


if i then
re(L2(i))&#9654;x0;
im(L2(i))&#9654;y0;

line(X,Y,x0,y0,RGB(i/n*255,0,j/n*255));
end;

if j then
re(L1(i+1))&#9654;x0;
im(L1(i+1))&#9654;y0;
line(X,Y,x0,y0,RGB(i/n*255,0,j/n*255));
end;

// if X<xl then X&#9654;xl; end;
// if X>xr then X&#9654;xr; end;
// if Y<yl then Y&#9654;yl; end;
// if Y>yr then Y&#9654;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

#5

Yeah, sorry about that. Basically was a forgotten limit leftover from the 39gII...

TW


#6

Does this mean a future update will remove this limit?


#7

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.

#8

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


#9

Hi Cyrille,

I strongly hope that this will be changed. This is for example a very annoying limitation with the DIMGROB command.


#10

+1
Didier

#11

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.

#12

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 264 11-11-2013, 10:17 AM
Last Post: Tim Wessman
  3D graphing on HP Prime Glenn Becker 2 179 09-11-2013, 06:08 AM
Last Post: Don Shepherd
  WP-34S: Program for vector (3D) manipulation Marcel Samek 4 238 09-05-2013, 05:29 AM
Last Post: Marcus von Cube, Germany
  3D printing custom molds Han 3 191 08-02-2013, 03:26 AM
Last Post: Bruce Larrabee
  3D-printed calculator parts? John Ioannidis 13 450 05-24-2013, 12:32 PM
Last Post: Bruce Larrabee
  OT: 3D Calculator Remakes hugh steers 26 814 01-31-2013, 09:12 AM
Last Post: Eddie W. Shore
  3D Model - HP 50g 49G+ 39G+ 48Gii JJB299 3 197 01-18-2013, 11:51 PM
Last Post: Raymond Del Tondo
  41 User Memory vs System Memory Gerry Schultz 6 323 07-01-2012, 12:02 AM
Last Post: Monte Dalrymple
  41-MCODE Vector Calculator (3D) Ángel Martin 0 85 11-16-2011, 08:15 AM
Last Post: Ángel Martin
  [OT] New Casio Grapher Tim Wessman 40 1,108 10-13-2010, 04:22 PM
Last Post: Jimi

Forum Jump: