Point
A 2D point with x and y coordinates.
Points represent positions in the layout plane. They are the fundamental coordinate type used throughout Rosette for specifying polygon vertices, port locations, and transform targets. Points are immutable -- all transformation methods return new Point instances.
p = Point(10, 20)
q = Point.origin()
d = p.distance_to(q) # 22.36...
# Translate by a vector
moved = p.translate(Vector2(5, 0)) # Point(15, 20)Attributes
attributexfloatX coordinate.
attributeyfloatY coordinate.
Methods
func__init__(x=0.0, y=0.0) -> NoneCreate a new point.
paramxfloat= 0.0X coordinate.
paramyfloat= 0.0Y coordinate.
Returns
Nonefuncorigin() -> PointCreate a point at the origin (0, 0). This is a static method.
p = Point.origin() # Point(0.0, 0.0)Returns
Pointfuncdistance_to(other) -> floatCompute the Euclidean distance to another point.
paramotherPointThe other point.
Returns
floatDistance between the two points.
functranslate(v) -> PointReturn a new point translated by a vector.
paramvVector2Translation vector.
Returns
PointA new translated point.
funcrotate(angle_deg) -> PointRotate the point around the origin by the given angle.
paramangle_degfloatRotation angle in degrees (counter-clockwise).
Returns
PointA new rotated point.
funcrotate_around(center, angle_deg) -> PointRotate the point around an arbitrary center point.
paramcenterPointCenter of rotation.
paramangle_degfloatRotation angle in degrees (counter-clockwise).
Returns
PointA new rotated point.
Supported operations
Addition: point + vector returns a new Point offset by the vector. Equivalent to point.translate(vector).
Point(1, 2) + Vector2(3, 4) # Point(4, 6)Subtraction: point - point returns a Vector2 representing the displacement from the right-hand point to the left-hand point.
Point(5, 7) - Point(1, 2) # Vector2(4, 5)