PLaSM Approach to Geometry

PLaSM, the Programming LAnguage for Symbolic Modeling, is a functional "design language" designed in recent years by the CAD Group at the University of Rome "La Sapienza" (Italy) and currently developed by the Geometric Computing Group at the University of Roma Tre.

PLaSM features

Programming approach to "generative" modeling
Geometrical objects generated by language expressions
Algebraic calculus over embedded polyhedra
Dim-independent approach to geometry repr and algorithms
Extended variational geometry (classes of objects with varying topology and shape)
Geometry-oriented extension of the functional language FL
Validity of geometry syntactically guaranteed
Domain broader than in solid modelers (points, wire-frames, surfaces, solids, etc.)

PLaSM is a geometry-oriented extension of a subset of FL:

it is a functional "design language"
can evaluate expressions whose value is a polyhedral complex
can produce higher-level functions in the FL style
no free nesting of scopes and environments is allowed
no pattern matching is provided
allows identifiers for any language object

The syntax of PLaSM is very similar to the one of FL. The differences only concern the meaning of few characters and the use of multiple lists of formal parameters of functions. Two new combining forms AC (apply-in-composition) and AS (apply-in-sequence) are introduced, in order to use a function with a number of actual parameters greater than the number used in the function definition.


SEL is a primitive operator with a specification parameter i, such that when applied to a sequence the i-th sequence element is returned:

SEL:2:<13, 4.5, ID> = 4.5

By using the combining form AC and AS, the SEL operator can work in two different ways:

AC:SEL:< 3,1 >:<< 1,3,8,7 >, 89, fun>= (SEL:3 ~ SEL:1):<< 1,3,8,7 >, 89, fun> = 8
AS:SEL:< 3,1 >:<< 1,3,8,7 >, 89, fun>= [SEL:3, SEL:1]:<< 1,3,8,7 >, 89, fun>= < fun, < 1,3,8,7 >>

PLaSM uses a case unsensitive alphabet;
Allows for partially specified (curried) functions.
Allows for overloading of operators:

3+2; 3*2
ops on numbers

(sin+cos):x; (sin*cos):x;
ops on functions

pol1+pol2; pol1*pol2;
ops on polyhedra

Predefined functions

Some non geometric predefinite functions and combinatorial forms follow

Type predicates
(IsInt, IsReal, IsSeq, IsFun, IsPol)

Comparison functions
GT, GE, LT, LE, EQ, ...

Logical functions and constants
AND, OR, NOT, TRUE, <>, ...

Combining Forms
AS, AC, ...

Mathematics functions

Sequence functions

Some more non-geometric operators:
repetitition operator allows for instancing n times any expression:
#:3:expr = < expr,expr,expr >

catenation of repeated sequences repeats and catenates sequences:
##:3:< a,b,c > = < a,b,c, a,b,c, a,b,c >

FROMTO operator generates integer sequences between two given extremes:
FromTo:<2,5> = 2..5 = <2,3,4,5>

INTSTO operator generates integer sequences with a given end:
INTSTO:5 = <1,2,3,4,5>

Function definition

Two kinds of functions are recognized in PLaSM:

global (or top-level) functions

Global functions may contain a definition of local functions between WHERE and END keywords. Global functions are allowed to contain formal parameters using a lambda-style. Formal parameters are specified together with a predicate wich is normally used to perform some type-checking at run-time.

local functions

The visibility of local functions is restricted to the scope of a global function.
Formal and actual parameters are given as follows:

Function definition:
DEF f (a::type1) = bodyF
DEF g (a1,...,an::type2) = bodyG
DEF h (a1::type1)(a2::type2) = bodyH
DEF l (a1::type1; a2::type2) = bodyL

Function instancing:
g:< x1, ... , xn >
l:< x1, x2 >

Geometric functions

Elementary shape contructors (geometric primitives)

Affine transformations
T, S, R, H, MAT, ...

Hierarchical Operator (Assemblies with local coordinates)

Skeletons of a complex
@0, @1, @2, @3, ...

Constructor of 1D polyhedra

Cartesian Product of complexes

Intersection of extrusions

Parametric mapping

Regularized Booleans Operators
+, &, -, \, XOR

Quick Positioning and scaling

For efficiency reasons, a special form for parameter specification has been implemented for some frequently used elementary geometric function. In particular, the functions MIN, MAX, SIZE, BOX and the affine transformation functions T, S, R, H can be specified both on a single value and on a sequence of values. E.g., T denotes translation, and T:3:2.5 means translation of 2.5 units on the third coordinate. Hence for a translation on more than one coordinate we can write, e.g., T:<1,3>:<2.5,6/1.5>.

Several equivalences hold for affine transformations. For instance:
T:<1,3>:<2.5,6/1.5> = (T:1:2.5 ~ T:3:(6/1.5))

Some notable geometric operators

The CUBOID primitive generates intervals of different intrinsic dimension:

CUBOID:5 = segment of length 5
CUBOID:<5,10> = rectangle of area 510
CUBOID:<5,10,5> = parallelepiped of volume 5105
CUBOID:<1,1,1,1> = hypercuboid of volume 1

The SIMPLEX primitive generates simplices of different intrinsic dimension:

SIMPLEX:5 = segment of length 5
SIMPLEX:<1,1> = standard triangle of area 1/2!
SIMPLEX:<1,a,1> = standard tetrahedron of volume a/3!
SIMPLEX:<1,a,b,1> = standard 4-simplex of volume ab/4!

The "Make Polyhedron" constructor MKPOL

generates polyhedral complexes of different dimension. It is the only basic geometry constructor in PLaSM. It is a mapping from triples of sequences to polyhedral complexes:

MKPOL:< verts, cells, pols >


verts is a sequence of points;
cells is a sequence of convex cells (given as indices of points);
pols is a sequence of polyhedra (given as indices of cells).

Any cell is defined as the convex hull of its vertices, any polyhedron is defined as the union set of its convex cells. This definition is quite general, and may include (complexes of) polylines, plane and space polygons, 3D polyhedra and higher dimensional geometric objects, both solid and embedded.

Some geometric examples

Example 1 gives the PLaSM code of a 2D example with three convex cells embedded in E3.

The Example 2 is slightly modified to give a similar object with a hole.

The "Hierarchical structure" constructor STRUCT is used to generate hierarchical assemblies of objects defined in local coordinates. It is applied to sequences of polyhedra, affine transformations and STRUCT invokations. This operator has a semantics very close to that of the structures defined in the ISO PHIGS graphics standard. At traversal time (at evaluation time, in our case) each occurrence of an object in a hierarchical network of structures is transformed from local coordinates to the coordinates of the root of the network.

A simple Example 3 is given, where a sequence of occurrences of the polyhedron generated in Example 2 is composed to give a linear assembly. An equivalent and more proper use of PLaSM is there shown, where the repetition operator ## is used and composed with the STRUCT operator.

Structures can be nested hierarchically

So, a sort of array assembly of geometric objects, shown in Example 4, is very easily generated as:

(STRUCT ~ ##:3):< (STRUCT ~ ##:5):< Mypol,T:1:10 >, T:3:10 >

Notice that PLaSM gives some (dimension-independent) affine operators, including

translation T:coords:parmtrs,
rotation R:coords:parmtrs,
and scaling S:coords:parmtrs,

where coords denotes the coordinates affected by the transformation, and parmtrs denotes its parameters. Affine transformations can be composed and applied to polyhedra. In such a case they are equivalent to the application of a STRUCT operator.

The "Parametric Mapping" constructor MAP

allows for simplicial mapping of polyhedral domains. The syntax is:


where vfun is a vector function (written using the FL selectors) and domain is a polyhedral complex. The semantics is very simple: MAP applies vfun to all vertices of a simplicial decomposition of the polyhedral cells of domain. Usually vfun is the CONS of a sequence of coordinate functions which are applied to the vertices of the simplicial decomposition to generate their images in target space Ed. Notice that the dimension d of such space will equate the number d of coordinate functions in the CONSed vfun.

A piecewise linear approximation with 32 segments of the graph of the sin function in the interval [0, 2pi] (where pi is 3.1415) is generated by the script of Example 5. Notice the mandatory use of the FL selectors, which are used to select the needed coordinates of vertices in the domain decomposition. Vertices are in fact represented as sequences of coordinates. A piecewise linear approximation of the circumference of unit radius is generated in the Example 6. Several interesting example of PLaSM script which make use of the MAP operator can be foun in ... .

The Boundary operator is a mapping:

@: Pd,n -> Pd-1,n

From the set Pd,n of polyhedra of dimension (d,n) to that of polyhedra of dimension (d-1,n). E.g., the boundary of a (3,3)-polyhedron is a (2,3)-polyhedron (a set of polygons embeded in 3D space). The boundary of a (2,2)-polyhedron is a (1,2)-polyhedron, i.e. a set of line segments in 2D. At current time it is not yet implemented in PLaSM. It should be implemented into the next release of the language, using an algorithmic approach based on boundary-BSP trees [BC97].

The Skeleton operators

We call r-skeleton the mapping @r: Pd,n -> Pr,n, 0 < r < d, such that @r:P is the r-skeleton of the polyhedral complex P. Notice that @0:P gives the set of P vertices; @1:P gives the set of vertices and edges; @2:P gives the set of vertices, edges and faces. When exporting a polyhedral complex from the language environment, the 2-skeleton is implicitly extracted if the object dimension is greater than 2.

Two simple examples of use of the skeleton extractors combined with the product operators are given in Example 7.

The QUOTE operator

is used in PLaSM to define 1-polyhedra embedded in 1D space. Such (1,1)-polyhedra are often used by other PLaSM functions. The range of the function is the set of sequences of non-zero reals:

QUOTE: (R - {0})* -> P1,1

Negative elements in the sequence are used to denote empty intervals in the complex.


A function to generate fully parameterized 2D building fronts (according to a given partition of the front with full and empty spaces) by using the QUOTE operator is given in Example 8. A simpler example is the following:

@1:(QUOTE:<2,5,2, -5, 2,5,2> * QUOTE:<5,-2,5>)

The Product Operator

is defined as a mapping from pairs of polyhedra to polyhedra:

*: Pd1,n1 Pd2,n2 -> Pd1+n1, d2+n2

where the cells in the polyhedral output are generated by pairwise cartesian products of the cells in the polyhedral input pair. Algorithms for dimension-independent "generalized" product of both polyhedra and polyhedral complexes are given on References [BFPP93] and [PFP96], respectively.

Such a product allows as special cases:

the Cartesian product * of polyhedral complexes;

the intersection of extrusions, denoted as &&:< perm1, perm2 >, where perm1, perm2 are two permutation of indices used to specify how to embed the lower dimensional arguments into the coordinate subspaces of the target space;

the standard intersection of polyhedral complexes.


Let consider the Example 9, which evaluates in this model (here displayed as a wire-frame).

PLaSM is Free Software and may be distributed under GNU LGPL