sd

sd defines a surface by number, in any phase, for the projection commands to use and for edge and patch to attach to.

Syntax

sd [name] number plan x0 y0 z0 xn yn zn
sd [name] number xyplan trans ;
sd [name] number yzplan trans ;
sd [name] number zxplan trans ;
sd [name] number pl2 point point
sd [name] number pl3 point point point
sd [name] number pl3o point point point offset
sd [name] number iplan a b c d
sd [name] number cy x0 y0 z0 xn yn zn radius
sd [name] number xcy radius trans ;
sd [name] number ycy radius trans ;
sd [name] number zcy radius trans ;
sd [name] number cy3 x1 y1 z1 x2 y2 z2 x3 y3 z3
sd [name] number cyr2 x1 y1 z1 x2 y2 z2 radius
sd [name] number cyr3 x1 y1 z1 x2 y2 z2 x3 y3 z3 radius
sd [name] number sp x0 y0 z0 radius
sd [name] number cone x0 y0 z0 xn yn zn radius angle
sd [name] number cn2p x0 y0 z0 xn yn zn r1 t1 r2 t2
sd [name] number er x0 y0 z0 xn yn zn r1 r2
sd [name] number pr x0 y0 z0 xn yn zn r1 t1 r2 t2 r3 t3
sd [name] number ts x0 y0 z0 xn yn zn r1 t r2
sd [name] number crx curve
sd [name] number cry curve
sd [name] number crz curve
sd [name] number cr x0 y0 z0 xn yn zn curve
sd [name] number cp curve trans ;
sd [name] number rule2d y1 curve1 y2 curve2 trans ;
sd [name] number swept base direction curve1 a1 [curve2 a2 ...] ; trans ;
sd [name] number rule3d curve1 curve2 trans ;
sd [name] number crule3d curve1 curve2 trans ;
sd [name] number pipe curve r1 s1 [r2 s2 ...] ; trans ;
sd [name] number blend3 curve1 curve2 curve3 trans ;
sd [name] number blend4 curve1 curve2 curve3 curve4 trans ;
sd [name] number r3dc x0 y0 z0 xn yn zn curve begin end trans ;
sd [name] number sds surface_1 surface_2 ... ;
sd [name] number intp surface_1 surface_2 fraction

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. point is a point in a coordinate system: rt x y z, cy rho theta z or sp rho theta phi, the angles in degrees. trans ; is a list of the operators of tr followed by ;; the ; is required even when the list is empty. direction in swept is r or l.

Six kinds have another spelling that reads as the same kind: cyli for cy, sphe for sp, plane for plan, xzplan for zxplan, iplane for iplan and toru for ts. torus is James’s own spelling of ts, which TrueGrid does not accept.

  • plan: the plane through the point, normal to the direction.
  • xyplan, yzplan, zxplan: the plane z = 0, x = 0 or y = 0, moved by the list.
  • pl2: the plane through the first point, normal to the line to the second.
  • pl3: the plane through three points, normal by the right-hand rule through them in order.
  • pl3o: the plane of pl3, moved along its normal by offset.
  • iplan: the plane a x + b y + c z = d.
  • cy: the infinite cylinder whose axis passes through the point along the direction, with the given radius.
  • xcy, ycy, zcy: the cylinder of the given radius about the x, y or z axis, moved by the list.
  • cy3: the cylinder through three points of a cross section, with its axis through the centre of the circle they fix, normal to its plane.
  • cyr2: the cylinder of the given radius about the axis through two points.
  • cyr3: the cylinder of the given radius whose axis passes through the centre of the circle through three points, normal to its plane.
  • sp: the sphere about the point, with the given radius.
  • cone: the infinite cone whose axis passes through the point along the direction. radius is the radius of the cone at that point. angle is the half-angle of the cone, in degrees.
  • cn2p: the infinite cone about the axis whose radius is r1 at the distance t1 along the axis from the point and r2 at t2.
  • er: the ellipsoid of revolution about the axis, centred at the point, with the semi-axis r1 across the axis and r2 along it.
  • pr: the paraboloid of revolution about the axis whose radius is the quadratic in the distance t along the axis through the three points (r1, t1), (r2, t2) and (r3, t3).
  • ts: the torus about the axis. The circle of radius r1 about the axis in the plane at distance t from the point is the centre line of a tube of radius r2.
  • crx, cry, crz: the 2D curve with the number curve, 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.
  • cr: the 2D curve revolved about the axis through the point along the direction. The curve’s x is the distance from the axis and its z the distance along it from the point.
  • cp: the 2D curve in the x-z plane, extended along y, moved by the list.
  • rule2d: the ruled surface between 2D curve 1 placed in the plane y = y1 and 2D curve 2 in the plane y = y2. A negative curve number reverses that curve.
  • swept: the surface swept by cross sections, each a 2D curve, placed along the 2D curve base at the fractions a1, a2, … of its length, from 0 to 1, with direction choosing the base’s right (r) or left (l) side.
  • rule3d, crule3d: the ruled surface between two 3D curves, a negative number reversing a curve. crule3d rules in cylindrical coordinates about the z axis.
  • pipe: the tube about a 3D curve with the radius r1 at the fraction s1 of the curve’s length, r2 at s2, and so on. Its sides are its two rims, the circles at the two ends of the curve, unless it is a closed tube: a pipe on a closed curve whose radius is the same at both ends has none.
  • blend3, blend4: the patch bounded by three or four 3D curves, given in any order. The first curve given stays first, and James tries every order and direction of the others and keeps the loop whose corner gaps, the closing one included, add up to least; a tie goes to the earlier candidate.
  • r3dc: the 3D curve revolved about the axis through the point along the direction, from the angle begin to the angle end in degrees. It has four sides for a turn under 360 degrees, and two, the circles that the generatrix’s ends sweep, for a full turn or more; a full turn of a closed generatrix is a closed tube and has none.
  • sds: the union of earlier surfaces, as a plain list of numbers that ends with ;.
  • intp: the surface a fraction of the way from the first surface to the second, each an earlier surface; the surface ssf and ssfi require. A point of the first surface is carried toward its nearest point on the second by the fraction, between 0 and 1, and a node projected onto the intp surface meets the nearest point of the surface those carried points make. James finds that point by a search over the first surface that starts from the node’s own projection onto it, so it is the nearest point near that start: where the carried surface folds back through the first surface or has more than one sheet, the point can be a local nearest point, and a run can stop with an error that an edge did not settle; a node that settles on a local nearest point is written with no message. Either surface may be a composite or another intp.

What it does

sd adds one surface to the table. A projection command refers to it by number or by name, and edge and patch use its sides. 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 surfaces built from curves are bounded: a node beyond their edge projects onto the edge, and the surface is found by a local search, so where it folds back on itself a node can settle on a local nearest point. The kinds that have sides, and how the sides are numbered, are in the geometry chapter, which also describes 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.
  • A radius must be positive (E1005): that of cy, xcy, ycy, zcy, cyr2, cyr3 and sp, both of er and ts, and every radius of pipe.
  • cone needs 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).
  • cn2p needs r1 different from r2 and t1 different from t2, pr three different t values, and r3dc an end angle different from its begin angle (E1011).
  • pl2 and cyr2 need two different points, and pl3, pl3o, cy3 and cyr3 three points that do not lie on a line (E1010).
  • A point of pl2, pl3 and pl3o begins with rt, cy or sp (E1012).
  • A fraction of swept or pipe lies between 0 and 1, and direction is r or l (E1013). The fractions of swept must increase and those of pipe may not decrease; the engine reports a list that breaks this when it builds the surface.
  • A direction may have any length, as 0 0 5 does 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.
  • sds takes a plain list of numbers. The colon shorthand 1:3 is an error (E0104). Every number in the list must name an earlier surface (E1000).
  • A curve of a surface must be defined before the sd that uses it: a 2D curve that ld or lcc has defined (E1001) or a 3D curve that curd has defined (E1014).
  • A kind that takes trans ; ends with it, and the ; is required (E0104 when it is missing). The list must be a similarity: a scale of one axis alone makes the engine stop with an error that names the operator. tf, ftf, rxy, ryz and rzx are refused (E0503).
  • James ignores a ; after any kind’s arguments that the kind does not need.
  • A pipe takes at most 64 radius and arc-length pairs, and a swept surface at most 64 sections after its base. One more is an error at the number that would begin it (E0104): 'sd' expects at most 64 pipe radius and arc-length pairs, got 65, or 'sd' expects at most 64 swept sections, got 65.
  • A surface kind that James knows of but does not support is an error (E1004): nurbs, igess, igesp, function, csps, bsps, nrbs, hermite, mesh, face, faceset, poly, stl and bstl. A word that is no surface kind at all is E0104.
  • James keeps the parameter %nextsrf: the highest surface number defined so far plus one. It changes as soon as sd has read the surface number, so a script can define a surface under the next free number, and an sd that is then refused moves it too.

Diagnostics

  • E1000: a surface in an sds list is not defined.
  • E1403: an intp fraction lies outside 0 to 1.
  • E1001: a 2D curve of the surface is not defined.
  • E1014: a 3D curve of the surface is 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.
  • E1010: the points of a plane or cylinder coincide or lie on a line.
  • E1011: the parameters of cn2p, pr or r3dc do not fix the surface.
  • E1012: a point begins with a word that is no coordinate system.
  • E1013: a fraction of swept or pipe is outside 0 to 1, or the direction is not r or l.
  • E0503: a transformation operator is unknown, malformed or refused.

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.

The script tests/golden/067-conics/input.tg, which make test runs:

c Three blocks, each with one face projected onto a conic of revolution:
c part 1 onto a cone through two (r, t) points (cn2p), its face inside the
c cone moved outward onto it; part 2, hung below the origin so it stands
c clear of part 1, its bottom face onto the lower cap of an ellipsoid (er)
c with r1 = 2 across the axis and r2 = 1 along it; part 3 onto a paraboloid (pr)
c through three (r, t) points, the dictionary's own example
c r = 0.75 (t - 7)^2, whose generatrix climbs steeply away from the axis
c above its vertex t = 7, so the block's top face, across the axis, takes
c it (a face along the axis would bunch onto a narrow band of it).
sd 1 cn2p 0 0 0 0 0 1 1 0 2 2
sd 2 er 0 0 0 0 0 1 2 1
sd 3 pr 0 0 0 0 0 1 3 9 0 7 12 3
block 1 3;1 3;1 3;0.2 0.8 -0.5 0.5 0 1
sfi -2;;;sd 1
endpart
block 1 3;1 3;1 3;-0.5 0.5 -0.5 0.5 -1.5 -0.5
sfi ;;-1;sd 2
endpart
block 1 3;1 3;1 3;1 2.5 -0.75 0.75 7.5 8.4
sfi ;;-2;sd 3
endpart
merge
neutral
write

Three blocks, each with one face projected onto a conic of revolution: a cone through two radii (cn2p), an ellipsoid (er) and a paraboloid through three points (pr). The golden case writes 81 nodes and 24 elements.

See also

  • sf: projects onto a surface.
  • edge and patch: attach edges and faces to a surface’s sides.
  • ld: defines the 2D curves that the revolved, extended, ruled and swept surfaces use.
  • curd: defines the 3D curves that the ruled, piped, blended and revolved surfaces use.
  • Geometry: the surface kinds, their sides and the curves.

James 0.8.0.

This site uses Just the Docs, a documentation theme for Jekyll.