geom.isrectilinear
drafting: TF = geom.isrectilinear (P)
drafting: TF = geom.isrectilinear (P, TOL)
True when every edge of a polygon is parallel to an axis.
TF = geom.isrectilinear (P) returns true when every
edge of the polygon P runs parallel to either the or the
axis, and false otherwise. The polygon is implicitly closed,
so the edge joining the last vertex to the first is tested as well.
TF = geom.isrectilinear (P, TOL) uses TOL as
the absolute tolerance, in the units of P, on the off-axis component of
each edge. TOL defaults to 1e-6, that is one micrometre at the
package’s millimetre convention. The default is deliberately looser than
machine precision: coordinates that have been through a rotation, or that
arrive from a CAD package, carry accumulated rounding that an exact test
would reject.
This is the gate for geom.offset and geom.largestrect, both of
which are exact only on rectilinear outlines. A building outline of the kind
those functions serve is a rectangle in the great majority of cases and an L
shape in most of the rest.
A zero-length edge counts as axis-parallel, since it has no direction to disagree with.
See also: geom.offset, geom.largestrect, geom.signedarea
Source Code: geom.isrectilinear
The gate for geom.offset and geom.largestrect, both exact only on outlines whose edges run along the axes.
geom.isrectilinear ([0, 0; 40, 0; 40, 30; 0, 30]) # a rectangle
ans = 1
geom.isrectilinear ([0, 0; 40, 0; 40, 15; 20, 15; 20, 30; 0, 30]) # an L
ans = 1
geom.isrectilinear ([0, 0; 40, 0; 20, 30]) # a triangle
ans = 0
The tolerance matters, because an outline that came from a CAD file carries rounding that an exact test would reject.
P = [0, 0; 40, 1e-7; 40, 30; 0, 30]; geom.isrectilinear (P) # default tolerance: still rectilinear
ans = 1
geom.isrectilinear (P, 1e-12) # exact: no longer
ans = 0