linkcad.geom
The geometry module provides 2D primitives for coordinate math and shape manipulation.
Classes
Point
A 2D coordinate.
from linkcad.v1.geom import Point
p = Point(1000, 2000)print(p.x, p.y)| 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.
from linkcad.v1.geom import Vector
v = Vector(100, 200)scaled = v * 2.0| 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 |
Transformation
A 2D affine transformation (translation, rotation, scaling, mirroring).
from linkcad.v1.geom import Transformation
t = Transformation.translate(1000, 2000)t = Transformation.rotate(45.0) # degreest = Transformation.scale(2.0)t = Transformation.mirror_x()
combined = t1 * t2 # compose transformationspt = 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.
from linkcad.v1.geom import Bounds
b = Bounds(min_x=0, min_y=0, max_x=1000, max_y=1000)| 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 |
Angle
An angle value. Used where functions accept or return angular quantities.
from linkcad.v1.geom import Angle
a = Angle.from_degrees(45.0)a = Angle.from_radians(0.785398)| Factory / Property | Description |
|---|---|
Angle.from_degrees(deg) | Create from degrees |
Angle.from_radians(rad) | Create from radians |
angle.degrees | Value in degrees |
angle.radians | Value in radians |
Resolution
Controls how curved shapes (circles, arcs, ellipses) are tessellated into polygon vertices during processing operations such as merge.
from linkcad.v1.geom import Resolution
res = Resolution()res.minimum_facets = 32 # at least 32 segments per full circleres.maximum_error = 1 # max deviation in database units| Property | Description |
|---|---|
minimum_facets | Minimum number of polygon segments per full circle |
maximum_error | Maximum allowed deviation from the true curve, in database units |