 Flexible Graphics

Graphing and manipulating functions and data is easy with techBASIC. Using the full power of the iPad and iPhone’s touch screens, you literally reach out and manipulate your data. Flick your finger across the screen and the plot pans with you, or use two fingers to rotate the graph. Unlike programs that only support matrices, techBASIC also supports functions. That means you can zoom in our out with a pinch gesture, and the function recalculates points at the new resolution to give you a new view of the data with no pixilation!

Tap on a plot, and techBASIC labels the location with the Cartesian coordinates of the point. You can also add custom callouts that display specific location at a given point. These callouts move with the data as you pan, rotate and zoom to understand the information.

Add controls to your plots to change the results dynamically. Our samples show you how.

Here are a few samples that give you some idea of the kind of information you can display in techBASIC.

You can color the polygons on a surface or the grid that divides them for strikingly different results.

Choose solid colors, transparency, or even provide a function to color the surface any way you want. This sample varies from white to blue based on the Z value.   In addition to Cartesian coordinates, techBASIC also plots functions in cylindrical or spherical coordinates. In two dimensions, both Cartesian and polar coordinates are available. You can plot functions or points from a matrix in either two- or three-dimensions. For points, you can also show error bars. It’s easy to plot more than one function. You can also export them to Photo at up to a 4 megapixel image. Multiple functions can be plotted at once for comparison. Callouts show interesting points on the plot; tap to show the coordinates at a specific location.

Graph and Manipulate Any Function or Data

techBASIC comes with several examples that show how to use the program. These can also serve as models for your own programs. One of these is Sinx_x, which plots the function 10*sin(r)/r, where r is the distance from the origin. With the options used in the sample, you get the rainbow colored plot seen here. This is just one of several axis styles and coordinate systems supported by techBASIC. Swiping lets you move around to see various parts of the function. Dragging up and down moves the function along the Z axis, while dragging parallel to the X or Y axis drags the function along one of those axis. As you move, the coordinates along the edge of the bounding box update, as does the legend to the right of the plot.

Use two fingers to pinch or expand the plot. You can zoom in as far as you like—techBASIC recomputes the function as you move or zoom, showing as much detail as you like with no loss of accuracy or increase in pixilation.

You can also take it for a spin—literally! Using two fingers held apart like you are going to start a pinch, twist instead. The function will turn about an axis projecting out of the screen. To twist it about an axis in the screen, use to fingers and drag as if you were trying to turn a sphere with the plot inside. It's easy to manipulate functions to see them from any angle or level of detail.

If you tap on the plot, techBASIC will show you the point on the mesh closest to where you tapped, giving the X, Y and Z coordinates. The callout will move around with the plot as you move the plot itself. Tap on the callout to dismiss it. You can add as many as you like.

That's a lot of sophisticated graphing, so it must take a lot or programming, right? Actually, no. Let's take a look. Here's the program that generated the plot:

! Display the graphics view.

system.showGraphics

! Set up the plot, label it, and display the function

! with false color.

DIM p AS Plot

p = graphics.newPlot

p.setTitle("f(x, y) = 10*sin(r)/r; r = sqrt(x*x + y*y)")

p.setGridColor(0.85, 0.85, 0.85)

p.setsurfacestyle(3)

p.setAxisStyle(5)

DIM func AS PlotFunction

func = p.newFunction(FUNCTION f)

! Adjust the function so the portion under the X-Y

! plane is visible, and push it slightly off the Z

! axis so the beginning of the descending curve

! can be seen.

p.setTranslation3D(-4, -3, -2)

p.setScale3D(1, 1, .8)

END

FUNCTION f(x, y)

d = SQR(x*x + y*y)

IF d = 0 THEN

f = 10

ELSE

f = 10*SIN(d)/d

END if

END FUNCTION

Most of the code consists of comments, and a lot of what is left is actually just selecting various styles for the axis, picking colors, and so forth. All we really need to see the function is this:

DIM p AS Plot

p = graphics.newPlot

DIM func AS PlotFunction

func = p.newFunction(FUNCTION f)

END

techBASIC

Visualizing 3D

1. Use techBASIC as the ultimate graphing calculator

2. Create a plot with only a few lines of code

3. Pan and zoom plots with swipes and pinches

4. Rotate 3D plots along an arbitrary axis

5. Supports 2D or 3D Cartesian axis

6. Polar, spherical and cylindrical axis

7. Create 2D and 3D vector plots

8. Create error bars in 2 or 3 dimensions

10. Works on the iPad, iPod or iPhone

Watch Visualization Video              FUNCTION f(x, y)

d = SQR(x*x + y*y)

IF d = 0 THEN

f = 10

ELSE

f = 10*SIN(d)/d

END if

END FUNCTION

techBASIC is the Ultimate Graphing Calculator

Take a look at the lines highlighted in yellow. They define the function to plot. Graphing calculators can plot functions, too, but they are limited to a single-line function. As you can see, techBASIC is not! This function specifically returns the limit when d = 0, rather than trying to divide by zero. You can use the full power of BASIC to easily plot any function, no matter how complex.

Functions in X-Y are just as easy. Change the function so it only has one parameter, and techBASIC automatically plots it in the X-Y plane. You can plot multiple two- or three-dimensional functions at once, and even plot discrete data, as you see in our examples that plot the data collected from the accelerometer, gyroscope or magnetometer. General surfaces are easy, too. Our torus samples show how to create non-functional surfaces and plot them.

Here’s a complete article showing you how to use techBASIC as the ultimate power-user’s graphing calculator. Apps for people who think.™     Plot vector fields in 2D or 3D. Here’s the magnetic field formed by two parallel wires, with controls to change the current direction and strength. Plot arbitrary surfaces, too, not just functions. Here’s a torus with controls to change its parameters. You can watch as it degenerates from a torus to a sphere.

See the graphics in action in this video.

Shade the area under a curve–great for showing the area covered by an integral! 