User Tools

Site Tools


hyperfun:hf_objects

HyperFun: Objects

A geometric object is supposed to have semantically significant geometric sense. The general form of the object's structure is:

<objectName> '(' 'x' '[' <size> ']' ',' 'a' '[' <size> ']' ',' 's' '[' <size> ']'')'
'{'
[<array declarations>]
[<statements>]
<objectName> '=' <functional expression> ';'
'}'

Note that there should be declarations of arrays of coordinate variables 'x' and numerical parameters 'a' in the head of the object's definition. Even if there are no parameters from outside, the declaration 'a[1]' must be present. However, the declaration of attribute array 's' can be omitted if there is no references to the array with name 's' in the program but even in such a case 's' cannot be used as a identifier in the object definition as 's' remains to be the reserved name.

The simplest example of an object in HyperFun without using attributes:

Sphere(x[3], a[1]) 
{
-- the definition of the sphere with radius 10 and a center in the origin
Sphere = 100 - x[1]^2 - x[2]^2 - x[3]^2;
}

The simple example of an object in HyperFun with attributes:

ColorSphere(x[3], a[4], s[3]) {
-- 's' is input/output parameter
array center[3], rgb[3];
center[1] = a[1]; center[2] = a[2]; center[3] = a[3];
radius = a[4];
rgb[1] = s[1]; rgb[2] = s[2]; rgb[3] = s[3];
s   = [0, 0, 0];
sphere = hfSphere(x, center, radius);
 
-- association the left hemisphere's interior and surface with the red color
s[1] = 1; s[2] = 0; s[3] = 0;
        if (x[1]>=0 and sphere >= 0) then
-- association the right hemisphere's interior and surface with the color received as input
        s[1] = rgb[1]; s[2] = rgb[2]; s[3] = rgb[3];
        endif;
 
ColorSphere = sphere;
}
hyperfun/hf_objects.txt · Last modified: 2023/12/19 03:07 by 127.0.0.1