skidl.schematics.geometry module

class skidl.schematics.geometry.BBox(*pts)[source]

Bases: object

add(*objs)[source]

Update the bounding box size by adding Point/BBox objects.

property area

Return area of bounding box.

property ctr

Return center point of bounding box.

property h

Return the bounding box height.

intersection(bbox)[source]

Return the bounding box of the intersection between the two bounding boxes.

intersects(bbox)[source]

Return True if the two bounding boxes intersect.

is_inside(pt)[source]

Return True if point is inside bounding box.

property ll

Return lower-left point of bounding box.

property lr

Return lower-right point of bounding box.

resize(vector)[source]

Expand/contract the bounding box by applying vector to its corner points.

round()[source]
snap_resize(grid_spacing)[source]

Resize bbox so max and min points are on grid.

Parameters:

grid_spacing (float) – Grid spacing.

property ul

Return upper-left point of bounding box.

property ur

Return upper-right point of bounding box.

property w

Return the bounding box width.

class skidl.schematics.geometry.Point(x, y)[source]

Bases: object

flip_xy()[source]

Flip X-Y coordinates of point.

property magnitude

Get the distance of the point from the origin.

mask(msk)[source]

Multiply the X & Y coords by the elements of msk.

max(pt)[source]

Return a Point with coords that are the max x,y of both points.

min(pt)[source]

Return a Point with coords that are the min x,y of both points.

property norm

Return a unit vector pointing from the origin to the point.

round()[source]
snap(grid_spacing)[source]

Snap point x,y coords to the given grid spacing.

xprod(pt)[source]

Cross-product of two 2D vectors returns scalar in Z coord.

class skidl.schematics.geometry.Segment(p1, p2)[source]

Bases: object

flip_xy()[source]

Flip the X-Y coordinates of the segment.

intersects(other)[source]

Return true if the segments intersect.

round()[source]
shadows(other)[source]

Return true if two segments overlap each other even if they aren’t on the same horiz or vertical track.

class skidl.schematics.geometry.Tx(a=1, b=0, c=0, d=1, dx=0, dy=0)[source]

Bases: object

flip_x()[source]

Return Tx with X coords flipped around (0, 0).

flip_y()[source]

Return Tx with Y coords flipped around (0, 0).

classmethod from_symtx(symtx)[source]

Return a Tx() object that implements the “HVLR” geometric operation sequence.

Parameters:

symtx (str) – A string of H, V, L, R operations that are applied in sequence left-to-right.

Returns:

A transformation matrix that implements the sequence of geometric operations.

Return type:

Tx

move(vec)[source]

Return Tx with movement vector applied.

no_translate()[source]

Return Tx with translation set to (0,0).

property origin

Return the (dx, dy) translation as a Point.

rot(degs)[source]

Return Tx rotated by the given angle (in degrees).

rot_90cw()[source]

Return Tx with 90-deg clock-wise rotation around (0, 0).

property scale

Return the scaling factor.

skidl.schematics.geometry.Vector

alias of Point

skidl.schematics.geometry.to_mils(mm)[source]

Convert millimeters to thousandths-of-inch and return.

skidl.schematics.geometry.to_mms(mils)[source]

Convert thousandths-of-inch to millimeters and return.