Curves and Sketches

A common concept for solid constructions is the extrusion of a 2-dimensional sketch. This section describes how sketches are created in trCAD.

Curves

In general, the curvedata type represents a 1-dimensional path in 2- or 3-dimensional space. The most simple curve may be a straight line that starts at a point p1 and extends to another point p2. To build such a curve, the curve link operator '->' is used:

Example

vector p1 = <[-3,2]>
vector p2 = <[5,7]>
curve c1 = p1 -> p2

In the same way the curve can be extended to a polygonal chain:

Example

vector p3 = <[2,6]>
vector p4 = <[4,-1]>
curve c2 = p1 -> p2 -> p3 -> p4

The curve can be closed to form a polygon by either explicitly returning to the starting point or by using the curve closure operator '-><-':

Example

curve c3 = p1 -> p2 -> p3 -> p4 -> p1
curve c4 = p1 -> p2 -> p3 -> p4 -><-

The oriented polygon from the example.

Note that curves are inherently oriented. It is possible to flip the direction in which the points are following each other by using the curve reversion operator.

Non-linear curve segments

In the previous example, the curve link operator '->' was used onto single points what caused them to be connected via straight lines. Sometimes, other types of connections are desired. This can be achieved by using one of the following curve segment constructors:

line_to line_dir arc
arc_to bezier

Example

curve c5 = <[3,0]> ->
           arc( <[0,0]>, PI * 0.5 ) ->
           line_dir( <[-2,0]> ) ->
           line_dir( <[0,-3]> )

A second curve example.

Curve segment constructors follows the idea, that each segment extends the curve, starting from the formerly last point point of it.

Sketches

In the context of trCAD, a sketch is a set of one or more 2-dimensional closed curves. A sketch can be formed by "adding" or "subtracting" multiple curves:

Example

curve c1 = <[8,0]> -> arc( <[0,0]>, 2PI )
curve c2 = <[4,3]> -> arc( <[3,3]>, 2PI )
curve c3 = <[-4,3]> -> arc( <[-3,3]>, 2PI )
curve c4 = <[5,-1.5]> -> arc_to( <[-5,-1.5]>, 5.5, false ) -> arc_to( <[5,-1.5]>, 5.2 )

sketch s = c1 - c2 - c3 - c4

A smiley contour sketch.

The moment a curve gets added to or subtracted from a sketch, it is projected onto the X/Y plane, thus enforcing the sketch to be 2-dimensional. This should be taken into account when working with curves that extend into three dimensions.

Sketches form the basis of solid extrusions. For this, some of the curves were subtracted to the sketch in the example instead of beeing added. A subtraction appends them in the same way as an addition does but also reverts their orientation at the same time, what can be seen from the arrows pointing into opposite directions. The reason for that is explained in more detail in this section.