Point
Point represents a point in the plane, defined by its x and y coordinates.
| Attribute / Method | Short Description |
|---|---|
Point.distance_to() |
calculate distance to point or rect |
Point.transform() |
transform point with a matrix |
Point.x |
the X-coordinate |
Point.y |
the Y-coordinate |
Class API
-
class
Point -
__init__(self)
-
__init__(self, x, y)
-
__init__(self, point)
-
__init__(self, list) Overloaded constructors.
Without parameters,
Point(0, 0)will be created.With another
pointspecified, a new copy will be crated. Alistmust be Python sequence object of length 2. For alist, it is the user’s responsibility to only provide numeric entries - no error checking is done, and invalid entries will receive a value of-1.0.Parameters: - x (float) – X coordinate of the point
- y (float) – Y coordinate of the point
-
distance_to(x[, unit]) Parameters: Returns: distance to object
x.Return type: float
-
transform(m) - Applies matrix
mto the point.Parameters: m – The matrix to be applied. Return type: Point
-
x -
x Coordinate
-
y -
y Coordinate
-
Remark
A point’s p attributes x and y can also be accessed as indices, e.g. p.x == p[0], and the tuple() and list() functions yield sequence objects of its components.
Point Algebra
For a general background, see chapter Operator Algebra for Geometry Objects.
Examples
This should illustrate some basic uses:
>>> fitz.Point(1, 2) * fitz.Matrix(90)
fitz.Point(-2.0, 1.0)
>>>
>>> fitz.Point(1, 2) * 3
fitz.Point(3.0, 6.0)
>>>
>>> fitz.Point(1, 2) + 3
fitz.Point(4.0, 5.0)
>>>
>>> fitz.Point(25, 30) + fitz.Point(1, 2)
fitz.Point(26.0, 32.0)
>>> fitz.Point(25, 30) + (1, 2)
fitz.Point(26.0, 32.0)
>>>
>>> fitz.Point([1, 2])
fitz.Point(1.0, 2.0)
>>>
>>> -fitz.Point(1, 2)
fitz.Point(-1.0, -2.0)
>>>
>>> abs(fitz.Point(25, 30))
39.05124837953327