linkcad.geom
The geometry module provides 2D primitives for coordinate math and shape manipulation.
Classes
Point
A 2D coordinate.
| Property / Method | Description |
|---|---|
x, y |
Coordinate components |
distance_to(other) |
Euclidean distance |
midpoint(other) |
Midpoint between two points |
+, - operators |
Vector arithmetic |
Vector
A 2D direction/offset.
| Property / Method | Description |
|---|---|
x, y |
Vector components |
length() |
Vector magnitude |
normalized() |
Unit vector |
dot(other) |
Dot product |
cross(other) |
2D cross product (scalar) |
*, / operators |
Scalar multiplication |
PointArray
An ordered sequence of points, used for polygon and polyline vertices.
| Property / Method | Description |
|---|---|
len(pts) |
Number of points |
pts[i] |
Access by index |
area() |
Signed area (polygons) |
bounds() |
Bounding box |
reversed() |
Reversed copy |
Transformation
A 2D affine transformation (translation, rotation, scaling, mirroring).
from linkcad.geom import Transformation
t = Transformation.translate(1000, 2000)
t = Transformation.rotate(45.0) # degrees
t = Transformation.scale(2.0)
t = Transformation.mirror_x()
combined = t1 * t2 # compose transformations
pt = t.apply(Point(0, 0))
| Factory Method | Description |
|---|---|
Transformation.identity() |
No-op transform |
Transformation.translate(dx, dy) |
Translation |
Transformation.rotate(degrees) |
Rotation around origin |
Transformation.scale(factor) |
Uniform scaling |
Transformation.scale_xy(sx, sy) |
Non-uniform scaling |
Transformation.mirror_x() |
Mirror about X axis |
Transformation.mirror_y() |
Mirror about Y axis |
| Method | Description |
|---|---|
apply(point) |
Transform a point |
apply_all(points) |
Transform a list of points |
inverse() |
Inverse transformation |
* operator |
Compose transformations |
Bounds
An axis-aligned bounding box.
| Property / Method | Description |
|---|---|
min_x, min_y |
Lower-left corner |
max_x, max_y |
Upper-right corner |
width, height |
Dimensions |
center() |
Center point |
contains(point) |
Point-in-bounds test |
intersects(other) |
Overlap test |
union(other) |
Merge two bounds |