Quad#
Represents a four-sided mathematical shape (also called “quadrilateral” or “tetragon”) in the plane, defined as a sequence of four Point objects ul, ur, ll, lr (conveniently called upper left, upper right, lower left, lower right).
Quads can be obtained as results of text search methods (Page.SearchFor()), and they are used to define text marker annotations (see e.g. Page.AddSquigglyAnnot() and friends), and in several draw methods (like Page.DrawQuad() / Shape.DrawQuad(), Page.DrawOval()/ Shape.DrawQuad()).
Note
If the corners of a rectangle are transformed with a rotation, scale or translation Matrix, then the resulting quad is rectangular (= congruent to a rectangle), i.e. all of its corners again enclose angles of 90 degrees. Property
Quad.IsRectangularchecks whether a quad can be thought of being the result of such an operation.This is not true for all matrices: e.g. shear matrices produce parallelograms, and non-invertible matrices deliver “degenerate” tetragons like triangles or lines.
Attribute
Quad.Rectobtains the enveloping rectangle. Vice versa, rectangles now have attributesRect.Quad, resp.IRect.quadto obtain their respective tetragon versions.
Methods / Attributes |
Short Description |
|---|---|
Transform with a matrix |
|
Transform with a point and matrix |
|
Upper left point |
|
Upper right point |
|
Lower left point |
|
Lower right point |
|
True if quad is a convex set |
|
True if quad is an empty set |
|
True if quad is congruent to a rectangle |
|
Smallest containing Rect |
|
The longest width value |
|
The longest height value |
Class API
- class Quad#
- Quad()#
- Quad(Point ul, Point ur, Point ll, Point lr)#
- Quad(Quad quad)#
Overloaded constructors: “ul”, “ur”, “ll”, “lr” stand for
Pointobjects (the four corners), “sequence” is a sequence with fourPointobjects.If “quad” is specified, the constructor creates a new copy of it.
Without parameters, a quad consisting of 4 copies of Point(0, 0) is created.
- Transform(Matrix matrix)#
Modify the quadrilateral by transforming each of its corners with a matrix.
- Parameters:
matrix (Matrix) – the matrix.
- Morph(Point p, Matrix m)#
“Morph” the quad with a matrix-like using a point-like as fixed point.
- Rect#
The smallest rectangle containing the quad, represented by the blue area in the following picture.
- Type:
- IsConvex#
Checks if for any two points of the quad, all points on their connecting line also belong to the quad.
- Type:
bool
- IsEmpty#
true if enclosed area is zero, which means that at least three of the four corners are on the same line. If this is false, the quad may still be degenerate or not look like a tetragon at all (triangles, parallelograms, trapezoids, …).
- Type:
bool
- IsRectangular#
true if all corner angles are 90 degrees. This implies that the quad is convex and not empty.
- Type:
bool
- Width#
The maximum length of the top and the bottom side.
- Type:
float
- Height#
The maximum length of the left and the right side.
- Type:
float

