kumiki.measuring¶
Flat import path
kumiki/__init__.py re-exports everything on this page via from kumiki import *, so every name below is also available directly as kumiki.EdgeOrCenterline -- you do not need to import from the submodule path shown in the heading above.
kumiki.measuring
¶
Measuring related primitives and functions for marking timbers. The feature primitives defined in this class should only be used for measuring and marking.
When cutting joint on timbers, we want to do things like measure from a reference edge of one timber, and mark that location onto a face of another timber. The types defined in LocatedTimberFeature are exactly the features that we care about when measuring on timbers.
Timber features are named geometric features on a timber, e.g. the centerline, the top face, etc. See TimberFeature enum in timber.py for a list of all timber features.
- Locations are GLOBAL features
- Markings are LOCAL features
Measuring functions follow the following naming convention:
locate_*: functions that take measurements relative to a (LOCAL) feature of a timber and outputs a feature in GLOBAL spacemark_*: functions that take a feature in GLOBAL space and outputs a marking relative to a (LOCAL) feature of a timberscribe_*: functions that take multiple measurements relative to (LOCAL) features of timbers and outputs a measurement relative to a (LOCAL) feature of a timber
OR put more simply:
locate_*means LOCAL to GLOBALmark_*means GLOBAL to LOCALscribe_*means LOCAL to LOCAL
In addition we use the naming convention mark_*_by_* which mark specific primitives using by the specified method.
TODO All mark_* methods that are not mark_by should be deprecated!
Using these functions, we can locate relative to features on one timber and mark them onto another timber.
For example, if we my_feature = locate_into_face(mm(10), TimberFace.RIGHT, timberA) we mean the location (feature) that is a plane 10mm into and parallel with the right face of the timber.
And then if we mark_distance_from_face_in_normal_direction(my_feature, timberB, TimberFace.RIGHT) we mean mark the distance from my_feature to the right face of timberB.
Some locations are signed and oriented. These features follow the following sign conventions:
- locations from timber faces are along the normal pointing INTO the timber i.e. positive is into the face
- locations from timber halfplanes aligning with a timber edge
- positive X is towards the face
- for long faces postivie Y is (usually) in the direction of the timber, sometimes it's the opposite so watch out!
- for end faces, use RHS rule with +Z ponting in the direction of the end
- locations from timber corners
- TODO but also we never do this so who cares
Some locations also have an "origin" point. This information is currently not used in any of these functions. Timber Features follow the following location conventions:
- timber faces are located at the center of the face surface
- timber edges are located on the bottom face of the timber
A Point is just a V3 and sometimes you might find yourself marking a Point and simply using its contained V3 directly! This is OK. We still wrap it in a Point to help ensure encapsulation of locating and marking functions. In particular, some of these functions can take many different types of features and we want to be intentional about passing Points into these functions!
Note there is some redundancy in terminology:
locate <-> measure location <-> feature
measurements just mean some distance relative to some feature. Both markings and locations are measurements.
LocatedTimberFeature
module-attribute
¶
Marking
dataclass
¶
Bases: ABC
locate
abstractmethod
¶
locate() -> Union[UnsignedPlane, Plane, Line, Point, LineOnPlane, Space]
DistanceFromFace
dataclass
¶
Bases: Marking
Represents a distance from a face on a timber with + being AWAY from the face.
locate
¶
locate() -> UnsignedPlane
DistanceFromPointIntoFace
dataclass
¶
Bases: Marking
Represents a distance from a point into a face on a timber with + being INTO the timber (that is the negative face normal direction is the + axis of the measurement) If the point is not supplied, the center of the face is used.
locate
¶
locate() -> Point
Convert the distance from a point into a face to a Point
Returns:
| Type | Description |
|---|---|
Point
|
Point at the specified distance from the starting point |
Source code in kumiki/measuring.py
DistanceFromLongEdgeOnFace
dataclass
¶
Bases: Marking
Represents a distance from a long edge on a timber with + being onto the face from the edge.
locate
¶
locate() -> Line
Convert the distance from a long edge to a line on the specified face.
Returns a line parallel to the edge, on the given face, at the specified distance from the edge. The distance is measured along the face plane, perpendicular to the edge direction. Positive distance means moving in the direction of the "other" face's normal (the face that defines the edge together with self.face).
Returns:
| Type | Description |
|---|---|
Line
|
Line parallel to the edge at the specified distance on the face |
Source code in kumiki/measuring.py
PointFromCornerInFaceDirection
dataclass
¶
Bases: Marking
Point on an edge in a given direction.
locate
¶
locate() -> Point
Source code in kumiki/measuring.py
DistanceFromCornerAlongEdge
dataclass
¶
Bases: Marking
Distance along a timber edge from a reference end (corner) to an intersection or closest point. Positive means into the timber from the end.
locate
¶
locate() -> Point
Source code in kumiki/measuring.py
PlaneFromEdgeInDirection
dataclass
¶
get_center_point_on_face_global
¶
get_center_point_on_face_global(face: SomeTimberFace, timber: PerfectTimberWithin) -> V3
Get the center point of a timber face in global coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
SomeTimberFace
|
The face to get the center of |
required |
timber
|
PerfectTimberWithin
|
The timber |
required |
Returns:
| Type | Description |
|---|---|
V3
|
Center point of the face surface in global coordinates |
Source code in kumiki/measuring.py
get_point_on_feature
¶
get_point_on_feature(feature: Union[UnsignedPlane, Plane, Line, Point, LineOnPlane], timber: PerfectTimberWithin) -> V3
Get a point on a feature.
Source code in kumiki/measuring.py
locate_face
¶
locate_face(timber: PerfectTimberWithin, face: SomeTimberFace) -> Plane
Measure a face on a timber, returning a Plane centered on the face pointing outward.
The plane's normal points OUT of the timber (away from the timber's interior), and the plane's point is positioned at the center of the face surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to measure |
required |
face
|
SomeTimberFace
|
The face to measure |
required |
Returns:
| Type | Description |
|---|---|
Plane
|
Plane with normal pointing outward from the face and point at the face center |
Example
plane = locate_face(timber, TimberFace.RIGHT)
plane.normal points in +X direction (outward from RIGHT face)¶
plane.point is at the center of the RIGHT face surface¶
Source code in kumiki/measuring.py
locate_edge
¶
locate_edge(timber: PerfectTimberWithin, edge: EdgeOrCenterline) -> Line
Measure any edge or centerline on a timber, returning a Line along it.
For TimberCenterline.CENTERLINE: direction = timber length direction, point at mid-length center. For TimberEdge values: uses canonical_line_from_corner to get the starting corner and direction face, then computes the global position and direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to measure |
required |
edge
|
EdgeOrCenterline
|
Which edge or centerline to measure |
required |
Returns:
| Type | Description |
|---|---|
Line
|
Line representing the edge in global coordinates |
Source code in kumiki/measuring.py
locate_long_edge
¶
locate_long_edge(timber: PerfectTimberWithin, edge: TimberLongEdge) -> Line
Measure a long edge on a timber. Thin wrapper around locate_edge.
locate_short_edge
¶
locate_short_edge(timber: PerfectTimberWithin, edge: TimberShortEdge) -> Line
Measure a short edge on a timber. Thin wrapper around locate_edge.
locate_centerline
¶
locate_centerline(timber: PerfectTimberWithin) -> Line
Measure the centerline of a timber. Thin wrapper around locate_edge.
locate_edge_on_face
¶
locate_edge_on_face(timber: PerfectTimberWithin, edge: TimberLongEdge, face: TimberFace) -> LineOnPlane
locate_position_on_centerline_from_bottom
¶
locate_position_on_centerline_from_bottom(timber: PerfectTimberWithin, distance: Numeric) -> Point
Measure a position at a specific point along the timber's centerline, measured from the bottom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to measure on |
required |
distance
|
Numeric
|
Distance along the timber's length direction from the bottom position |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Point on the timber's centerline at the specified distance from bottom |
Source code in kumiki/measuring.py
locate_position_on_centerline_from_top
¶
locate_position_on_centerline_from_top(timber: PerfectTimberWithin, distance: Numeric) -> Point
Measure a position at a specific point along the timber's centerline, measured from the top.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to measure on |
required |
distance
|
Numeric
|
Distance along the timber's length direction from the top position |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Point on the timber's centerline at the specified distance from top |
Source code in kumiki/measuring.py
locate_bottom_center_position
¶
locate_bottom_center_position(timber: PerfectTimberWithin) -> Point
Measure the position of the center of the bottom cross-section of the timber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to measure on |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Point at the center of the bottom cross-section |
Source code in kumiki/measuring.py
locate_top_center_position
¶
locate_top_center_position(timber: PerfectTimberWithin) -> Point
Measure the position of the center of the top cross-section of the timber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber to measure on |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Point at the center of the top cross-section |
Source code in kumiki/measuring.py
locate_into_face
¶
locate_into_face(distance: Numeric, face: SomeTimberFace, timber: PerfectTimberWithin) -> UnsignedPlane
Measure a distance from a face on a timber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
Numeric
|
How far into the timber, along the face's inward normal, to place the plane |
required |
face
|
SomeTimberFace
|
The face to measure from (can be TimberFace, TimberEnd, or TimberLongFace) |
required |
timber
|
PerfectTimberWithin
|
The timber to measure on |
required |
Returns:
| Type | Description |
|---|---|
UnsignedPlane
|
UnsignedPlane parallel to the face, offset |
UnsignedPlane
|
normal. This is the inverse of mark_distance_from_face_in_normal_direction: if |
UnsignedPlane
|
feature = locate_into_face(d, face, timber), then |
UnsignedPlane
|
mark_distance_from_face_in_normal_direction(feature, timber, face).distance == d |
Source code in kumiki/measuring.py
locate_plane_from_edge_in_direction
¶
locate_plane_from_edge_in_direction(timber: PerfectTimberWithin, edge: EdgeOrCenterline, direction: Direction3D, distance: Numeric = scalar(0)) -> Plane
Return a Plane that is parallel to the given edge, has direction as its
normal, and sits distance away from the edge in that direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timber
|
PerfectTimberWithin
|
The timber whose edge to measure from |
required |
edge
|
EdgeOrCenterline
|
Which edge or centerline |
required |
direction
|
Direction3D
|
Normal direction of the resulting plane |
required |
distance
|
Numeric
|
How far from the edge to place the plane (default 0 = through the edge) |
scalar(0)
|
Source code in kumiki/measuring.py
locate_plane_from_centerline_in_direction
¶
locate_plane_from_centerline_in_direction(timber: PerfectTimberWithin, direction: Direction3D) -> Plane
mark_distance_from_face_in_normal_direction
¶
mark_distance_from_face_in_normal_direction(feature: Union[UnsignedPlane, Plane, Line, Point, LineOnPlane], timber: PerfectTimberWithin, face: SomeTimberFace) -> DistanceFromFace
Mark a feature onto a face on a timber.
Returns a DistanceFromFace measurement representing the distance from the face to the feature, measured INTO the timber. Positive means the feature is inside the timber (deeper than the face surface). Negative means the feature is outside the timber (shallower than the face surface).
This is the inverse of locate_into_face: If feature = locate_into_face(d, face, timber), then mark_distance_from_face_in_normal_direction(feature, timber, face).distance = d
Source code in kumiki/measuring.py
mark_distance_from_corner_along_edge_by_intersecting_plane
¶
mark_distance_from_corner_along_edge_by_intersecting_plane(plane: Union[UnsignedPlane, Plane], timber: PerfectTimberWithin, edge: Union[TimberLongEdge, TimberShortEdge, EdgeOrCenterline], end: TimberEnd) -> DistanceFromCornerAlongEdge
Mark onto an edge by intersecting a plane, returning a DistanceFromCornerAlongEdge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plane
|
Union[UnsignedPlane, Plane]
|
the plane to intersect with |
required |
timber
|
PerfectTimberWithin
|
the timber whose edge we're intersecting |
required |
edge
|
Union[TimberLongEdge, TimberShortEdge, EdgeOrCenterline]
|
the edge to intersect with (TimberLongEdge, TimberShortEdge, TimberEdge, or TimberCenterline) |
required |
end
|
TimberEnd
|
the end of the timber to mark from |
required |
Returns:
| Type | Description |
|---|---|
DistanceFromCornerAlongEdge
|
DistanceFromCornerAlongEdge with the signed distance from the end to the |
DistanceFromCornerAlongEdge
|
intersection. Positive means into the timber from the end. |
Source code in kumiki/measuring.py
mark_distance_from_corner_along_edge_by_finding_closest_point_on_line
¶
mark_distance_from_corner_along_edge_by_finding_closest_point_on_line(line: Line, timber: PerfectTimberWithin, edge: Union[TimberLongEdge, TimberShortEdge, EdgeOrCenterline], end: TimberEnd) -> DistanceFromCornerAlongEdge
Mark onto an edge by finding the closest point to a line, returning a DistanceFromCornerAlongEdge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line feature to mark from |
required |
timber
|
PerfectTimberWithin
|
The timber whose edge we're marking to |
required |
edge
|
Union[TimberLongEdge, TimberShortEdge, EdgeOrCenterline]
|
The edge to mark to (TimberLongEdge, TimberShortEdge, TimberEdge, or TimberCenterline) |
required |
end
|
TimberEnd
|
Which end of the timber to mark from |
required |
Returns:
| Type | Description |
|---|---|
DistanceFromCornerAlongEdge
|
DistanceFromCornerAlongEdge with the signed distance from the end to the closest point. |
Source code in kumiki/measuring.py
mark_distance_from_end_along_centerline
¶
mark_distance_from_end_along_centerline(feature: Union[UnsignedPlane, Plane, Line, Point, LineOnPlane], timber: PerfectTimberWithin, end: TimberEnd = BOTTOM) -> DistanceFromPointIntoFace
Mark a feature onto the centerline of a timber.
Returns a DistanceFromPointIntoFace measurement representing the distance from the specified end of the timber to the intersection/closest point on the centerline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature
|
Union[UnsignedPlane, Plane, Line, Point, LineOnPlane]
|
The feature to mark (Plane, Line, Point, etc.) |
required |
timber
|
PerfectTimberWithin
|
The timber whose centerline we're marking to |
required |
end
|
TimberEnd
|
Which end of the timber to mark from (defaults to BOTTOM) |
BOTTOM
|
Returns:
| Type | Description |
|---|---|
DistanceFromPointIntoFace
|
DistanceFromPointIntoFace with distance from the specified end to where the feature intersects/is closest |
DistanceFromPointIntoFace
|
to the centerline. Positive means into the timber from the end. The point is set to the end's |
DistanceFromPointIntoFace
|
centerline position. |
Source code in kumiki/measuring.py
mark_plane_from_edge_in_direction
¶
mark_plane_from_edge_in_direction(plane: Union[UnsignedPlane, Plane, LineOnPlane], timber: PerfectTimberWithin, edge: EdgeOrCenterline) -> PlaneFromEdgeInDirection
Mark a plane onto a timber edge, returning the direction and signed distance from the edge to the plane.
This is the inverse of locate_plane_from_edge_in_direction: if p = locate_plane_from_edge_in_direction(timber, edge, dir, dist), then mark_plane_from_edge_in_direction(p, timber, edge) returns (dir, dist).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plane
|
Union[UnsignedPlane, Plane, LineOnPlane]
|
The plane to mark (its normal becomes the direction) |
required |
timber
|
PerfectTimberWithin
|
The timber whose edge we're measuring from |
required |
edge
|
EdgeOrCenterline
|
Which edge to measure from |
required |