geom.Path
drafting: geom.Path
A path of straight segments, circular arcs and splines in three dimensions.
A geom.Path is the route a section is swept along by
solid.sweep: a pipe run, a bent bar or the centre line of a frame.
It is open or closed and, unlike a geom.Polyline, need not lie in
one plane.
The vertices are coordinates in the path’s geom.UCS, the world
coordinate system by default, so the same path can be laid anywhere, as a
polyline is laid on a plane. Assigning another UCS moves the path, its
shape unchanged in its own coordinates.
An arc is kept by the point half way along it, which fixes its plane and
its radius; a bulge, as a polyline keeps, would leave the plane of an arc
undecided in three dimensions. Arcs come from rounding corners with
geom.Path.fillet, from a polyline’s bulges, or from three points
with geom.Path.arc. A geom.Spline makes one smooth segment
of its own. Pieces are put end to end with geom.Path.join.
A geom.Path is a value: every change makes a new one.
See also: solid.sweep, geom.Spline, geom.Polyline, geom.Region, geom.UCS
Source Code: geom.Path
The geom.Path class contains the following properties:
The vertices as an M-by-3 matrix [x, y,
z], in millimetres in the path’s UCS.
An M-by-3 matrix whose row i is the point half way along
the arc leaving vertex i, or NaN where the segment leaving
it is straight or where no segment leaves it, at the end of an open
path. The points are in the path’s UCS.
An M-by-1 cell whose element i is the geom.Spline
of the segment leaving vertex i, its points in the path’s
coordinates, or empty where that segment is a straight segment or an
arc.
true when the last vertex is joined back to the first.
The geom.UCS the vertices are coordinates in, the world
coordinate system by default. Assigning another moves the path onto
it, its shape unchanged in its own coordinates.
The geom.Path class offers the following public methods:
geom.Path: P = geom.Path (V)
geom.Path: P = geom.Path (V, Name, Value, …)
geom.Path: P = geom.Path (PL)
geom.Path: P = geom.Path (SP)
P = geom.Path (V) makes an open path of straight
segments through the points given as rows of V, an M-by-3
matrix in millimetres, or an M-by-2 matrix of points in the plane
of the UCS, with at least two rows.
Name/Value pairs:
'Closed'true to join the last point back to the first, false by
default. A closed path must not repeat its first point at the
end; a repeat is accepted and dropped.'UCS'geom.UCS the points are coordinates in, the world coordinate
system by default. P = geom.Path (PL) makes the path of the
geom.Polyline PL, in its UCS, open or closed as PL
is, with its arcs kept exact.
P = geom.Path (SP) makes the path of one segment
along the geom.Spline SP, in its UCS. A closed spline
makes a closed path of one vertex, its first point, the spline running
from it round and back.
## The centre line of a tube bent twice, with bends of radius 15 P = geom.Path ([0, 0, 0; 0, 0, 100; 80, 0, 100; 80, 60, 100]); P = fillet (P, 15); |
geom.Path: P = fillet (P, RADIUS)
geom.Path: P = fillet (P, RADIUS, IDX)
P = fillet (P, RADIUS) rounds every corner
where two straight segments meet with an arc of radius RADIUS
millimetres, tangent to both and in their plane, as a tube is bent: the
corner vertex becomes the two points where the arc meets the segments,
joined by the arc. Corners where an arc or a spline meets a segment are
left as they are, and so are the two ends of an open path.
P = fillet (P, RADIUS, IDX) rounds only
the corners at the vertices indexed by IDX, each of which must be
a corner between two straight segments.
A radius too large for a corner, whose arc would run past the end of a segment or into the round of the next corner, is refused. Rounds that use up a segment between them meet, and the segment is dropped.
See also: geom.Polyline.fillet
geom.Path: P = chamfer (P, D)
geom.Path: P = chamfer (P, [D1, D2])
geom.Path: P = chamfer (…, IDX)
geom.Path: P = chamfer (…, 'Angle', A)
P = chamfer (P, D) cuts every corner where two
straight segments meet with a straight segment from D millimetres
back along the segment before the corner to D along the segment
after it. Corners where an arc or a spline meets a segment are left as
they are, and so are the two ends of an open path.
P = chamfer (P, [D1, D2]) cuts back
D1 along the segment before each corner and D2 along the
segment after it, before and after in the order of the vertices.
P = chamfer (P, D,
cuts back D along the segment before each corner, with the cut at
A degrees to that segment.
'Angle', A)
P = chamfer (…, IDX) cuts only the corners at
the vertices indexed by IDX, each of which must be a corner
between two straight segments.
A cut that would run past the end of a segment, or into the cut or round of the next corner, or an angle at which the cut misses the segment after the corner, is refused.
See also: geom.Path.fillet, geom.Polyline.chamfer
geom.Path: P = join (P1, P2, …)
geom.Path: P = join (…, 'Tangent', TF)
P = join (P1, P2, …) returns the path
that runs along P1, then P2, and so on, each a
geom.Path or a geom.Spline. Each path must be open and
begin where the piece before it ends. The pieces need not meet
smoothly: where they meet at an angle, the path has a corner. When the
last piece ends where the first begins, the path is closed. The path
is in the UCS of P1, the others’ points carried into it.
Where a free end of a spline drawn through points meets a straight
segment, an arc or a spline end with a direction of its own, the spline
takes that direction, so the path runs on smoothly there. A spline made
from control points is kept as it is. With
'Tangent' set to false, free ends stay free and the
path may have a corner there.
## A hairpin: up, over the top by a half circle, and down
P = join (geom.Path ([0, 0, 0; 0, 0, 50]), ...
geom.Path.arc ([0, 0, 50], [10, 0, 60], [20, 0, 50]), ...
geom.Path ([20, 0, 50; 20, 0, 0]));
|
geom.Path: L = length (P)
L = length (P) returns the length of the path
P in millimetres along its arcs and splines, including the
segment that closes a closed path.
geom.Path: write (P, FILE)
geom.Path: write (P, FILE, Name, Value, …)
write (P, FILE) writes the path P to
FILE, which must end in .dxf, as its pieces in an ASCII
DXF drawing: a LINE for each straight segment, an ARC on
its own plane for each arc and a SPLINE for each spline, in
world coordinates, bound by a group. The group’s extended data, under
the application 'DRAFTING', names the class and holds the
path’s geom.UCS, so geom.read gives back the path that
was written, closed or not, in its frame. A program that does not
know the package sees the pieces, which is what a path is.
Name/Value pairs:
'Layer''0' by default.'Linetype'draw.linetype, or any name the
receiving program holds; 'CONTINUOUS' by default.'Colour''Version''R2000' (AC1015), the default, or 'R12'
(AC1009) for a program that reads nothing later. R12 has no
groups and holds only lines and arcs, so a path is an error there.'LTScale' The drawing units are millimetres. Several geom objects go in one file
through geom.write.
See also: geom.read, geom.write, draw.Drawing.write
geom.Path: P = geom.Path.arc (P1, PM, P2)
P = geom.Path.arc (P1, PM, P2) returns
the open path along the circular arc that starts at P1, passes
through PM and ends at P2. PM may be any point on the
arc between its ends. Each point is a 3-element vector in world
coordinates, and the three must not lie on one line. The path is in
the world coordinate system, and assigning it a UCS moves it there.
See also: geom.Path.join
geom.Path: C = geom.Path.chain (PIECES)
C = geom.Path.chain (PIECES) joins the
geom.Polyline, geom.Spline and geom.Path objects
in the cell array PIECES wherever an end of one meets an end of
another, and returns the paths they make as a row cell array, one for
each run of pieces, or cell (1, 0) when PIECES is empty.
This is how the lines, arcs and splines of a drawing, given in any
order and any direction, become the outlines they draw.
Two ends meet when they lie within 1e-4 millimetres of each other. The pieces are turned round as the run needs, and the two ends of every joint are moved to the point half way between them, so that the path passes through one vertex there. Nothing else is changed: arcs stay exact arcs, splines stay the splines they were, and where pieces meet at an angle the path has a corner. A run whose last end meets its first is closed, and a piece that is closed already comes back as a closed path of its own.
Where an end meets more than one other end, the run stops there, and each branch is a path of its own: the pieces do not say which way the outline goes on. The paths come in the order of the first piece of each in PIECES.
The paths are in the world coordinate system, unless every piece has the same UCS, in which case they are in that one.
## A slot drawn as two lines and two half circles, in no order
C = geom.Path.chain ({geom.Polyline ([0, 0; 20, 0]), ...
geom.Polyline ([0, 10, 1; 0, 0, 0]), ...
geom.Polyline ([0, 10; 20, 10]), ...
geom.Polyline ([20, 0, 1; 20, 10, 0])});
|
See also: geom.Path.join, geom.Region.nest