Skip to content

compas_wood.assign_vectors ¤

Match tag points / direction lines to plate edges and write joint types and insertion vectors.

Slot convention: a plate with n_edges boundary edges has n_faces = n_edges + 2 faces. Slots 0/1 are the bottom/top faces; edge i maps to face slot i + 2.

Functions:¤

assign_insertion_vectors ¤

assign_insertion_vectors(model: PlateModel, lines, snap_radius: float = 0.1, plate_ids=None) -> dict[int, list[float]]

Match lines to plate edges and tag the insertion vector on each matched face slot.

The stored vector is normalize(cross(plate_normal, line_direction)) — see :func:insertion_vectors_from_lines for the matching rules.

Parameters:

Name Type Description Default
model :class:`compas_wood.model.PlateModel`

Mutated in place via model.tag_plate_joinery.

required
lines sequence of :class:`compas.geometry.Line` or (start, end) pairs

A line matches an edge when either endpoint is within snap_radius of it. Lines shorter than 1e-10 are skipped with a warning.

required
snap_radius float

Maximum distance from a line endpoint to an edge for a match.

0.1
plate_ids sequence[int]

Restrict matching to these plates; default is all plates in sorted-id order.

None

Returns:

Type Description
dict[int, list[float]]

The changed flat vector rows (length (n_edges + 2) * 3) keyed by plate id. An existing row is merged only when its length matches.

assign_joint_types ¤

assign_joint_types(model: PlateModel, dots, snap_radius: float = 0.1, plate_ids=None) -> dict[int, list[int]]

Match dot positions to plate edges and tag the joint type on each matched face slot.

Joint type codes: 3=ss_ip, 15=ss_op, 20=top-to-side, 30=cr_ip, 40=tt, 58=ss_r, 60=boundary.

Parameters:

Name Type Description Default
model :class:`compas_wood.model.PlateModel`

Mutated in place via model.tag_plate_joinery.

required
dots sequence of (point, joint_type_code)

Point is a :class:compas.geometry.Point or [x, y, z]; the code is one of the integers above.

required
snap_radius float

Maximum distance from a dot to a plate edge for a match.

0.1
plate_ids sequence[int]

Restrict matching to these plates; default is all plates in sorted-id order.

None

Returns:

Type Description
dict[int, list[int]]

The changed joint-type rows (length n_faces) keyed by plate id. A dot matching edge i writes to face slot i + 2; the last match wins per slot. An existing row is merged only when its length matches n_faces.

insertion_vectors_from_lines ¤

insertion_vectors_from_lines(bot_polylines, lines, snap_radius: float = 0.1) -> list[tuple[int, int, float, float, float]]

Match lines to plate edges and compute insertion vectors from the line directions.

Parameters:

Name Type Description Default
bot_polylines sequence of :class:`compas.geometry.Polyline` or list of [x, y, z]

Bottom outline of each plate.

required
lines sequence of :class:`compas.geometry.Line` or (start, end) pairs

A line matches an edge when either endpoint is within snap_radius of it. Lines shorter than 1e-10 are skipped with a warning.

required
snap_radius float

Maximum distance from a line endpoint to an edge for a match.

0.1

Returns:

Type Description
list[tuple[int, int, float, float, float]]

(plate_idx, face_slot, iv_x, iv_y, iv_z) — face_slot already has the +2 offset, and the kernel keeps only the best-distance line per (plate, slot). The vector is normalize(cross(plate_normal, line_direction)) — zero when the line is parallel to the plate normal.

match_points_to_plate_edges ¤

match_points_to_plate_edges(bot_polylines, points, snap_radius: float = 0.1) -> list[tuple[int, int, int]]

Find all (point, plate edge) pairs within snap_radius.

Parameters:

Name Type Description Default
bot_polylines sequence of :class:`compas.geometry.Polyline` or list of [x, y, z]

Bottom outline of each plate.

required
points sequence of :class:`compas.geometry.Point` or [x, y, z]

Query positions.

required
snap_radius float

Maximum distance from a point to an edge for a match.

0.1

Returns:

Type Description
list[tuple[int, int, int]]

(point_idx, plate_idx, edge_idx) per match — edge_idx is raw, without the +2 slot offset.