offset operation

Syntax

  • offset (offsetDistance)
  • offset (offsetDistance, offsetSelector)

Parameters

  1. offsetDistancefloat
    The offset distance, negative or positive.
  2. offsetSelectorselstr
    { all | inside | border }— selects which faces to keep. all is default.

Description

The offset operation constructs offset polygons at distance offsetDistance for each face of the current shape's geometry. Depending on the sign of the parameter, offset polygons are constructed in the interior (negative sign) or in the exterior (positive sign), respectively. The scope's size is adapted to the new geometry.

Note:

The resulting shape contains both the offset polygons and the border faces (that is the difference between the original faces and the offset polygons). If only the offset polygons are needed, the corresponding faces can simply be extracted by using a component split (see examples below). Alternatively, an offset selector can be supplied as a second parameter.

Scope

The scope's size is adapted to the new geometry.

Occluder shape

In case an offset selector is applied an unlabled occluder shape is automatically generated before the offset is applied. The occluder shape is made available for unlabeled occlusion queries.

Related

Examples

Offset Polygons and Border Faces

The following illustration lists offset polygons (red) and border faces (green) in both the interior and exterior case.

Offset polygons and faces in both interior and exterior

The original polygon (in the middle) is downsized (negative offsets) and enlarged (positive offsets). Offset polygons are colored in red, border faces are in green. Note that in the case of enlarging, offset polygons and the border faces overlap.

These offset polygons have been generated using the rule below with offset between -3 and 3.

attr red   = "#FF0000"
attr green = "#00FF00"

Lot --> 
   offset(-3) A

A --> 
   comp(f) { inside : I 
           | border : O }

I --> 
   color(red)

O --> 
   color(green)

To extract the offset polygons, the inside selector is used for the component split. In the exterior case, this might be confusing, since offset polygons are actually outside in this case.

Note:

When using positive offsets, border faces (green) and offset polygons (red) overlap. In this case the normals of the border faces point down (see below).

Face Orientation

In the following illustration for each face, the first edge is marked.

In the interior case (offset = -1), both the inside and the border faces are oriented counter-clockwise (positive).

Interior case

In the exterior case (offset = 1), only the red face is oriented counter-clockwise. The green border faces are clockwise (negative).

Exterior case
Note:

Since the border faces are negative in the exterior case, the following boolean equation holds in both cases: Inside faces + Border faces = Original Face.


In this topic