Overview
3D Functions is a program that allows creating parametric 3D-objects. It has been written entirely in assembler. It has perspectivical interface and simple C-like syntax. It is not really mathematical application, but it can be used for quick defining objects and displaying them on-the-fly in a very pictorial manner.
Chris Dragan 

Release notes
Version of this help file and it's owning program is 4.0. This is not a final version, but fully functional. Following bugs are known and will be removed in next release:
1	Inability of use built-in expressions instead of brace expressions, eg.: if (a) if (b) c;
2	Break instructions leave if expression,
3	Not present option of texture, that is a bitmap image that covers the chart,
4	Wrong positioning the formula window after compilation error. 

Tabs
3D Functions' main window has two tabs - Chart and Formula.
The Formula tab is for defining function formula, that is a text, which after switching to the second tab is compiled into internal code and then executed in calculations.
In the second tab one can rotate the chart using mouse - holding left or right button and dragging cursor. With right button the angle changes by one unit, and with left button by two units, where a unit equals 360 degrees/512. 

Files
File toolbuttons allows opening, saving and clearing current function. Saved function have not got any special format. It is simply a text file. 

Standard functions
Pushing one of three standard function toolbuttons causes switching current tab and setting a standard function procedure active. These functions include Bridge, Sine3D, and Arcus Tangent. The definitions of these are:
z=18/(x^2+9) + 4/((y-3)^2+1) + 4/((y+3)^2+1)
z=2*sin(sqrt(x*x+y*y))
z=3*(atan(x)+atan(y)) 

Animation
One can animate the chart in two ways:
1	Using the time scrollbar, which appears down the chart window, when value tmax is greater than 0,
2	Pushing Animate toolbutton.
Note that function has to support "t" variable to encouner any chart changes, not only rotation. 

Chart properties
This tab lets the user to set up colors of background, grid and wire. This can be also used to switch off the grid by selecting it's color the same as the color of background. 

Formula properties
This tab lets the user to select font for formula tab. And also it contains a checkbox which allows switching the Friendly Syntax parameter. When this is on, while calculation 3D Functions treat some expressions more loose. These expressions are:
1	log(), ln(), lg(), sqrt() - are treated like log(abs())
2	a/b, a%b, a/=b, a%=b - allow division by 0 (a/0 == 1)
Additionaly, it allows the b argument in expressions a%b, a%=b to be non-integer. 

Defaults properties
This tab allows to set default values. Note that some numbers behave weird because of different stage of rounding. 

Buffers properties
This tab allows to set up buffer sizes. Three first are used for compilation and the next three for execution. If a buffer is too small the program reports an error while compilation or execution. Then the user has to enlarge too tight buffer. Correct buffer sizes are from 1024 to 65536. 

Animation properties
This tab allows to change speed of angle changes and timer frequency. This parameters affect only speed of animation while animate toolbutton is checked. 

About properties
In this tab one can check the amount of extra memory allocated by 3D Functions for bitmap and function buffers. It also shows number of vertices currently being displayed. 

Expressions
There are four types of expressions:
1	Value assignment: value = number;,
2	Common expression - set of operators and operands, where operator can be in form: function (expression),
3	Complexed expression: { expr1; expr2; ... exprn } ;,
4	Built-in expression - one of the following: if..else, while, do..while, for.
Each expression ends with semicolon. Only the last expression is not forced to end with it.
In every place of a function definition one can insert a comment, which begins with hash sign (#) and ends with the end of line. 

Error messages
This is the list of error messages generated in stages of compilation and calculation. To get solution on an error click it's name.
Compilation errors
0	Unknown sign
	#Unsupported sign has been used. You need to rebuild the whole expression. 
1	Unknown operator/operand
	#Incorrect word has been used. To define a variable type word containing characters 'a'..'z', 'A'..'Z', '0'..'9'. 
2	Invalid number format
	#Numbers can only contain nine different digits and a dot sign. Before and after dot must not be no more than ten digits. 
3	Too many brackets
	#One single common expression can contain no more than 20 opening brackets with no closing brackets between. Note that negation sign works like opening bracket, but does not have a closing bracket. 
4	Data buffer overflow
	#One of buffers has been exceeded. You have to increase size of this buffer in the Buffers properties. 
5	Too many breaks
6	Too many block instructions
	#One of the operators is needed. 
7	Conversion buffer overflow
8	Executable buffer overflow
9	Operand expected
10	Operator expected
	#An operand is needed - variable, value, constant, number, function or expression in brackets. 
11	Writable variable expected
	#A writable operand is expected - it cannot be a constant, number or function. 
12	Expression expected
13	Number expected
14	'(' expected
15	')' expected
16	';' expected
17	'=' expected
	#One of assignment operators is expected, unless it is value assignment expression which demands the first assignment operator. 
18	'} ' expected
19	',' expected
	#The for expression syntax demands a comma. 
20	'while' expected
	#The do..while expression syntax demands "while" reserved word. 
21	Wrong break placement
	#"break" reserved word can be used only inside while, do..whileor for expression. 
22	Wrong main placement
	#"main" reserved word can be used only ouside of any expressions. 
23	Duplicate main label
	#There can be used only one "main" reserved word. 

Execution errors
24	Negative value
	#During log(), lg(), ln() or sqrt() function execution there appeared negative value. Check Friendly Syntax checkbox in Formula properties to enable abs() subfunction (log(a)==log(abs(a)). 
25	Division by zero
	#During division there appeared zero. To enable division by zero (a/0 == 1) check Friendly Syntax checkbox in Formula properties. 
26	Non-integer value
	#During modulo division there appeared a non-integer number. Check Friendly Syntax checkbox in Formula properties to use any numbers next time. 
27	Stack overflow 

Rule operators
operator	privilege	action
+	4	addition
-	4	substraction
*	5	multiplication
/	5	division
%	5	modulo division (remainder)
^	6	power raising
<<	5	shift left
>>	5	shift right
 
Boolean operators
An expression has boolean value true if it is non-zero, otherwise it's boolean value is false. Operators "&&" and "||" work on boolean values. Other - relation operators - work on normal numbers, but return boolean values.
operator	privilege	action
||	2	logical sum
&&	2	logical product
>	3	greater
<	3	lower
==	3	equal
>=	3	greater or equal
<=	3	lower or equal
!=	3	not equal
 
Assignment operators
All assignment operators have privilege level of 1.
operator	action
=	normal assignment
+=	addition
-=	substraction
*=	multiplication
/=	division
%=	modulo division
^=	power raising
<<=	shift left
>>=	shift right
 
Values
Values are built-in write-only variables. Values can be updated in so-called value assignment expression. In fact this type of expression is not really executable, but the Value is assigned once, at compilation time.value	description
xmid	chart x-shift
ymid	chart y-shift
zmid	chart z-shift
scale	chart viewpoint size
pmin	first value of "p"
pmax	last value of "p"
pgran	granularity of "p"
qmin	first value of "q"
qmax	last value of "q"
qgran	granularity of "q"
tmax	maximum value of "t"

Notes
"xmid", "ymid" and "zmid" together make a point of the chart that will be displayed in the middle of the chart window.
"pgran" and "qgran" are integer values and vary between 2 and 200.
"tmax" is an integer value and can be very large...
All of these values can be set to default in Defaults properties 

Numbers
These operands are read-only. A number consists of an integer part, a dot and a fraction. Last two are optional. Integer part and fraction can be no more than ten digits long.

Constants
Like numbers, constants are read-only, but in oposite to numbers constants cannot be defined, they are built-in.constant	description
p, q	These constants define the whole chart. One uses them to update 'x', 'y', and 'z' - predefined variables. 'p' and 'q' define subsequent meshes of the "rectangular" chart net.
t	This constant defines time scroll position. If the time changes, the whole chart is recalculated with new 't' value.
pi	Proportion of perimeter to diameter.
e	Euler's constant.
l2t	log2(10)
l2e	log2(e)
lg2	log10(2)
ln2	loge(2)
 
Variables
Variables are readable and writable operands. Defining a variable is very simple - it is defined in it's first usage place. It must be assigned then. 

Predefined variables
There are three predefined variables: 'x', 'y' and 'z'. They define a chart net mesh coordinates. To place such point one simply has to assign them, basing on 'p' and 'q' constants, which define x-order (p) and y-order (q) mesh position of the chart rectangular net. Also one can base on 't' constant, which define time stamp. But first one has to assign 'tmax' value (in function formula or in defaults properties).
The default mesh position is (p,q,0), that is x=p, y=q and z=0. Basing on this, one can define only z value of x and y, creating real function of two variables "z=f(x,y)". 

Functions
Function is a kind of operand. It consists of a name and a common expression in brackets.function	description
-a	negation
(a)	bracket - subexpression
abs(a)	absolute value
sin(a)	sine
cos(a)	cosine
atan(a)	arcus tangent
log(a)	logarithm of base 2
ln(a)	natural logarithm
lg(a)	decimal logarithm
sqrt(a)	square root
frac(a)	fraction
exp(a)	e^a
 
#S indicates a single common expression. 
#E indicates a single common expression, a set of common expressions in braces or built-in instruction. 
#M indicates a set of common expressions separated by semicolons. 

if..else syntax
if..else instruction executes first part (before else word) when boolean value of S is true (non-zero). Otherwise it executes the second part (if it exists).
Example usage of if..else instruction:
if (S) E;
or:
if (S) E;else E; 

while syntax
while instruction checks the case expression (S) and when it is true, it executes the E part, and then returns to the check part. This instruction executes until the case is false.
Example usage of while instruction:
while (S) E; 

do..while syntax
do..while instruction first executes the E part, and then checks the case expression S. If it is true, the instruction starts once again, until it is false.
Example usage of do..while instruction:
do E; while (S);
Note that the first semicolon (after E) is not valid when braces are used. 

for syntax
for instruction at the beginning executes first M expression. Then it executes the loop, which is as follows. First is executed the E expression. Then, if the S case is true, second M expression is executed and the loop continues, otherwise it stops.
Example usage of for instruction:
for (M,S,M) E;
Note that the commas before and after S are very important. 

return reserved word
This reserved word can be used anywhere outside common expressions. It causes the whole calculation for current 'p', 'q', and 't' to stop. 

break reserved word
This reserved word can be used only inside while, do..while and for instructions. It causes them to stop immediately. 

main reserved word
This reserved word can be used only once, outside any of built-in instructions. It separates pre-calculations section from the real calculations. When 't' parameter changes, or when the chart is calculated first time, the pre-calculation code is executed first, and then the calculation part starts for all subsequent 'p' and 'q' values. This can speed up some calculations for animated charts.
When no main word is found, all the code is used in calculations, and no pre-calculations part exists. 

