M-File Help: Polygon View code for Polygon

Polygon

Polygon class

A general class for manipulating polygons and vectors of polygons.

Methods

plot Plot polygon
area Area of polygon
moments Moments of polygon
centroid Centroid of polygon
perimeter Perimter of polygon
transform Transform polygon
inside Test if points are inside polygon
intersection Intersection of two polygons
difference Difference of two polygons
union Union of two polygons
xor Exclusive or of two polygons
display print the polygon in human readable form
char convert the polgyon to human readable string

Properties

vertices List of polygon vertices, one per column
extent Bounding box [minx maxx; miny maxy]
n Number of vertices

Notes

Acknowledgement

The methods inside, intersection, difference, union, and xor are based on code written by:

Kirill K. Pankratov, kirill@plume.mit.edu, http://puddle.mit.edu/~glenn/kirill/saga.html

and require a licence. However the author does not respond to email regarding the licence, so use with care, and modify with acknowledgement.


Polygon.Polygon

Polygon class constructor

p = Polygon(v) is a polygon with vertices given by v, one column per vertex.

p = Polygon(C, wh) is a rectangle centred at C with dimensions wh=[WIDTH, HEIGHT].


Polygon.area

Area of polygon

a = P.area() is the area of the polygon.


Polygon.centroid

Centroid of polygon

x = P.centroid() is the centroid of the polygon.


Polygon.char

String representation

s = P.char() is a compact representation of the polgyon in human readable form.


Polygon.difference

Difference of polygons

d = P.difference(q) is polygon P minus polygon q.

Notes


Polygon.display

Display polygon

P.display() displays the polygon in a compact human readable form.

See also

Polygon.char


Polygon.inside

Test if points are inside polygon

in = p.inside(p) tests if points given by columns of p are inside the polygon. The corresponding elements of in are either true or false.


Polygon.intersect

Intersection of polygon with list of polygons

i = P.intersect(plist) indicates whether or not the Polygon P intersects with

i(j) = 1 if p intersects polylist(j), else 0.


Polygon.intersect_line

Intersection of polygon and line segment

i = P.intersect_line(L) is the intersection points of a polygon P with the line segment L=[x1 x2; y1 y2]. i is an Nx2 matrix with one column per intersection, each column is [x y]'.


Polygon.intersection

Intersection of polygons

i = P.intersection(q) is a Polygon representing the intersection of polygons P and q.

Notes


Polygon.linechk

Input checking for line segments.


Polygon.moments

Moments of polygon

a = P.moments(p, q) is the pq'th moment of the polygon.

See also

mpq_poly


Polygon.perimeter

Perimeter of polygon

L = P.perimeter() is the perimeter of the polygon.


Polygon.plot

Plot polygon

P.plot() plot the polygon.

P.plot(ls) as above but pass the arguments ls to plot.


Polygon.transform

Transformation of polygon vertices

p2 = P.transform(T) is a new Polygon object whose vertices have been transfored by the 3x3 homgoeneous transformation T.


Polygon.union

Union of polygons

i = P.union(q) is a Polygon representing the union of polygons P and q.

Notes


Polygon.xor

Exclusive or of polygons

i = P.union(q) is a Polygon representing the union of polygons P and q.

Notes


 

© 1990-2012 Peter Corke.