Blitz Math 3D — user manual

Version 1.0. Authors: Olivier Landemarre & Claude AI opus 5.5.

Blitz Math 3D draws curves, surfaces and volumes described by formulas, in three dimensions. You type a formula, choose the domain, and the object appears in a GEM window, where you turn it with the mouse, set the light, the colors, a section… before saving your document or exporting the image.

Contents:

  1. Installation and versions
  2. Getting started
  3. The object window
  4. Writing a formula
  5. Document types, with examples
  6. The menus
  7. The settings boxes
  8. Variables and animation
  9. Saving, exporting, exchanging
  10. The command line
  11. Example documents
  12. Tips and frequently asked questions

1. Installation and versions

The files

FileRole
MATH3D.PRGthe full version, for a 68030 or better with a coprocessor (FPU)
MATH3D60.PRGthe same full version, for the 68060 (CT60, CT63, Hades, Milan…)
MATH3DCF.PRGthe same full version, for the ColdFire V4e of the FireBee
MATH3DL.PRGthe light version, for a 68000 without coprocessor
MATH3D.RSCthe resource (menus, boxes, texts), in French
RSRC\MATH3D<n>.RSCthe resource in the other languages
EXAMPLES\example documents, 8.3 names for TOS (section 11)
EX_LONG\the same, with their original names (MiNT, MagiC, Linux)
MANUAL.TXT, MANUAL.PDFthis manual; MANUEL.TXT and MANUEL.PDF in French
LISEZMOI.TXTthe content of the archive, in short

Copy everything into one folder, keeping MATH3D.RSC and the RSRC folder next to the programs. At startup, the program takes the resource of the system language (English, German, Spanish, Portuguese, Catalan, Italian, Dutch, Swedish, Norwegian, Danish, Finnish, Czech, Hungarian, Polish, Romanian, Greek) if it is in RSRC, otherwise MATH3D.RSC, in French. This manual uses the names of the English resource.

The language comes from the AES. MyAES follows the country code saved in the NVRAM (and loads the resource of that code by itself); XaAES, the one of its configuration. Portuguese (code 35) and Catalan (54) are thus picked up automatically there. TOS and EmuTOS do not report the language: to force one, copy its resource over MATH3D.RSC, for example RSRC\MATH3D0.RSC for US English or RSRC\MATH3D35.RSC for Portuguese.

Czech, Hungarian, Polish, Romanian and Greek are written in the system font of their country (Kamenický, Latin-2, Greek), the one a machine set up for that country has. Copied onto a machine with the Western European font, these resources would show wrong letters.

The program writes a small file next to itself, MATH3D.CFG: the list of recent files.

Which version?

MATH3D.PRG (full)MATH3DL.PRG (light)
Processor68030 or better, with FPU (Falcon + 68882, TT, CT60, V4SA…)any Atari, 68000 included (ST, STE, Mega ST, basic Falcon)
Memory2 MB minimum2 MB minimum
Screensfrom monochrome to True Colorfrom monochrome to 256 colors, Falcon 16 bits (not the 24 and 32-bit modes nor the Intel byte order of graphics cards)
Computingin floating pointin fixed point for interaction, fast without FPU

On a 68060 (Falcon with CT60 or CT63, Hades, Milan…), take MATH3D60.PRG: the full version compiled for that processor. The 68060 no longer has some coprocessor instructions in hardware (sine, exponential, logarithm…): MATH3D60.PRG computes them itself, without going through the system's slow emulation. On a 68060, MATH3D.PRG also works, but more slowly.

On the FireBee, take MATH3DCF.PRG: it is the full version, compiled for its ColdFire V4e processor and its coprocessor. It does everything MATH3D.PRG does, command line included.

The light version does everything needed to draw the "classic" curves and surfaces: explicit, parametric, polar, cylindrical, spherical curves, meridians; parametric, spherical, revolution surfaces, graphs; implicit curves and isosurfaces; tubes; solid faces and wireframe.

Only in the full version: differential equations, phase portraits, complex functions, vector fields, conformal maps, STL objects; color by curvature, contour lines, critical points, geodesics, Frenet frames, field lines, section by a plane, several isosurfaces; Measures, Variables, Animate a variable; the sum() function; the SAGA overlay of the V4SA.

In the light version, fog, specular highlights and smooth shading are greyed out (too slow without FPU). A document coming from the full version that uses them still opens: the option stays available, so that you can switch it off.

Both versions read and write the same document format (.ARG).

Systems

TOS, EmuTOS, MagiC, MiNT with XaAES or MyAES. The settings boxes open in windows where the AES allows it (AES 4.1 and later), and as modal boxes elsewhere.

2. Getting started

Your first object, a saddle:

  1. Start the program, then File > New.
  2. In the Surfaces column, choose Graph z = f(x,y).
  3. The domain offers x from -2 to 2, 32 points and the same for y: keep it. Click Create.
  4. A plane appears (the starting formula is 0). Choose Object > Formulas…, type x*x-y*y and confirm.
  5. Drag the mouse in the window with the left button held down: the object turns. With Shift held down, dragging zooms.
  6. Render > Colors…: type orange in Object, confirm.
  7. File > Save as…: your document is a .ARG file.

Each document type starts with a neutral formula (a plane, a circle, a sphere…) that you then replace with your own: it is the simplest way to see at once what the domain covers.

3. The object window

ActionEffect
drag, left buttonturns the object
Shift + dragzooms
mouse wheel (if the mouse has one and the system passes it on)zooms
right buttonopens the context menu
Undo / Ctrl+Zundoes the last change
Shift+Undo / Ctrl+Yredoes
Ctrl+Ccopies the image to the clipboard

While you turn the object, the window shows a preview (wireframe, or solid faces if Window > Solid preview is checked); the final image is computed when you release the button.

The context menu (right button)

4. Writing a formula

Operators

NotationMeaning
+ - * /the four operations
^power: x^2, 2^x, x^0.5
%remainder of the division
( )parentheses
< <= > >= == !=comparisons: 1 if true, 0 if false

Numbers are written with a decimal point: 0.5, 6.283185, 1e-3.

Functions

FunctionMeaning
sin cos tantrigonometry, angles in radians
asin acos ataninverse functions
atan2(y, x)angle of the point (x, y), from −π to π
sinh cosh tanhhyperbolic functions
expexponential
lnnatural logarithm
log, log10base-10 logarithm
sqrtsquare root
absabsolute value
floor, ceilround down, round up
pow(a, b)a to the power b
fac(n)factorial
ncr(n, k), npr(n, k)combinations, permutations
min(a, b), max(a, b)the smaller, the larger
sign(x)−1, 0 or 1
mod(a, b)remainder of a by b
hypot(a, b)√(a² + b²)
if(c, a, b)a if c is true (non-zero), otherwise b
sum(k, start, end, term)sum of term for integer k from start to end (full version)

Constants: pi (3.14159…) and e (2.71828…).

Examples

FormulaMeaning
sqrt(x*x+y*y)distance to the origin
if(x*x+y*y<1, sqrt(1-x*x-y*y), 0)a half-sphere standing on a plane
min(x, 1)x, capped at 1
abs(sin(3*t))a "bouncing" sine wave
sum(k,1,8,sin((2*k-1)*x)/(2*k-1))Fourier series of a square wave, 8 terms

Pitfalls

Document variables

In the full version, Object > Variables… defines up to six variables (R = 4, r = 1.5…) usable in all formulas and in the section plane. See section 8.

5. Document types, with examples

Each type has its formulas, its variables and its domain. The domain is given in lines "from … to … points": the bounds and the number of computed points (more points: finer, but slower).

Useful values: 2π = 6.283185, π = 3.141593, π/2 = 1.570796, 4π = 12.566371, 6π = 18.849556.

Types marked ★ exist only in the full version.

5.1 Curves

Explicit curve — y(x), z(x)

Two formulas in x; the curve goes through (x, y(x), z(x)). Domain: x. Put 0 in z for a plane curve.

Curvey(x)z(x)domain x
damped sineexp(-x/4)*sin(3*x)00 to 12.566371, 400
Gaussian bellexp(-x*x)0−3 to 3, 200
space curvesin(x)cos(2*x)/20 to 6.283185, 300

Parametric curve — x(t), y(t), z(t)

Three formulas in t. Domain: t.

Curvex(t)y(t)z(t)domain t
helixcos(t)sin(t)t/40 to 18.849556, 400
trefoil knotsin(t)+2*sin(2*t)cos(t)-2*cos(2*t)-sin(3*t)0 to 6.283185, 400
Viviani's curve1+cos(t)sin(t)2*sin(t/2)0 to 12.566371, 400
3D Lissajoussin(3*t)sin(4*t)sin(5*t)0 to 6.283185, 600
torus knot (2, 5)(2+cos(5*t))*cos(2*t)(2+cos(5*t))*sin(2*t)sin(5*t)0 to 6.283185, 600

Polar curve — r(t)

One formula in t: the point at distance r(t) from the origin, in direction t, in a horizontal plane. Domain: t, plus the height of the plane (z plane).

Curver(t)domain t
circle10 to 6.283185
cardioid1+cos(t)0 to 6.283185
5-petal rosecos(5*t)0 to 3.141593
Archimedean spiralt/60 to 18.849556
logarithmic spiralexp(t/8)0 to 18.849556
Fay's butterflyexp(sin(t))-2*cos(4*t)+sin((2*t-pi)/24)^50 to 75.398224, 2000

Front view: Render > Camera…, yaw 0 and pitch 0.

Cylindrical curve — r(t), z(t)

Two formulas in t: distance r(t) to the vertical axis and height z(t), in direction t.

Curver(t)z(t)domain t
helix1t/40 to 18.849556
conical spiralt/6t/60 to 18.849556
wavy crown10.2*sin(8*t)0 to 6.283185
spring with growing pitch1t*t/400 to 25.132741

Spherical curve — r(t), theta(t), phi(t)

Three formulas in t: distance to the origin, angle from the pole (theta, from 0 to π) and longitude (phi).

Curver(t)theta(t)phi(t)domain t
equator11.570796t0 to 6.283185
clelia1t8*t0 to 3.141593, 600
loxodrome1pi-2*atan(exp(t/6))t−30 to 30, 1500
spiral on a growing spheret/6t/24*t0 to 6.283185

Meridian — r(u)

One formula in u: the profile of a surface of revolution, drawn as a curve (the point at distance r(u) from the axis, at height u). Domain u, plus the angle of the meridian; checkbox x axis (else z). It is the curve that the surface of revolution (5.2) turns around the axis.

Profiler(u)domain u
vase1+0.3*sin(3*u)−1 to 1
coneu0 to 1
dropsqrt(1-u*u)*(1-u)/2−1 to 1

Tube and Frenet frame

A curve can be drawn as a tube: it is an option of the document (--tube on its line, see section 9 and the examples FRENET.ARG, NOEUDTOR.ARG). In the full version, Render > Overlays… adds Frenet frames (tangent, normal, binormal) along the curve, and Render > Colors… the color by curvature or by torsion.

★ Differential equation — x', y', z'

Three formulas in x, y, z, t: the derivatives dx/dt, dy/dt, dz/dt. The program follows the solution from a starting point (the start line of the domain), with the fourth-order Runge-Kutta method. Domain: t (duration and number of steps).

Systemdx/dtdy/dtdz/dttstart
circle-yx00 to 6.283185, 2001, 0, 0
helix-yx0.20 to 31.4, 8001, 0, 0
Lorenz attractor10*(y-x)x*(28-z)-yx*y-8/3*z0 to 40, 40001, 1, 1
Rössler attractor-y-zx+0.2*y0.2+z*(x-5.7)0 to 150, 60001, 1, 0
damped spiral-0.1*x-yx-0.1*y00 to 40, 8002, 0, 0

If the trajectory looks angular, increase the number of steps.

★ Phase portrait — x', y'

Two formulas in x, y, t: dx/dt and dy/dt in the plane. One trajectory starts from each point of a grid (the x and y lines of the domain) and lasts the time of the t line; it stops at the edge of the window.

Systemdx/dtdy/dtxyt
center (circles)-yx−2 to 2, 5−2 to 2, 50 to 6.283185, 100
pendulumy-sin(x)−6 to 6, 13−3 to 3, 70 to 10, 200
Van der Poly(1-x*x)*y-x−3 to 3, 7−3 to 3, 70 to 20, 400
saddlex-y−2 to 2, 9−2 to 2, 90 to 3, 100

★ Vector field — Fx, Fy, Fz

Three formulas in x, y, z: one arrow at each point of a grid (three domain lines; a line of a single point gives a plane). In Render > Overlays…, Field lines draws the lines that follow the field instead of the arrows.

FieldFxFyFzgrid
rising vortex-yx0.3−1 to 1 (5, 5, 3)
sourcexyz−1 to 1 (5, 5, 5)
pendulum (plane)y-sin(x)0x −4 to 4 (9), y −2.5 to 2.5 (7), z 0 to 0 (1)
Lorenz10*(y-x)x*(28-z)-yx*y-8/3*z−20 to 20, −25 to 25, 5 to 45 (7 each)

★ Conformal map — Re w, Im w

Two formulas in x, y: the real part and the imaginary part of w = f(x + iy). The program draws the image by f of the vertical (orange) and horizontal (blue) lines of the domain grid. Right angles are preserved: this is what is called a conformal map.

f(z)Re wIm wxy
z²x*x-y*y2*x*y0.2 to 1.2, 11−1 to 1, 11
exp zexp(x)*cos(y)exp(x)*sin(y)−1 to 1, 9−3.141593 to 3.141593, 25
1/zx/(x*x+y*y)-y/(x*x+y*y)0.5 to 2, 11−1 to 1, 11
z³x^3-3*x*y*y3*x*x*y-y^30.2 to 1.2, 11−1 to 1, 11

A front view is advised (yaw 0, pitch 0).

5.2 Surfaces

Parametric surface — x(u,v), y(u,v), z(u,v)

Three formulas in u and v. Domain: u and v.

Surfacex(u,v)y(u,v)z(u,v)uv
planeuv0−2 to 2−2 to 2
saddleuvu*u-v*v−2 to 2−2 to 2
spherecos(u)*sin(v)sin(u)*sin(v)cos(v)0 to 6.2831850 to 3.141593
torus(2+cos(v))*cos(u)(2+cos(v))*sin(u)sin(v)0 to 6.2831850 to 6.283185
Möbius strip(1+v/2*cos(u/2))*cos(u)(1+v/2*cos(u/2))*sin(u)v/2*sin(u/2)0 to 6.283185, 60−1 to 1, 10
helicoidv*cos(u)v*sin(u)u/20 to 12.566371−1 to 1
Enneper surfaceu-u^3/3+u*v*vv-v^3/3+v*u*uu*u-v*v−2 to 2−2 to 2
seashell2*(1-exp(u/18.849556))*cos(u)*cos(v/2)^22*(exp(u/18.849556)-1)*sin(u)*cos(v/2)^21-exp(u/9.424778)-sin(v)+exp(u/18.849556)*sin(v)0 to 18.849556, 800 to 6.283185, 24
pretzel (example)(4+1.5*cos(u)+4*cos(v*0.5)^2)*cos(2*v)(4+1.5*cos(u)+4*cos(v*0.5)^2)*sin(2*v)1.5*sin(u)+4*sin(v)0 to 6.283185, 400 to 6.283185, 40

Spherical surface — r(theta, phi)

One formula in theta (angle from the pole, from 0 to π) and phi (longitude, from 0 to 2π): the distance to the origin in each direction.

Surfacer(theta, phi)
sphere1
bumpy sphere1+0.25*sin(3*phi)*sin(theta)
flower1+0.3*sin(5*phi)*sin(theta)^2
harmonic (lobes)abs(cos(theta))+0.3
prolate ellipsoid1/sqrt(sin(theta)^2+cos(theta)^2/4)

Advised domain: theta 0 to 3.141593 (24 to 40 points), phi 0 to 6.283185 (twice as many points).

Surface of revolution — r(u)

One formula in u: the meridian turns around the axis (z by default, x if the x axis checkbox is checked). Domain: u (along the axis) and v (the angle, usually 0 to 2π).

Surfacer(u)u
cylinder1−1 to 1
coneu0 to 1
paraboloidsqrt(u)0 to 2
hyperboloidsqrt(1+u*u)−2 to 2
vase1+0.3*sin(3*u)−1 to 1
spheresqrt(1-u*u)−1 to 1
torus (one half)2+sqrt(1-u*u)−1 to 1

Graph — z = f(x, y)

One formula in x and y, the height. Domain: x and y.

Surfacez(x, y)domain
saddlex*x-y*y−2 to 2
paraboloidx*x+y*y−2 to 2
bellexp(-x*x-y*y)−2 to 2
wavessin(x)*cos(y)−6 to 6, 60
circular ripplescos(3*sqrt(x*x+y*y))/(1+x*x+y*y)−4 to 4, 60
sombreroif(x*x+y*y>0, sin(3*sqrt(x*x+y*y))/(3*sqrt(x*x+y*y)), 1)−4 to 4, 60
half-sphereif(x*x+y*y<1, sqrt(1-x*x-y*y), 0)−1.5 to 1.5, 40
monkey saddlex^3-3*x*y*y−1 to 1
two bumpsexp(-x*x-y*y)*cos(2*x)+0.4*exp(-((x-1.2)^2+(y+0.8)^2))−2.5 to 2.5, 60

The graph is ideal for contour lines and critical points (full version, Render > Overlays…).

★ Complex function — w = f(x + iy)

Two formulas in x and y: the real part and the imaginary part of w. The height is the modulus |w| (capped), the color the argument (red for positive reals, then the whole hue circle): you see the zeros (the modulus touches 0 and all colors meet there) and the poles (the modulus rises to the cap).

f(z)Re wIm w
zxy
z²x*x-y*y2*x*y
z³ − 1 (domain −1.5 to 1.5)x^3-3*x*y*y-13*x*x*y-y^3
1/zx/(x*x+y*y)-y/(x*x+y*y)
exp zexp(x)*cos(y)exp(x)*sin(y)
sin zsin(x)*cosh(y)cos(x)*sinh(y)
(z² − 1)/(z² + 1)see COMPLEXE.ARG

Advised domain: −2 to 2 in x and in y, 32 to 48 points.

5.3 Implicit objects

An implicit curve or surface is the set of points where a formula equals zero: x^2+y^2-1 gives the unit circle. The program looks for this zero on a grid: the domain must contain the object, and more points give a finer drawing.

Contour — f(x, y) = 0

One formula in x and y. Domain: x and y, plus the height of the plane.

Curvef(x, y)domain
circlex^2+y^2-1−2 to 2, 40
ellipsex^2/4+y^2-1−2.5 to 2.5, 40
lemniscate of Bernoulli(x*x+y*y)^2-2*(x*x-y*y)−2 to 2, 60
folium of Descartesx^3+y^3-3*x*y−3 to 3, 60
cardioid(x*x+y*y-x)^2-(x*x+y*y)−1 to 2.5, 60
heart curve(x*x+y*y-1)^3-x*x*y^3−1.5 to 1.5, 60
periodic patternsin(x)*sin(y)-0.2−6 to 6, 80

Slice — f(x, y, z) = 0 in a plane

One formula in x, y, z; the program draws the curve where the surface f = 0 cuts a plane where one coordinate is constant (axis: x, y or z, and its value). The two domain lines are those of the two other axes.

Examplef(x, y, z)slice
equator of the spherex^2+y^2+z^2-1z = 0
smaller circlex^2+y^2+z^2-1z = 0.6
hyperbola of a saddlex*x-y*y-zz = 0.5
slice of a torus(x*x+y*y+z*z+3)^2-16*(x*x+y*y)y = 0 (domain −3.5 to 3.5)

Intersection — f = 0 and g = 0

Two formulas in x, y, z: the curve common to both surfaces. Domain: x, y, z.

Curvefgdomain
equatorx^2+y^2+z^2-1z−1.5 to 1.5, 24
Viviani's curvex^2+y^2+z^2-4(x-1)^2+y^2-1−2.2 to 2.2, 32
two cylindersx*x+z*z-1y*y+z*z-1−1.5 to 1.5, 32
tilted circlex^2+y^2+z^2-1x+y+z−1.5 to 1.5, 32

Isosurface — f(x, y, z) = 0

One formula in x, y, z: the closed surface where f is zero. Domain: x, y, z. This is the slowest type to compute: start with 20 points per axis, then go up.

Surfacef(x, y, z)domain
spherex^2+y^2+z^2-1−1.5 to 1.5, 20
ellipsoidx^2/4+y^2+z^2-1x −2.5 to 2.5, y and z −1.5 to 1.5
torus(x*x+y*y+z*z+3)^2-16*(x*x+y*y)x, y −3.5 to 3.5; z −1.5 to 1.5; 32
rounded cubex^4+y^4+z^4-1−1.5 to 1.5, 24
gyroidsin(x)*cos(y)+sin(y)*cos(z)+sin(z)*cos(x)−3.2 to 3.2, 32
Schwarz P surfacecos(x)+cos(y)+cos(z)−3.2 to 3.2, 32
one-sheet hyperboloidx^2+y^2-z^2-0.5−1.5 to 1.5, 32
conex^2+y^2-z^2−1.5 to 1.5, 32
heart(x*x+9/4*y*y+z*z-1)^3-x*x*z^3-9/80*y*y*z^3−1.5 to 1.5, 40

★ Several isosurfaces: the same f at several levels, each in its own color (blue → red), for example the spheres x^2+y^2+z^2 at levels 0.25, 1 and 2.25 (document COUPEANI.ARG, or HYPERBOL.ARG for x^2+y^2-z^2 at levels −0.5, 0, 0.5). This setting is made in the document (--iso-levels 0.25,1,2.25 on its line).

5.4 ★ STL object

File > Open… accepts an STL file (text or binary), as written by CAD and 3D printing software. The object has neither formula nor domain; all render settings apply to it. An object too large for the free memory is refused before being read.

6. The menus

B-Math 3D

About Blitz Math 3D: the version number (1.0), the variant (68030 with FPU, 68060 with FPU, ColdFire V4e, or light for 68000) and the build date.

File

EntryEffect
Newchoose a document type and its domain (section 5)
Open…open a .ARG document (or an STL object, full version)
Recent filesthe last four documents opened or saved
Save, Save as…write the document
Export TGA image…the image, at the size of the window
Export OBJ mesh…the mesh (surfaces, isosurfaces, STL), for a 3D modeler
Export VRML scene…, Export POV scene…a complete scene (object, camera, light, colors) for a VRML viewer or POV-Ray
Quit

Edit

EntryEffect
Undoback to the document before the last change (16 steps, 4 in the light version)
Redoredoes what was undone
Copyputs the image on the clipboard (SCRAP.TGA and SCRAP.IMG)

Object

EntryEffect
Formulas…the formulas of the document
Domain and mesh…the bounds and number of points, the axis, the starting point
★ Measures…length, area, volume (closed object), bounding box, number of critical points
★ Variables…the variables of the document (section 8)
★ Animate a variable…varies a variable in the window (section 8)

Render

EntryEffect
Camera…orientation and field of view
Light…direction, ambient light, highlights, shading
Colors…colors of the object, background, wireframe, fade, curvature
★ Overlays…contour lines, critical points, geodesics, Frenet frames, field lines
★ Section…the section plane
Fog…fog by distance or by altitude
Solidsolid faces, on or off
Wireframethe mesh drawn, on or off

Window

EntryEffect
Computecomputes the image again
Closecloses the document
Progress boxshows a box during the computation (otherwise only the mouse pointer)
Modal boxessettings boxes as modal dialogs, even where the AES can put them in windows
Solid previewwhile turning: solid faces instead of the wireframe (fast machines)
Light previewwhile turning: fewer lines (slow machines; checked by default in the light version)
Error diffusion dither, Ordered dither (Bayer)in 16 colors or fewer, how shades are rendered
Overlay SAGA (PIP), 8-bit palette, Orientation palettedisplay through the overlay of the Vampire V4SA (full version)

These window settings last for the session; they are not saved in the document.

7. The settings boxes

Where the AES allows it, the boxes open in windows: you can keep several of them open, change a value and click Apply to see the effect without closing the box.

Camera

Yaw (rotation around the vertical axis) and Pitch, in degrees; Field of view (larger: stronger perspective). Initial view goes back to the starting camera. Front view: yaw 0, pitch 0.

Light

Colors

Object, Background, Wireframe, and Fade to (a color reached with depth). A color is written:

With a resource in another language, the color names of that language are accepted too, and the English names always.

★ Color by curvature: the color follows the curvature of the surface (Gaussian by default, or Mean) or of the curve (curvature, or Torsion); scale sets the sensitivity.

★ Overlays

What is drawn on top of the object:

★ Section

The plane a·x + b·y + c·z = d: the side a·x + b·y + c·z ≤ d is kept, the other is removed, which opens the object like a cutaway. Examples:

a, b, c, dEffect
0, 0, 1, 0removes everything above z = 0
1, 0, 0, 0.5keeps x ≤ 0.5
0, 1, 0, hcuts at y = h, where h is a variable (to animate)
-1, 0, 1.7320508, 0a plane tilted by 60° (Villarceau circles of the torus)

The four numbers may be formulas of the document variables.

Fog

★ greyed out in the light version.

8. Variables and animation

Full version.

Object > Variables…: six lines name = value. A variable can be used in all formulas of the document and in the section plane. Leaving a name empty removes the variable.

Example, the pretzel with two parameters (BRETZVAR.ARG): variables R = 4 and r = 1.5, formulas

x(u,v) = (R+r*cos(u)+R*cos(v*0.5)^2)*cos(2*v)
y(u,v) = (R+r*cos(u)+R*cos(v*0.5)^2)*sin(2*v)
z(u,v) = r*sin(u)+R*sin(v)

Change r to 0.5: the tube gets thinner.

Object > Animate a variable…: the variable, its value from, to, and the number of frames. The animation plays in the window; a click or a key stops it, and the document keeps the value of the frame shown. Export asks for a name and also writes each frame as a TGA image, numbered from 000 (ANIM000.TGA, ANIM001.TGA…), to be assembled into a movie with other software.

Animation ideas:

DocumentVariablefrom → to
graph a*(x*x-y*y)a−1 → 1: the saddle turns over
isosurface x^2+y^2-z^2-aa−0.5 → 0.5: from two sheets to one
section 0, 1, 0, h on an isosurfaceh−1.6 → 1.6: the plane crosses the object
polar cos(k*t)k1 → 7: the petals appear
parametric cos(t), sin(t), p*tp0 → 0.5: the circle stretches into a helix

9. Saving, exporting, exchanging

The document

A document (.ARG) is a small text file: it holds the type, the formulas, the domain and the render settings. It can be read and edited with a text editor; its line starts with view, followed by the type:

view graph --solid --color orange "x*x-y*y" -2 2 40 -2 2 40 400 300

Exports

The clipboard

Edit > Copy (Ctrl+C) writes the image into the system clipboard folder (CLIPBRD) in two forms: SCRAP.TGA (true color) and SCRAP.IMG (256 colors, GEM format). Another program can then paste it.

Opening from another program

If the current document has been modified, the program first asks whether to save it.

10. The command line

Full version (MATH3D.PRG, MATH3D60.PRG on a 68060 and MATH3DCF.PRG on the FireBee); under Linux, the math3d program.

Without parameters, MATH3D.PRG is the GEM application described so far. With parameters, it computes an image without a window and writes it to a file: useful to make a series of images, an animation, or a large rendering. Start it from a shell (under MiNT or MagiC), or from a desktop that lets you pass parameters to a program.

The light version (MATH3DL.PRG) has no command line: it only accepts view … (open a document, see below).

The form of a command

MATH3D.PRG <type> [options] <formulas> <domain> <output> [w h]

The program answers Ecrit: <file> (<width>x<height>) ("written"), or an Erreur: … message ("error") that says what is wrong; these messages are in French. MATH3D.PRG --help gives the complete list of types and options.

The types

TypeParameters after the options
explicity(x) z(x) · x min max n
paramx(t) y(t) z(t) · t min max n
polarr(t) · t min max n · z plane
cylindricalr(t) z(t) · t min max n
spcurver(t) theta(t) phi(t) · t min max n
rvcurver(u) · u min max n · v angle (option --axis x or z)
surfacex(u,v) y(u,v) z(u,v) · u min max n · v min max n
sphericalr(theta,phi) · theta min max n · phi min max n
revolver(u) · u min max n · v min max n (option --axis x or z)
graphz(x,y) · x min max n · y min max n
implicit2df(x,y) · x min max n · y min max n · z plane
implicit3d sliceaxis (x, y or z) value · f(x,y,z) · two lines min max n
implicit3df(x,y,z) g(x,y,z) · x, y, z min max n
implicit3d isof(x,y,z) · x, y, z min max n
odedx/dt dy/dt dz/dt · t min max n · x0 y0 z0
phasedx/dt dy/dt · x min max n · y min max n · t min max n
complexRe w Im w · x min max n · y min max n
conformalRe w Im w · x min max n · y min max n
fieldFx Fy Fz · x, y, z min max n
stlSTL file

For implicit3d iso, the word iso comes before the options.

Examples

The saddle, solid orange faces, 640 × 480:

MATH3D.PRG graph --solid --no-wire --color orange "x*x-y*y"
    -2 2 40 -2 2 40 SADDLE.TGA 640 480

(a single line; it is broken here to fit the page)

The trefoil knot as a tube, colored by its torsion:

MATH3D.PRG param --tube --color-curvature torsion "sin(t)+2*sin(2*t)"
    "cos(t)-2*cos(2*t)" "-sin(3*t)" 0 6.283185 400 TREFOIL.TGA

The Lorenz attractor, yellow on a midnight blue background:

MATH3D.PRG ode --color yellow --bg 16,16,28 "10*(y-x)" "x*(28-z)-y"
    "x*y-8/3*z" 0 40 4000 1 1 1 LORENZ.TGA

A sphere as an isosurface, with highlights, and its OBJ mesh:

MATH3D.PRG implicit3d iso --solid --no-wire --specular --mesh-output
    SPHERE.OBJ "x^2+y^2+z^2-1" -1.5 1.5 24 -1.5 1.5 24 -1.5 1.5 24
    SPHERE.TGA

The main options

Camera angles are in radians here (the boxes of the application use degrees).

OptionEffect
--solid, --no-wiresolid faces; without the wireframe
--color <c>, --bg <c>, --wire-color <c>colors of the object, background, wireframe: orange, 200,170,110 or #C8AA6E (English names only)
--yaw <a>, --pitch <a>, --fov <degrees>camera: yaw, pitch (defaults 0.6 and 0.5), field of view (45)
--aa <n>antialiasing, from 1 to 4
--light <x,y,z>, --ambient <a>light direction, ambient light
--specularhighlights (--specular-strength, --specular-power)
--smooth-shading, --analytic-normalssmooth shading; normals computed from the formulas
--fog, --height-fogfog by distance, by altitude (--fog-density, --fog-color, --fog-height…)
--ground-shadowshadow cast behind the object
--line-width <n>, --tubeline width; curves as tubes (--tube-radius, --tube-sides)
--axes, --grid, --title <text>axes, ground grid, title in the image
--color-depth, --color-far <c>fade with depth
--color-curvature <k>color by curvature: gauss, mean (surfaces), curvature, torsion (curves)
--contours <n>, --contour-color <c>contour lines
--critical-pointsminima, maxima, saddles
--geodesics <n>geodesics (--geodesic-from a,b, --geodesic-length L)
--frenet <k>Frenet frames
--section <a,b,c,d>section: keeps a·x + b·y + c·z ≤ d
--iso-levels <c1,c2,…>several isosurfaces (2 to 8)
--field-lines, --arrow-scale <k>vector field: field lines, arrow length
--modulus-cap <c>cap of the modulus (complex functions, conformal maps)
--var <name=value>a formula variable (repeatable)
--mesh-output <f>also writes the OBJ mesh
--vrml-output <f>, --pov-output <f>also writes the VRML or POV-Ray scene
--depth-output <f>also writes the depth map (grey levels)
--pal8, --orient-pal256-color image; palette by face orientation

Animations

--frames <n> computes n frames. What varies:

The output name must contain %d, replaced by the frame number (%03d: on three digits). For example, the saddle turning over in 24 frames, SAD000.TGA to SAD023.TGA:

MATH3D.PRG graph --solid --no-wire --var a=-1 --var-end a=1 --frames 24
    "a*(x*x-y*y)" -2 2 32 -2 2 32 SAD%03d.TGA 320 240

Argument files

@FILE replaces this word by the content of the file: one or more words per line, # for a comment, quotes around a formula that contains spaces, and other @ inside. It can hold a whole command or only common settings:

MATH3D.PRG graph @STUDIO.OPT "x*x-y*y" -2 2 40 -2 2 40 SADDLE.TGA

The documents of the application are argument files: their line starts with view, followed by the type, the options, the formulas, the domain and the size of the window. MATH3D.PRG @SADDLE.ARG (or just the document name) opens the application with this document. To get an image from it without a window, copy the line without the word view, and add the output name before the size:

the document:  view graph --solid "x*x-y*y" -2 2 40 -2 2 40 400 300
the command:   MATH3D.PRG graph --solid "x*x-y*y" -2 2 40 -2 2 40
                   SADDLE.TGA 400 300

Scenes

A scene describes the same rendering as key: value lines, easier to read than a long command:

mode: graph
solid: true
no-wire: true
render.color: orange
render.contours: 12
expr: exp(-x*x-y*y)*cos(2*x)
x_range: -2.5, 2.5, 60
y_range: -2.5, 2.5, 60
output: CONTOURS.TGA
size: 640, 480

It is run with MATH3D.PRG scene CONTOURS.SCN. Each option becomes render.<option without --> (render.bg, render.yaw, render.fog-density…), variables var: a=1, an animation render.frames and var-end.

Several objects in one image

The multi type overlays curves, surfaces and implicit objects, with a common camera; each object starts with its word (--curve, --surface, --iso, --implicit2d, --slice, --intersect) and may have its own color:

MATH3D.PRG multi --curve param --color red "cos(t)" "sin(t)" "t/4"
    0 12.566371 300 --iso --solid --color cyan "x^2+y^2+z^2-0.25"
    -1 1 24 -1 1 24 -1 1 24 MULTI.TGA

11. Example documents

Open them with File > Open…; they are documents like yours, to be changed freely. They come twice:

Their names are French. ★: full version only.

EXAMPLES\EX_LONG\What it shows
BRETZEL.ARGview_bretzel.argsparametric surface (a pretzel), orientation palette
BRETZVAR.ARGview_bretzel_variables.args★ the same with the variables R and r
SELLE.ARGview_selle.argsthe saddle, parametric surface
GRAPHE.ARGview_graphe.argsgraph with if: a half-sphere
NIVEAUX.ARGview_niveaux.args★ graph and contour lines
PTSCRIT.ARGview_points_critiques.args★ minima, maxima and saddles of a graph
FOURIER.ARGview_fourier.args★ graph with sum: product of two Fourier series
TORECOUR.ARGview_tore_courbure.args★ torus colored by its Gaussian curvature
SPHECOUR.ARGview_spherique_courbure.args★ spherical surface colored by its mean curvature
GEODESIQ.ARGview_geodesiques.args★ geodesics on a torus
VILLARCE.ARGview_coupe_villarceau.args★ torus cut by a bitangent plane
COUPEANI.ARGview_coupe_animee.args★ three nested spheres, section animatable with h
HYPERBOL.ARGview_hyperboloides.args★ three isosurfaces: hyperboloids and cone
FRENET.ARGview_frenet.args★ knot as a tube and its Frenet frames
NOEUDTOR.ARGview_noeud_torsion.args★ trefoil knot colored by its torsion
LORENZ.ARGview_lorenz.args★ Lorenz attractor (differential equation)
PENDULE.ARGview_pendule.args★ phase portrait of the pendulum
CHAMP.ARGview_champ.args★ Lorenz vector field
LIGNCHAM.ARGview_lignes_champ.args★ field lines of the pendulum
COMPLEXE.ARGview_complexe.args★ complex function (z² − 1)/(z² + 1)
CONFORME.ARGview_conforme.args★ conformal map w = exp z

The COURBES folder ("curves") holds twenty-one curves, in all coordinate systems, which also open in the light version:

EXAMPLES\COURBES\EX_LONG\courbes\Curve
C01SINUS.ARGc01sinus.argsdamped sine (explicit)
C02VAGUE.ARGc02vague.argsspace curve (explicit)
C03CLOCH.ARGc03cloch.argsGaussian bell (explicit)
C04HELIC.ARGc04helic.argshelix
C05TREFL.ARGc05trefl.argstrefoil knot
C06VIVIA.ARGc06vivia.argsViviani's curve
C07LISSA.ARGc07lissa.args3D Lissajous
C08NTORI.ARGc08ntori.argstorus knot (2, 5)
C09RESST.ARGc09resst.argsspring wound on a torus
C10TENNI.ARGc10tenni.argstennis ball seam
C11ROSE.ARGc11rose.argsfive-petal rose (polar)
C12CARDI.ARGc12cardi.argscardioid (polar)
C13SPLOG.ARGc13splog.argslogarithmic spiral (polar)
C14LEMNI.ARGc14lemni.argslemniscate of Bernoulli (polar)
C15PAPIL.ARGc15papil.argsFay's butterfly (polar)
C16CONE.ARGc16cone.argsconical spiral (cylindrical)
C17COURO.ARGc17couro.argswavy crown (cylindrical)
C18RESSV.ARGc18ressv.argsspring with growing pitch (cylindrical)
C19LOXOD.ARGc19loxod.argsloxodrome (spherical)
C20CLELI.ARGc20cleli.argsclelia (spherical)
C21VASE.ARGc21vase.argsvase profile (meridian)

12. Tips and frequently asked questions

The object does not appear, or the window stays empty. Check the domain: for an implicit object, it must contain the object (the sphere of radius 1 needs at least −1 to 1; leave a margin, −1.5 to 1.5). A formula that only gives impossible values (square root of a negative number everywhere) draws nothing.

The formula is refused. The message names the faulty formula (the details of formula errors are in French). Common causes: 2x instead of 2*x, a missing parenthesis, a comma instead of a point (0,5 instead of 0.5), a variable that is not the one of the type (t in a surface in u, v).

The object looks angular. Increase the number of points of the domain (Object > Domain and mesh…) or use Mesh + in the context menu. On a 68000, stay reasonable: the computing time grows like the number of points (curves), its square (surfaces), its cube for an isosurface.

Dragging is slow. Check Window > Light preview. On fast machines, Solid preview on the contrary shows the solid object while turning.

−x² gives a bowl instead of a dome. See the pitfalls of section 4: write -(x^2) or -x*x.

An option is greyed out. In the light version, what needs too much computing without a coprocessor is (fog, highlights, smooth shading); some menus only apply to some types (the section to surfaces and meshes, Frenet frames to curves…).

The light version refuses a document. Its type exists only in the full version (differential equation, complex function, STL…), or it uses sum().

Colors are poor in 16 colors. Try the other dither (Window > Error diffusion dither or Ordered dither); the orientation palette (context menu) often gives the best relief with few colors.