From Gerris

Revision as of 03:31, 14 December 2007; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

A GfsSurface is an oriented surface (in 3D) or an oriented curve (in 2D).

The surface can be defined implicitly using for example:

(x*x + y*y + z*z - 0.1*0.1)

which defines the surface as the set of points of coordinates (x,y,z) such that x*x + y*y + z*z - 0.1*0.1 = 0 (i.e. a sphere of radius 0.1 centered on the origin).

The sign of the implicit function defines the surface orientation. The function should be "smooth enough" (i.e. differentiable). For example the result from this:

Define MYDROPLET (x*x + y*y + z*z > 0.1*0.1 ? 1. : -1.)

would look quite different from the definition above.

Surfaces can also be defined explicitly using GTS files. For example:


When using GTS surfaces in two dimensions, the oriented curve is defined as the intersection of the GTS surface with the z = 0 plane.

The surface definition can be followed by an optional parameter block with the following syntax:

  tx = 0.1 ty = -0.2 tz = 0.4
  sx = 2.  sy = 1.5  sz = -1
  rx = -45 ry = -5.5 rz = 25
  scale = 3.
  flip = 1
  twod = 1

where (tx,ty,tz) is a translation vector, (sx,sy,sz) is a scaling vector and (rx,ry,rz) is a rotation vector (angles in degrees around each principal direction). Note that the translation is always performed after rotation and scaling.

If the scale parameter is specified, uniform scaling is applied along the three axis.

The flip parameter can be used to flip the surface orientation.

If set to one the twod parameter "flattens" the surface on the z = 0 plane (this is used in 3D by the GfsRefineSurface object).

Several simple implicit surfaces are pre-defined:

an ellipse (an elliptical prism in 3D) centered on (x,y) and with semimajor axis a and semiminor axis b.
a sphere centered on (x,y,z) and of radius r.
a cube centered on (x,y,z) and of size h.

Boolean operations

Boolean operations between implicit surfaces can be used to create more complex objects (a technique also know as Constructive Solid Geometry). Given two implicit surfaces A and B with associated implicit functions fA and fB, the standard boolean set operations can be constructed as:

A ^ B = { MIN (fA(x,y,z), fB(x,y,z)) }
A U B = { MAX (fA(x,y,z), fB(x,y,z)) }
A - B = { MIN (fA(x,y,z), - fB(x,y,z)) }

For example the following will replicate the example of the wikipedia CSG page

Solid ({
  double s = sphere (0, 0, 0, 0.25);
  double c = cube (0,0,0,0.38);
  double sUc = MAX (s, c);
  double cylinder1 = x*x + y*y - 0.12*0.12;
  double cylinder2 = z*z + y*y - 0.12*0.12;
  double cylinder3 = x*x + z*z - 0.12*0.12;
  double cylinderI = MIN (MIN (cylinder1, cylinder2), cylinder3);

  return MAX (sUc, - cylinderI);
Personal tools