wgeom
Write geometry function to file
This page describes the legacy workflow. New features might not be compatible with the legacy workflow.
Syntax
Description
writes a geometry function, specified by the geometry matrix fid
= wgeom(dl
,filename
)dl
, to a
file with the name filename.m
. For information about the geometry file
format, see Parametrized Function for 2-D Geometry Creation.
Examples
Create Geometry File
Create a 2-D geometry in the PDE Modeler app, export it to the MATLAB® workspace, and then write it to a file.
Start the PDE Modeler app and draw a unit circle and a unit square.
pdecirc(0,0,1) pderect([0 1 0 1])
Enter C1-SQ1
in the Set formula
field.
Export the geometry description matrix, set formula, and name-space matrix to the MATLAB workspace by selecting the Export Geometry Description option from the Draw menu.
Decompose the exported geometry into minimal regions. The result is one minimal region with five edge segments: three circle edge segments and two line edge segments.
dl = decsg(gd,sf,ns)
dl = 2.0000 2.0000 1.0000 1.0000 1.0000 0 0 -1.0000 0.0000 0.0000 1.0000 0 0.0000 1.0000 -1.0000 0 1.0000 -0.0000 -1.0000 1.0000 0 0 -1.0000 0 -0.0000 0 0 1.0000 1.0000 1.0000 1.0000 1.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.0000 1.0000 1.0000
Write the resulting geometry to a file. Name the file
geometry.m
.
fid = wgeom(dl,"geometry");
Input Arguments
dl
— Decomposed geometry matrix
matrix of double-precision numbers
Decomposed geometry matrix, specified as a matrix of double-precision numbers. It
contains a representation of the decomposed geometry in terms of disjoint minimal
regions constructed by the decsg
algorithm. Each edge segment of
the minimal regions corresponds to a column in dl
. Edge segments
between minimal regions are border segments. Outer boundaries are
boundary segments. In each column, the second and third rows
contain the starting and ending x-coordinates. The fourth and fifth
rows contain the corresponding y-coordinates. The sixth and seventh
rows contain left and right minimal region labels with respect to the direction induced
by the start and end points (counterclockwise direction on circle and ellipse segments).
There are three types of possible edge segments in a minimal region:
For circle edge segments, the first row is
1
. The eighth and ninth rows contain the coordinates of the center of the circle. The 10th row contains the radius.For line edge segments, the first row is
2
.For ellipse edge segments, the first row is
4
. The eighth and ninth rows contain the coordinates of the center of the ellipse. The 10th and 11th rows contain the semiaxes of the ellipse. The 12th row contains the rotational angle of the ellipse.
All shapes in a decomposed geometry matrix have the same number of rows. Rows that are not required for a particular shape are filled with zeros.
Row number | Circle edge segment | Line edge segment | Ellipse edge segment |
---|---|---|---|
1 | 1 | 2 | 4 |
2 | starting x-coordinate | starting x-coordinate | starting x-coordinate |
3 | ending x-coordinate | ending x-coordinate | ending x-coordinate |
4 | starting y-coordinate | starting y-coordinate | starting y-coordinate |
5 | ending y-coordinate | ending y-coordinate | ending y-coordinate |
6 | left minimal region label | left minimal region label | left minimal region label |
7 | right minimal region label | right minimal region label | right minimal region label |
8 | x-coordinate of the center | x-coordinate of the center | |
9 | y-coordinate of the center | y-coordinate of the center | |
10 | radius of the circle | x-semiaxis before rotation | |
11 | y-semiaxis before rotation | ||
12 | Angle in radians between x-axis and first semiaxis |
Data Types: double
filename
— Geometry file name
string | character vector
Geometry file name, specified as a string or a character vector.
Data Types: char
| string
Output Arguments
fid
— File identifier
integer | -1
File identifier, returned as an integer. If wgeom
cannot write
the file, fid
is -1
. For more information about
file identifiers, see fopen
.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)