In order to be "clean" the parameters could still be defined in the [OPTIONS] sections while adding the in-procedure name (and other stuff):
Hi again, I think I have found a very good compromise of all the options discussed, you are most welcome to have an early look at the binary (I will send you a link).
I have extended the file-format to support also named constants. One may use named constants in ASM-formulas as well, even when those names will never be refered from code later.
Those named constants are supported by the JIT-editor, and now, there is a preprocessor which fills in the the nasty code to read those values.
What makes this solution sexy is, that there was nearly no change necessary to the MB3D-core.
Example of the final (preprocessed) code (again, the Benesi-tree
):
procedure BenesiPineTree(var x, y, z, w: Double; PIteration3D: TPIteration3D);
var
// begin preprocessor
sqrt_1_2: Double;
sqrt_1_3: Double;
sqrt_2_3: Double;
Offset: Double;
Scale: Double;
// end preprocessor
temp_x, temp_y, temp_z, temp: Double;
new_x, new_y, new_z: Double;
x_temp, y_temp, z_temp: Double;
begin
// begin preprocessor
sqrt_1_2 := PDouble(Integer(PIteration3D^.PVar) + 0)^;
sqrt_1_3 := PDouble(Integer(PIteration3D^.PVar) + 8)^;
sqrt_2_3 := PDouble(Integer(PIteration3D^.PVar) + 16)^;
Offset := PDouble(Integer(PIteration3D^.PVar) - 16)^;
Scale := PDouble(Integer(PIteration3D^.PVar) - 24)^;
// end preprocessor
temp_x := x*sqrt_2_3-z*sqrt_1_3;
new_z := x*sqrt_1_3 + z*sqrt_2_3;
new_x := (temp_x-y)*sqrt_1_2;
new_y := (temp_x+y)*sqrt_1_2;
new_x := abs(new_x);
new_y := abs(new_y);
new_z := abs(new_z);
temp_x := (new_x+new_y)*sqrt_1_2;
new_y := (-new_x+new_y)*sqrt_1_2;
new_x := temp_x*sqrt_2_3+new_z*sqrt_1_3;
new_z := -temp_x*sqrt_1_3+new_z*sqrt_2_3;
x:=scale*new_x-offset; //scale =2 offset=2
y:=scale*new_y;
z:=scale*new_z;
x_temp:=x*x;
y_temp:=y*y;
z_temp:=z*z;
temp:=(x+x)/sqrt(y_temp+z_temp);
new_x:= x_temp - y_temp - z_temp;
new_z:=temp*(y_temp-z_temp); //y and z variables are switched to add symmetry
new_y:=temp*2.0*y*z;
x := new_x + PIteration3D^.J1;
y := new_y;
z := new_z;
end;
The *.m3f-file also looks sexy, there are no redundancies in code/definitions:
[OPTIONS]
.DEScale = 1
.SIPow = 2
.Version = 9
.Double Offset = 2
.Double Scale = 2
[CONSTANTS]
.Double sqrt_1_2 = 0.707106781186548
.Double sqrt_1_3 = 0.577350269189626
.Double sqrt_2_3 = 0.816496580927726
[SOURCE]
procedure BenesiPineTree(var x, y, z, w: Double; PIteration3D: TPIteration3D);
var
temp_x, temp_y, temp_z, temp: Double;
new_x, new_y, new_z: Double;
x_temp, y_temp, z_temp: Double;
begin
temp_x := x*sqrt_2_3-z*sqrt_1_3;
new_z := x*sqrt_1_3 + z*sqrt_2_3;
new_x := (temp_x-y)*sqrt_1_2;
new_y := (temp_x+y)*sqrt_1_2;
new_x := abs(new_x);
new_y := abs(new_y);
new_z := abs(new_z);
temp_x := (new_x+new_y)*sqrt_1_2;
new_y := (-new_x+new_y)*sqrt_1_2;
new_x := temp_x*sqrt_2_3+new_z*sqrt_1_3;
new_z := -temp_x*sqrt_1_3+new_z*sqrt_2_3;
x:=scale*new_x-offset; //scale =2 offset=2
y:=scale*new_y;
z:=scale*new_z;
x_temp:=x*x;
y_temp:=y*y;
z_temp:=z*z;
temp:=(x+x)/sqrt(y_temp+z_temp);
new_x:= x_temp - y_temp - z_temp;
new_z:=temp*(y_temp-z_temp); //y and z variables are switched to add symmetry
new_y:=temp*2.0*y*z;
x := new_x + PIteration3D^.J1;
y := new_y;
z := new_z;
end;
[END]
Description: