This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Three Ways to Create 2-D Geometry

There are three ways to create 2-D geometry. Two are based on CSG (Constructive Solid Geometry) models, which combine basic shapes.

  • Use the PDE Modeler app to draw basic shapes (rectangles, circles, ellipses, and polygons) and combine them with set intersection and unions to obtain the final geometry. You can then export the geometry to your MATLAB® workspace, or continue to work in the app. For details, see 2-D Geometry Creation in PDE Modeler App.

  • Use the decsg function to create geometry at the command line as follows:

    • Specify matrices that represent the basic shapes (rectangles, circles, ellipses, and polygons).

    • Give each shape a label.

    • Specify a “set formula” that describes the intersections, unions, and set differences of the basic shapes.

    decsg allows you to describe any geometry that you can make from the basic shapes (rectangles, circles, ellipses, and polygons). For details, see 2-D Geometry Creation at Command Line.

  • Specify a function that describes the geometry. The function must be in the form described in Parametrized Function for 2-D Geometry Creation.

How to Decide on a Geometry Creation Method

This table lists the advantages and disadvantages of each method for creating geometry. In general, choose the lowest-numbered method:

  1. Use the PDE Modeler app if you can (simple geometry).

  2. Use the decsg function for geometries that are somewhat complex but can be described in terms of the basic shapes.

  3. Use a geometry description function if you cannot use the other methods.

MethodAdvantagesDisadvantages
PDE Modeler appSimple click-and-drag interfaceCan be tedious to specify exact shapes
See the geometry as you create itCan fail for complex figures
Instant feedback on subdomains, connectednessNo control of edge or subdomain labels
 Only basic shapes as building blocks: rectangles, circles, ellipses, and polygons
decsgControl all basic geometry elementsCannot see the geometry as you create it
 No control of edge or subdomain labels
 Only basic shapes as building blocks: rectangles, circles, ellipses, and polygons
Geometry functionSpecify any shapeCannot see the geometry as you create it
Specify edge and subdomain labelsNeed to write a function