Twelve years ago, I created a 3D graphing tool for the Casio Prizm called Graph3DP. Written in C, this tool allows up to 6 equations in the form z=f(x, y) to be graphed at once, traced, and viewed in a variety of color schemes. My first two forays into bringing 3D graphing to color-screen TI graphing calculators were a simple TI-BASIC grapher called Graph 3D v4.x and a comprehensive z80 ASM 3D graphing tool for the TI-84 Plus C Silver Edition called Graph3DC. This latter math tool, awarded ticalc.org's 2016 Program of the Year for the TI-84 Plus C Silver Edition, hooked extensively into the TI-OS, similar to (for example) the Inequalz inequality graphing app. Quirks and bugs in the OS required extensive hook workarounds to get everything to work correctly, but I was proud of the result.

Enter the TI-84 Plus CE. I would have loved to port the comprehensively integrated Graph3DC to the TI-84 Plus CE. But without the ability to easily create Apps on the TI-84 Plus CE, I began to look at porting Graph3DP from the Casio Prizm to the TI-84 Plus CE in July 2017. Life and Geopipe got in the way, so it took until this summer when I saw someone else publishing a rudimentary TI-BASIC 3D grapher for the TI-84 Plus CE on ticalc.org for me to be reminded of this project. Over the past two months, I have been (very) occasionally working on this port, and I finally have something to show for it. The current features and goals roughly match its Casio Prizm capabilities:
  • Graph up to 6 3D equations -> works, but runs into memory problems at the moment
  • Enter equations with custom input routines -> mostly works, but keys repeat way too fast, and the font looks a little grim
  • Zoom and set the graph window from Zoom and Window menus -> pretty much work
  • Trace graphs -> works, but it's slower than I'd like. Same with graphing. For tracing, I'll probably switch from redrawing the graph each time to saving and restoring the area under the trace cursor and the X/Y/Z values
  • Graph in multiple color modes -> the spectra need to be adjusted to work correctly in 8-bit palettized color mode.
  • Fast graph calculation with gCAS2 -> Like Graph3DP, Graph3DC for the TI-84 Plus CE embeds AHelper's gCAS2 as an alternative to the TI EOS, slightly limiting the functions that can be used in graphs but (I believe) significantly accelerating computation. I'm willing to test out the TI EOS against it just to be sure, but based on the speed of graphing, I don't expect (for example) 21*21 = 441 computations of the below equation Z=(Y*X^3-X*Y^3)/390 to be faster than the 7.5 seconds it takes gCAS2


As always, I'll keep the updates (and screenshots) coming, and I welcome comments and suggestions.

Edit 11/29/2024: For consistency with my own internal docs, and to avoid confusion with Graph3DC for the TI-84 Plus C Silver Edition, I'll be calling this Graph3CE instead of Graph3DC.

This evening, I fixed a bug with gCAS2 where entering a single numerical constant as an equation (e.g., Z=3 or Z=777) would cause the parser to get stuck in an infinite loop. It's not clear why this bug doesn't manifest itself on the existing 2014 Casio Prizm build, but it does make me consider the wisdom of sticking with AHelper's relatively fragile gCAS2 over the TI's own parser, and further induces me towards testing the OS parser's speed for this application.
Nice this looks awesome! Why does it seem like a few lines are missing in the graph image? Is it possible to set custom colors for the graph?
MateoConLechuga wrote:
Nice this looks awesome! Why does it seem like a few lines are missing in the graph image?
Thank you! For some reason, a few grid point values are receiving a value of infinity, even though the equation cannot yield an infinite value for finite X and Y. Likely another interesting, overlooked gCAS2 bug.

Quote:
Is it possible to set custom colors for the graph?
By pressing Zoom, it's possible to switch between three preset color schemes: spectrum, tropical ocean, and flame. I can certainly appreciate the idea of a way to set a custom gradient, but that'll certainly come after everything is stable, if at all.
MateoConLechuga wrote:
Nice this looks awesome! Why does it seem like a few lines are missing in the graph image?
In fact, unless I've made an error, I may have uncovered a bug in the toolchain: https://github.com/CE-Programming/toolchain/issues/511

Among my recent progress is a nice new debouncing and key repeat feature that does all the things a user would expect (e.g., delayed first repeat and faster subsequent repeats), plus debugging the routines that store and restore saved state such as Z= equations across program runs.

Edit: Thanks to Runer112, MateoConLechuga, and calc84maniac, the isinf() bug is fixed:

This looks awesome!!
TortillaMan wrote:
This looks awesome!!

Thank you!

As suggested by Mateo, I switched to using a custom palette for each of the three graph color modes ("RGB", "ocean", and "flame"), rather than approximating each of the program's palettes with colors from the xLIBC palette. The result isn't hugely different, but because it saves math (and hence speed) and allows instant switching, I'm sticking with it.

This looks pretty and I love the color palette change. I always love to see 3D graphing appear on calculators where the OS lacks such feature. Smile
Looks Nice!
Neat! I've been looking for a good 3D graphing program because all the other ones are in Basic.
Thanks, everyone! I hope I can deliver a good alternative to the TI-BASIC ones.

My latest work has been tracking down a memory error I introduced while optimizing the graphing: now, equations are all parsed first before any graphed surfaces are computed, which allows invalid (e.g., syntax error-containing) equations to be detected more quickly. I accidentally introduced a free() of an uninitialized pointer, and because it was uninitialized rather than initialized to NULL, it wasn't easy to catch.

I spent a few hours today refactoring code to pull myself out of the depths of my early 2010s C coding style. From a user perspective, the functionality is unchanged, but I took the time to start this refactor to get rid of three cardinal sins:
  1. A monolithic, ~1000-line main() function
  2. Global variables unencapsulated in any containing structures
  3. Use of labels and gotos
Specifically, I worked on the portion of the program that graphs and manipulates graphs, pulling out pieces into separate functions, and encapsulating the state used by those new functions in tidy structs. I have more than I will pull out in future refactoring sessions, which will allow me to remove the remaining gotos/labels in that portion of the code (and therefore the entire program). No screenshots this time!

Edit: I refactored out the code that renders graphs into a separate function as well, eliminating the last three mutable global variables in the process.
My Graph3DC focus today was on tracing: I first restored the tracing functionality present in Graph3DP as-is (left screenshot), then optimized (right screenshot). The optimizations encompass both code structure and user experience improvements: in the process of saving portions of the screen to the buffer to avoid redrawing the whole graph when the trace cursor is moved, I also removed one of the labels/gotos in the graphing portion of the program, replacing it with nested loops. Thanks to calc84maniac and MateoConLechuga for pointing out the right way to use the toolchain to achieve what I wanted.

The results look really great Kerm!
Thank you!

A few new improvements of varying complexity. First, graph segments are colored by average endpoint color rather than a single endpoint's color. Since the TI-84 Plus CE implementation now uses indexed colors (indices 2-254 are used for the minimum to maximum Z-height of the graphed function(s)), it's easy to average the two, producing a clearer result, especially for symmetric functions. Left shows the old coloring (still used on the Prizm version), using the color of a single endpoint, while the right shows the improved averaging.


I also made the transition between the Graph and Trace modes seamless. Now that I have untangled the decade-old code I wrote for graphing, simplifying it down to loops and function calls and removing a hundreds-of-lines chunk of goto-laced code, I can avoid recomputing function values and resetting the graph when the user switches from Graph to Trace, or Trace to Graph. Besides speed, this has the added feature benefit of allowing the user to rotate the graph to an optimal perspective to examine the function in question, trace it to explore values, then adjust the rotation and re-trace. Previously, tracing was only possible in a top-down view. This unfortunately does mean a little more memory is used to store the original Z values of each function to display during tracing, even when the x/y/z values have otherwise been modified for rotation, but I think it's worth it.

Wow this looks really good! When do you think a stable download will be released? Also the color changing feature thingy is something that isn't even on the standard 2d graphing so that's really nice. Also this could be a silly question, but is it possible to graph 2d implicit equations using this? I'm not entirely sure how implicit functions are graphed but on the 89 titanium you graph them from the 3D graphing mode with z=(side 1 of equation in terms of x and y) - (side 2 of the equation in terms of x and y) so maybe it has something to with that? Also there's this video showing the implicit graphs on the 89 titanium I was talking about if you're confused.
guywithathing wrote:
Wow this looks really good! When do you think a stable download will be released?
Thank you! I'm hoping to get a beta out for testing in the two weeks. My biggest remaining task is to write a test suite for the program's built-in CAS that compiles and runs PC-side, because I know there are bugs in it.

guywithathing wrote:
is it possible to graph 2d implicit equations using this?
Yes! Because it accepts graphs in the form z=f(x,y), you can precisely follow that video with Graph3DC. In fact, I'll probably make a few videos on 3D graphing on the TI-84 Plus CE that follow 3D graphing tutorials for the TI-89, including implicit functions.
This looks great! Will it work on a 83 plus?
Programs targeting the TI-eZ80 series almost always work on all of 84+CE / 84+CEPE / 83PCE / 83PCEEP. The main exceptions are the variant of Python based on the internal ARM chip, and programs depending on the exact math engine.
The 83+ is different, though: monochrome screen, different processor, less memory etc.
Indeed, as Lionel says, this will only work on the modern color-screen calculators. I have an older, simpler TI-BASIC 3D grapher for the monochrome z80 calculators like the TI-83, TI-83 Plus, and TI-84 Plus.

As I indicated I would, I (re-)made gCAS, the CAS that is built into Graph3DC, cross-compile for Linux. With this, I made a rudimentary test harness for it, with a handful of tests:


Code:
X^2+Y^3 (X=0.130000, Y=-4.200000) = -74.071091
sin(X)+cos(Y) (X=3.141593, Y=3.141593) = -1.000000
3 (X=0.000000, Y=0.000000) = 3.000000
-4.203 (X=42.000000, Y=1337.000000) = -4.203000
3*X*pi (X=-1.500000, Y=0.000000) = -14.137167
atan(X)+asin(Y)/2. (X=4.712389, Y=0.785398) = 1.813361
All tests passed!


I definitely need to re-add the help screen, as the parser has some differences from the OS parser that will confuse novice users:
  • asin, acos, and atan are used instead of sin^-1, cos^-1, and tan^-1.
  • I need to make sinH, cosH, and tanH accessible, probably via [ALPHA] + [sin]/[cos]/[tan].
  • At present, the square root function is sqrt, not √.
  • Implicit multiplication is not supported
  
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 2
» All times are UTC - 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