sd
sd defines a surface by number, in any phase, for the projection commands to use.
Syntax
sd [name] number plan x0 y0 z0 xn yn zn
sd [name] number cy x0 y0 z0 xn yn zn radius
sd [name] number sp x0 y0 z0 radius
sd [name] number cone x0 y0 z0 xn yn zn radius angle
sd [name] number crx curve
sd [name] number cry curve
sd [name] number crz curve
sd [name] number sds surface_1 surface_2 ... ;
number is a whole number of 1 or more. name is optional. (x0, y0, z0) is a point and (xn, yn, zn) is a direction. cyli is another spelling of cy, and sphe of sp.
plan: the plane through the point, normal to the direction.cy: the infinite cylinder whose axis passes through the point along the direction, with the given radius.sp: the sphere about the point, with the given radius.cone: the infinite cone whose axis passes through the point along the direction.radiusis the radius of the cone at that point.angleis the half-angle of the cone, in degrees.crx,cry,crz: the 2D curve with the numbercurve, revolved about the x, y or z axis. The curve’s local origin is the global origin, and its local z direction is the named axis.sds: the union of earlier surfaces, as a plain list of numbers that ends with;.
What it does
sd adds one surface to the table. A projection command refers to it by number or by name. A surface is always Cartesian, even when the part that uses it is a cylinder part. A cone is the whole algebraic cone, both nappes. A revolved curve is bounded by the circles that its two ends sweep, so a node beyond an end projects onto that rim. For a composite from sds, a node is projected onto every member and keeps the nearest result. The geometry chapter shows each kind.
When James applies it
When it is read. sd is legal in the Control, Part and Merge phases.
Rules James adds
- A surface number that you define again replaces the surface. James does not warn, because redefining is the usual way to correct a mistake.
- A number below 1 is an error (E0104).
- A name must hold a letter and no spaces (E1008). Only its first eight characters count, and case is ignored. A name that you give to several surfaces makes a composite for any command that refers to that name.
spandcyneed a positive radius (E1005).coneneeds a radius that is not negative (E1007). A radius of 0 puts the apex at the point. The angle must lie strictly between -90 and 90 and may not be 0 (E1006).- A direction may have any length, as
0 0 5does for the z axis. A direction of length zero is an error that the engine reports when it builds the surface, and the run exits with 2. sdstakes a plain list of numbers. The colon shorthand1:3is an error (E0104). Every number in the list must name an earlier surface (E1000).crx,cryandcrzneed a curve thatldorlcchas already defined (E1001).- A surface kind that James knows of but does not support is an error (E1004). A word that is no surface kind at all, such as
torus, is E0104. - James keeps the parameter
%nextsrf: the highest surface number defined so far plus one. It changes after eachsd, so a script can define a surface under the next free number.
Diagnostics
- E1000: a surface in an
sdslist is not defined. - E1001: the curve of
crx,cryorcrzis not defined. - E1004: the surface kind is not supported.
- E1005: a radius is not positive.
- E1006: the cone angle is out of range.
- E1007: the cone radius is negative.
- E1008: the name is not valid.
Example
The script tests/corpus/139-sfi-name-composite/input.tg, which make test runs:
sd bowl 3 sp 0 0 0 1
sd BOWL 1 sp 3 0 0 1
sd 2 sp 6 0 0 1
block 1 3;1 3;1 3;0.5 1.5;0 1;0 1;
sfi -1;;; sd bowl
sfi -2;;; sd Bowl
endpart
The first two sd commands give two spheres the name bowl, in lower and upper case. The third sphere has no name. A sfi that refers to bowl or to Bowl gets a composite of the first two spheres, and the IR holds that composite as a fourth surface with the two spheres as members. The third sphere is not in it.