# decsg

Decompose constructive solid 2-D geometry into minimal regions

## Description

decomposes
the geometry description matrix `dl`

= decsg(`gd`

,`sf`

,`ns`

)`gd`

into the geometry
matrix `dl`

and returns the minimal regions that
satisfy the set formula `sf`

. The name-space matrix `ns`

is
a text matrix that relates the columns in `gd`

to
variable names in `sf`

.

Typically, you draw a geometry in the PDE Modeler app, then export it to the MATLAB^{®} Command Window by selecting **Export Geometry
Description, Set Formula, Labels** from the
**Draw** menu in the app. The resulting geometry
description matrix `gd`

represents the CSG model.
`decsg`

analyzes the model and constructs a set of
disjointed minimal regions bounded by boundary segments and border segments.
This set of minimal regions constitutes the *decomposed
geometry* and allows other Partial Differential Equation Toolbox™ functions to work with the geometry.

Alternatively, you can use the `decsg`

function
when creating a geometry without using the app. See 2-D Geometry Creation at Command Line for details.

To return all minimal regions (`sf`

corresponds
to the union of all shapes in `gd`

), use the shorter
syntax

.`dl`

= decsg(`gd`

)

## Examples

## Input Arguments

## Output Arguments

## Limitations

In rare cases

`decsg`

can error or create an invalid geometry because of the limitations of its algorithm. Such issues can occur when two or more edges of a geometry partially overlap, almost coincide, or are almost tangent.

## Tips

`decsg`

does not check the input CSG model for correctness. It assumes that no circles or ellipses are identical or degenerated and that no lines have zero length. Polygons must not be self-intersecting.`decsg`

returns`NaN`

if it cannot evaluate the set formula`sf`

.

## See Also

`geometryFromEdges`

| `csgdel`

| `wgeom`

| `pdecirc`

| `pdeellip`

| `pdepoly`

| `pderect`

| PDE
Modeler

**Introduced before R2006a**