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

attributexfloat

X coordinate.

attributeyfloat

Y coordinate.

Methods

func__init__(x=0.0, y=0.0) -> None

Create a new point.

paramxfloat
= 0.0

X coordinate.

paramyfloat
= 0.0

Y coordinate.

Returns

None
funcorigin() -> Point

Create a point at the origin (0, 0). This is a static method.

p = Point.origin()  # Point(0.0, 0.0)

Returns

Point
funcdistance_to(other) -> float

Compute the Euclidean distance to another point.

paramotherPoint

The other point.

Returns

float

Distance between the two points.

functranslate(v) -> Point

Return a new point translated by a vector.

paramvVector2

Translation vector.

Returns

Point

A new translated point.

funcrotate(angle_deg) -> Point

Rotate the point around the origin by the given angle.

paramangle_degfloat

Rotation angle in degrees (counter-clockwise).

Returns

Point

A new rotated point.

funcrotate_around(center, angle_deg) -> Point

Rotate the point around an arbitrary center point.

paramcenterPoint

Center of rotation.

paramangle_degfloat

Rotation angle in degrees (counter-clockwise).

Returns

Point

A 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)

On this page