ld
ld defines a 2D curve by number, in any phase, from straight and circular segments.
Syntax
ld number segment [segment ...]
Each segment is one of:
lp2 x z [x z ...] ;
lar x_end z_end radius ;
number is a whole number of 1 or more. A curve lives in a local plane with the coordinates x and z. A surface that revolves it, crx, cry or crz, reads x as the distance from the axis and z as the position along it.
What it does
The segments form one chain. Each segment starts where the one before it ended.
lp2draws straight lines through its points. If its first point is not where the chain ended, James first draws a line to it.lardraws a circular arc from where the chain ended to the point(x_end, z_end).radiusis the radius of the circle. The arc is the short one. A positive radius turns counter-clockwise, with the centre on the left of the chord from start to end. A negative radius turns clockwise.
When James applies it
When it is read. ld is legal in the Control, Part and Merge phases.
Rules James adds
- A number below 1 is an error (E0104). So is a curve of more than 256 segments.
- An
lp2with a single point and no point before it only sets the start of the chain. It is legal when a later segment of the sameldcontinues from it, aslardoes in the example. A chain that never gets past that one point is an error (E1002). - After a start, an
lp2of one point draws a line from where the chain ended to that point. Anlp2of one point that repeats the end point exactly draws nothing. - An
lp2list of two or more points that begins at the end point is used as written. Otherwise James puts the end point in front of it. - An
lp2with a number of coordinates that is not a multiple of 2 is an error (E1002). - A
larwhose radius is too small for its chord is an error (E1003). James accepts a radius of exactly half the chord, which is a semicircle, and the sign chooses its direction. Alarwith no point before it is the same error. - A segment type that James knows of but does not support is an error (E1009). A word that is no segment type at all, such as
arc, is E0104 in place of the first segment. After a complete segment such a word ends theldand is read as the next command, which James reports as not recognized (E0105).
Diagnostics
- E1002: an
lp2has too few points or an odd number of coordinates. - E1003: a
larradius is too small, or it has no start. - E1009: the segment type is not supported.
- E0104: the first segment type is no word James knows, or the number is below 1.
- E0105: a word that is no segment type follows a complete segment, so it ends the
ldand is not a command.
Example
The script tests/corpus/122-sd-crx-accept/input.tg, which make test runs:
ld 1 lp2 0 0 1 1;
sd 1 crx 1
The ld defines curve 1 as one line from (0, 0) to (1, 1). The sd then revolves it about the x axis as surface 1, a cone. The IR holds the curve with one lp2 segment and the surface with kind crx that refers to the curve.