next up previous contents index
Next: Project Amandus Up: Project Explicit Previous: User-Defined Domain Transformations

Replacing the "compute-explicit" Method

 

You can replace this method with your own "compute-explicit" method if you want to compute something special that cannot be described with the input file, for example if you have to compute some parameter for the surface numerically, if you need some function not supported by the function compiler (see 10.2.8 for a list of the supported functions) or if you want to use the same parameter for several surfaces.

The first argument of the "compute-explicit" method is the Geom2d instance the data is stored in, the second is the index of the point that should be computed and the third one are the coordinates of the domain point. As an example we use the stereographic projection of helicoids in the three-sphere:

EXPLICIT *explicit_compute_explicit(GEOM2D *geom, int num, COMPLEX z)
{
  EXPLICIT *self;
  double arg[10], x, y;
  int i;

  self = (EXPLICIT *)START_METHOD(G_INSTANCE);
  ASSURE(self, "", END_METHOD(NULL));

  /* copy the double parameter to the arg array (needed for fn_eval below) */
  x = arg[0] = z.x;
  y = arg[1] = z.y;
  for(i = 0; i < self->time_parm->num_double_parm; i++)
    arg[i + 2] = self->time_parm->double_parm[i];

  if(!strcmp(self->name, "s3helicoid")) {
    extern int proj_stereo(VEC3, VEC4);
    double alpha = self->time_parm->double_parm[0];
    VEC4 x4;
    VEC3 x3;

    x4[1] = cos(y) * cos(x);
    x4[2] = cos(y) * sin(x);
    x4[3] = sin(y) * cos(alpha * x);
    x4[0] = sin(y) * sin(alpha * x);

    proj_stereo(x3, x4);

    geom->x[num] = x3[0];
    geom->y[num] = x3[1];
    geom->z[num] = x3[2];
  } else {
    /* the default case */
    geom->x[num] = fn_eval(self->coord_f.x, arg);
    geom->y[num] = fn_eval(self->coord_f.y, arg);
    geom->z[num] = fn_eval(self->coord_f.z, arg);
  }

  END_METHOD(self);
}

The part upto the if and from the else on always has to be present to handle the default case, i.e. to evaluate the formulas read from other description files. Again the name of the Explicit instance is used to determine which surface should be computed.

The description file s3helicoid.ex only contains the parameter and domain data, the formulas have to be present but they are not used by "compute-explicit":

# S^3 Helicoid

GEOMETRY;        # task
0; 1;            # frame / number of frames

0; 1;            # number of int / double parameter
0.0;             # double parameter a

1; 1;            # part number / max number of parts

# part 1
0; 20; 20; 0; 0; # flag / number of u- and v-lines / u- and v-sub
0; 0; pi; pi;    # umin / vmin / umax / vmax

# dummy formulas
0; 0; 0;

Of course we can avoid writing a new "compute-explicit" method for this example by coding the stereographic projection into the explicit formulas in the description file:

cos(y) * cos(x) / (1 + sin(y) * sin(a * x));
cos(y) * sin(x) / (1 + sin(y) * sin(a * x));
sin(y) * cos(a * x) / (1 + sin(y) * sin(a * x));


SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.