This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - Han
46
« on: December 22, 2013, 12:06:47 pm »
That's not scrolling as you are using G1 as both the input and the output of the BLIT. So as the BLIT command carries out the copying, the bits in G1 are changing! Assuming G1 is a larger graphic, then you should blit to G0 different sections of G1.
47
« on: December 22, 2013, 10:28:03 am »
Changing the user's settings is not a really good programming practice unless you can guarantee that no matter what the user does during program execution, their settings will be returned to the state prior to running the program. In your case, if the user presses the [On] key, program execution is halted and there is a chance the user's angle settings do not get restored. Instead, use the angle setting to test whether or not your own program needs to do angle conversion. If your code is written with the assumption that radians are used, and the user's calculator happens to be in degrees, then
GETANGLE(a) BEGIN IF HAngle THEN a:=a/PI*180; // angle was assumed to be in radians when programmed; convert to degrees END; RETURN(a); END;
So now you can just do SIN(GETANGLE( blah )) and always assume that the angle is in radians (while you program). Whether or not the user's settings is in radians won't affect the outcome as GETANGLE() will convert accordingly.
48
« on: December 19, 2013, 12:42:32 pm »
Yes, you can transfer directly between emulator and the actual calculator, bypassing the connectivity kit altogether.
49
« on: December 18, 2013, 11:08:40 pm »
I found your problem. It's a whitespace issue that I had already reported. It's not the LOCAL statement at all, but a matter of the whitespace used by the forum not be interpreted as whitespace accepted by the HP Prime!!
50
« on: December 18, 2013, 11:03:43 pm »
I stand corrected. Odd, for some reason I had it ingrained that it had to be = and not := but it does work as you say. Even for EXPORT!
51
« on: December 18, 2013, 08:18:22 pm »
A:=A+1;
is fine. The ":=" is only for storing values into already-declared variable (or built-in system variable). The "=" is used for assignment during declaration. Otherwise, "=" is used to designate equality (so can be used as a boolean test in some cases).
As for the limit, it is 8, not 4. Only 16 bits allocated for declarations, 8 for variables, and another 8 for the corresponding initial values.
52
« on: December 18, 2013, 07:20:17 pm »
For any type of variable declaration that also includes an initial value, don't use the := and instead use only =
So:
LOCAL x=2, y=3;
is ok, but:
LOCAL x:=2, y:=3;
is not correct.
53
« on: December 18, 2013, 04:48:36 pm »
Looks like what I thought was an issue is not, then. I thought I had taken out the WAIT(.25) but I did not. So on the calculator, it was super slow. Without it, it works about as fast as the screenshot.
54
« on: December 18, 2013, 04:23:14 pm »
When you say as fast as the screenshot, I presume you meant even with the WAIT(.25) in the source, yes? I have not soft-reset my calculator yet, but it appears that my calculator is very slow in rendering. Even with WAIT(.25) completely removed, it feels sluggish. I will see if I can record the difference.
55
« on: December 18, 2013, 03:00:52 pm »
Could someone humor me and try running the same code (as posted) on the most recent emulator update (or even firmware)? For some reason it seems to go extremely slowly.
56
« on: December 18, 2013, 02:54:12 pm »
Since I cannot upload yet, here is the source. More info here: http://www.hpmuseum.org/forum/thread-95.html// Graph 3D v2.221 (16-DEC-2013) // by Han Duong
g3D_setdefault(); g3D_getfunc(); g3D_getsettings(); g3D_getwin(); g3D_setgrid(); g3D_getangles(); g3D_rotmatrix(); g3D_compute(); g3D_project(); g3D_draw(); g3D_keys(); xmin3D,xmax3D; ymin3D,ymax3D; zmin3D,zmax3D; grid3D,zoom3D;
rotx,roty,rotz,Rx,Ry,Rz,Rot; xc,yc,zc; Zvals,Points2D,Point,zColor,zClip; redraw3D=1,recompute3D=1,init3D=0; minD,fxy="";
//---------------------------- // START FUNCTION //---------------------------- view "Edit Function",START() begin
if init3D==0 then g3D_setdefault(); end; startview(0,1);
end;
//---------------------------- // RESET FUNCTION //---------------------------- View "Reset Plot Settings",RESET() begin g3D_setdefault(); end;
//---------------------------- // Symb FUNCTION //---------------------------- Symb() begin startview(0,1); end;
//---------------------------- // SymbSetup FUNCTION //---------------------------- SymbSetup() begin msgbox("Use X and Y as the input variables.") end;
//---------------------------- // PlotSetup FUNCTION //---------------------------- PlotSetup() begin if init3D==0 then g3D_setdefault(); end; g3D_getsettings(); end;
//---------------------------- // Plot FUNCTION //---------------------------- Plot() begin if init3D==0 then g3D_setdefault(); end; g3D_draw(); end;
//---------------------------- // Numb FUNCTION //---------------------------- Num() begin local z_Values; if init3D==0 then g3D_setdefault(); end; g3D_compute(); z_Values:=Zvals .+ zc; editmat(Zvals); end;
//---------------------------- // NumSetup FUNCTION //---------------------------- NumSetup() begin if init3D==0 then g3D_setdefault(); end; g3D_setgrid(); end;
//---------------------------- // g3D_setdefault //---------------------------- g3D_setdefault() begin xmin3D:=-10; xmax3D:=10; ymin3D:=-10; ymax3D:=10; zmin3D:=-10; zmax3D:=10; zoom3D:=10; grid3D:=15; rotx:=105; roty:=0; rotz:=5; xc:=0; yc:=0; zc:=0; redraw3D:=1; recompute3D:=1; init3D:=1; fxy:=""; g3D_getfunc(); end;
//---------------------------- // g3D_getfunc //---------------------------- g3D_getfunc() begin local i, ftot=0, fnew, fsel;
for i from 0 to 9 do if ISCHECK(i) then fsel:=i; ftot:=ftot+1; end; end;
if ftot==0 then msgbox("Please enter/select a function!"); startview(0,1); kill; end;
if ftot>1 then msgbox("Please select only one function!"); startview(0,1); kill; end;
fnew:=expr("STRING(V"+fsel+")"); if fnew<>fxy then fxy:=fnew; recompute3D:=1; end; return(recompute3D);
end;
//---------------------------- // g3d_getsettings //---------------------------- view "Plot Settings (all)",g3D_getsettings() begin if init3D==0 then g3D_setdefault(); end; g3D_getwin(); g3D_getangles(); end;
//---------------------------- // g3D_getwin //---------------------------- view "Set Viewing Window",g3D_getwin() begin
local xmin,xmax,ymin,ymax,zmin,zmax; local zoom;
if init3D==0 then g3D_setdefault(); end;
xmin:=xmin3D; xmax:=xmax3D; ymin:=ymin3D; ymax:=ymax3D; zmin:=zmin3D; zmax:=zmax3D; zoom:=zoom3D;
if input( {xmin,xmax,ymin,ymax,zmin,zmax,zoom}, "Graph 3D View Window", { "Xmin=", "Xmax=", "Ymin=", "Ymax=", "Zmin=", "Zmax=", "Zoom factor=" }, { "Enter the value of back side of the viewing box", "Enter the value of front side of the viewing box", "Enter the value of left side of the viewing box", "Enter the value of right side of the viewing box", "Enter the value of bottom side of the viewing box", "Enter the value of top side of the viewing box", "Enter the zoom factor (must be > 0)" }, {xmin3D,xmax3D,ymin3D,ymax3D,zmin3D,zmax3D,zoom3D}) then
if xmin>=xmax then msgbox("Warning: Invalid Xmin/Xmax! Setting Xmax:=Xmin+1"); xmax:=xmin+1; end;
if ymin>=ymax then msgbox("Warning: Invalid Ymin/Ymax! Setting Ymax:=Ymin+1"); ymax:=ymin+1; end;
if zmin>=zmax then msgbox("Warning: Invalid Zmin/Zmax! Setting Zmax:=Zmin+1"); zmax:=zmin+1; end;
if zoom3D<1 then msgbox("Warning: zoom must be > 0; reset to 10"); zoom:=10; end;
if (xmin<>xmin3D) or (xmax<>xmax3D) or (ymin<>ymin3D) or (ymax<>ymax3D) or (zmin<>zmin3D) or (zmax<>zmax3D) then recompute3D:=1; xmax3D:=xmax; xmin3D:=xmin; ymax3D:=ymax; ymin3D:=ymin; zmax3D:=zmax; zmin3D:=zmin; xc:=(xmax3D+xmin3D)/2; yc:=(ymax3D+ymin3D)/2; zc:=(zmax3D+zmin3D)/2; end;
zoom3D:=zoom;
end;
end;
//---------------------------- // g3D_setgrid //---------------------------- view "Set Grid Size",g3D_setgrid() begin local grid;
if init3D==0 then g3D_setdefault(); end;
grid:=grid3D; if input(grid,"Graph 3D Grid Size","Grid Size=","Enter N for an NxN grid",grid3D) then if grid<1 then msgbox("Warning: grid size must be > 0; reset to 15"); grid:=15; end; end;
if grid<>grid3D then recompute3D:=1; end;
grid3D:=grid; end;
//---------------------------- // g3D_getangles //---------------------------- view "Set Rotation Angles",g3D_getangles() begin local rx,ry,rz;
if init3D==0 then g3D_setdefault(); end;
rx:=rotx; ry:=roty; rz:=rotz;
if input({rx,ry,rz}, "Graph 3D Rotation Angles", { "X-angle=", "Y-angle=", "Z-angle=" }, { "Enter the angle (deg) about the x-axis", "Enter the angle (deg) about the y-axis", "Enter the angel (deg) about the z-axis" }, {rotx,roty,rotz}) then if (rx<>rotx) or (ry<>roty) or (rz<>rotz) then rotx:=rx; roty:=ry; rotz:=rz; end; end; end;
//---------------------------- // g3D_rotmatrix //---------------------------- g3D_rotmatrix() begin
A:=rotx; B:=roty; C:=rotz; if HAngle==0 then A:=A*PI/180; B:=B*PI/180; C:=C*PI/180; end;
Rx:=[[1.,0.,0.],[0.,COS(A),-SIN(A)],[0.,SIN(A),COS(A)]]; Ry:=[[COS(B),0.,-SIN(B)],[0.,1.,0.],[SIN(B),0.,COS(B)]]; Rz:=[[COS(C),-SIN(C),0.],[SIN(C),COS(C),0.],[0.,0.,1.]]; Rot:=Rx*Ry*Rz; Rot(3,4):=minD;
end;
//---------------------------- // g3D_compute //---------------------------- g3D_compute() begin
local i,j,dx,dy,xm,ym,func; local m,minZ,maxZ;
if g3D_getfunc() then
iferr func:=STRING(V0); then func:=""; end; V0:=fxy;
if recompute3D then
zColor:=makemat(RGB((grid3D+1-J)/grid3D*255,0,(I-1)/grid3D*255),grid3D+1,grid3D+1); dx:=(xmax3D-xmin3D)/grid3D; dy:=(ymax3D-ymin3D)/grid3D; xm:=xmin3D-dx; ym:=ymin3D-dy; Points2D:=makemat((xm+dx*I-xc,ym+dy*J-yc),grid3D+1,grid3D+1);
// apps currently have terrible bug handling iferr Zvals:=makemat(V0(xm+dx*I,ym+dy*J)-zc,grid3D+1,grid3D+1); then recompute3D:=1; msgbox("Error during evaluation of function!"); V0:=func; kill; end; // end error trap
recompute3D:=0;
// get longest distance from center to prevent inversion minZ:=min(Zvals); maxZ:=max(Zvals); minD:=10+(max(abs(minZ),abs(maxZ))^2+(xmax3D-xc)^2+(ymax3D-yc)^2)^(.5);
end; // if recompute3D
V0:=func;
end; // if g3D_getfunc
end;
//---------------------------- // g3D_project //---------------------------- g3D_project() begin local clip;
g3D_rotmatrix(); dimgrob_p(G1, 320, 240); clip:=triangle(G1); triangle_p(G1, Points2D, zColor, Zvals, { "N", -160, -120, minD*zoom3D }, Rot, clip); blit_p(G0,G1); end;
//---------------------------- // g3D_draw //---------------------------- g3D_draw() begin
if init3D==0 then g3D_setdefault(); end;
g3D_compute(); g3D_project(); g3D_keys(); freeze;
end;
//---------------------------- // g3D_draw //---------------------------- g3D_keys() begin local key,mousein, dx, dy;
while 1 do key:=wait(-1); if TYPE(key)==6 then break; end; if key==-1 then break; end;
repeat case if key==1 then roty:=(roty+5) MOD 360; end; if key==3 then roty:=(roty-5) MOD 360; end; if key==4 then kill; end; if key==7 then rotz:=(rotz-5) MOD 360; end; if key==8 then rotz:=(rotz+5) MOD 360; end; if key==2 then rotx:=(rotx-5) MOD 360; end; if key==12 then rotx:=(rotx+5) MOD 360; end; if key==45 then zoom3D:=max(zoom3D/1.05,.01); end; if key==50 then zoom3D:=zoom3D*1.05; end; end; g3D_project(); until NOT IsKeyDown(key);
end; // end while
end;
57
« on: December 13, 2013, 09:41:05 am »
If you click the Reply or quote button, below the text form you can upload files actually. Of course, at 40 posts you can also upload a link to the file in Omnimaga downloads section as well. Else, there is Cemetech, TI-Planet and Hpcalc.org, but Hpcalc.org can take about 6 months before approving your files.
You may also find the new forums at http://hpmuseum.org/forum a nice place to upload programs. And yes, hpcalc.org takes forever to do updates. Nice programming, Omni!
58
« on: December 07, 2013, 09:03:19 pm »
@Han: wow thanks for such a comprehensive answer!
Not all those I listed were officially employed by HP though. They just were the "big guns" during the day. A lot of their work did make it into the HP49G/HP50G firmware, or toolchain, though.
59
« on: December 07, 2013, 12:44:51 pm »
.. Let's hope they have a Prime now ^^
I wonder, are they still working for HP?
Among the users-turned-employees, I think Cyrille and Tim are the only ones left. Mika and Mozgy, two really awesome SATURN programmers have long disappeared from the HP "scene" from what I can tell. As some of you may recall, Mika was the author of Jazz, which incorporated the ML debugger from Jan Brittenson. Claude-Nicholas Feichter and Mika wrote ALG48. Mozgy reverse-engineered the HPTools and created the GNU Tools, among other programs (e.g. Willy in the Mines adaption for the HP48). Jean-Yves Avenard and folks from the MetaKernel worked for HP but I think they eventually branched off to Hydrix after the Australian office was killed off.
60
« on: December 07, 2013, 12:36:09 pm »
-The calc rebooted after letting my polygon program loop for a very long while (several minutes) before interrupting it. Not sure what caused it, though. -The emulator crashes then restarts when running into an INT command.
The first issue is likely due to a memory leak. As for the second issue, are you using INT for integration? Or did you use it to find integer values of a decimal? The former is how it's implemented on the HP Prime (that is not to say, however, that INT does not have any bugs). For integer values, use IP. Based on my own experiences with the calculator, the error handling on the calculator is likely the cause of MANY issues inside programs -- and even worse in apps. It would not surprise me to find out that crashes are the result of mishandled errors.
|