curd
curd defines a 3D curve by number, as a polyline or as a cubic spline through control points.
Syntax
curd number lp3 x y z [ x y z ... ] ; [ operator ... ; ]
curd number csp3 option [ end_value ... ] x y z [ x y z ... ] ; [ operator ... ; ]
number: the curve’s number, a whole number of 1 or more.cur,curf,cureandcursrefer to the curve by it.lp3: a polyline through the points, in order.csp3: a cubic spline through the points.x y z: the coordinates of a control point. A curve needs at least two, and the count of numbers must be a multiple of three.operator: an optional transformation, the operators of tr, ended by;. James applies it to the control points.
A curd holds one type group, lp3 or csp3. Extra ; after the point list are ignored.
csp3 takes an option first. It is the word loop, which closes the spline into a smooth loop and takes no end value, or two digits. The first digit says how the first point is held and the second digit how the last is held:
| Digit | Condition at that end | Values that follow the option |
|---|---|---|
0 | natural: second derivative zero | none |
1 | a derivative vector | three reals dx dy dz |
2 | matches the first end of another curve | a curve number and a magnitude |
3 | matches the last end of another curve | a curve number and a magnitude |
The values of the first digit come before those of the second. A match takes the other curve’s unit tangent at the named end and scales it by the magnitude.
What it does
curd adds one curve to the table of 3D curves. A curve is geometry for the attach commands to use and moves nothing by itself. lp3 is exact geometry: straight segments. csp3 solves a cubic spline whose parameter runs by unit steps between control points, and every end condition is honoured.
When James applies it
When it is read, in any phase. curd is a definition, not a step of the hierarchy. A curve that csp3 matches must be defined before the curve that matches it.
Rules James adds
- One type group per
curd. A second group on the same command is refused with E0608, a recognised type that James does not support with E0603, and an unknown word with E0104. - A transformation word that follows the point list on the same line as the last
;is read as part of thecurd. A line that starts with;continues thecurd, so a transformation word after that;belongs to it too. Case153-curd-stray-semicolon-transshows both: its curve 3 ends one line with;and starts the next with; mx 1;, and the IR gives curve 3 the transformation row. - A word that starts a new line is read as the next command, whatever it is. A transformation word such as
mxthere is not a command, and James reports it as not recognized (E0105). - A
loopneeds at least three points. - A curve number below 1 is refused.
Diagnostics
- E0601: a curve that
csp3matches is not defined. - E0602: fewer than two points.
- E0603: a recognised curve type other than
lp3orcsp3. An unknown word is E0104. - E0605: the count of coordinates is not a multiple of three.
- E0606: the
csp3option is not recognised, or its end values are the wrong number. - E0608: a second type group.
- E0104: the curve number is missing or below 1.
Example
The script tests/corpus/153-curd-stray-semicolon-trans/input.tg, which make test runs:
curd 1 lp3 0 0 0 1 1 1 2 2 2;;
curd 2 lp3 0 0 0 1 1 1 2 2 2; ; mx 1;
curd 3 lp3 0 0 0 1 1 1;
; mx 1;
block 1 2;1 2;1 2;0 1;0 1;0 1;
endpart
The three curves are polylines. Curve 1 ends in two semicolons. Curve 2 has a stray ;, then mx 1 on the same line, which the IR holds as a transformation row. Curve 3 has two points, and its mx 1 is on the next line after a ;. The IR holds three curves and two transformation rows, and the part is unaffected.