offset operation

Syntax

  • offset(distance)
  • offset(distance, keepFaces)

Parameters

  1. distancefloat
    The offset distance, negative or positive.
  2. keepFacesselector
    { all | inside | border }—Selects which faces to keep. all is default.

Description

The offset operation constructs offset polygons at distance distance 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.

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 occluder shape is automatically generated before the offset is applied. The occluder shape is made available for unlabeled occlusion queries.

Compontent tags

The operation propagates existing component tags to the resulting geometry. See the section about tag propagation for more information on working with component tags.

Related

Examples

Offset Polygons and Border Faces

The following illustration lists offset polygons (blue) and border faces (yellow) 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 blue, border faces are in yellow. Note that in the case of enlarging, offset polygons and the border faces overlap.

These offset polygons have been generated using the rule

attr blue    = "#3957A5"
attr yellow  = "#F2BB1D"

Lot --> offset(-3) A
A   --> comp(f) { inside: I | border: O }
I   --> color(blue)
O   --> color(yellow)

with offset between -3 and 3.

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 (yellow) and offset polygons (blue) 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 blue face is oriented counter-clockwise. The yellow 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.