Next: Polygon sweeps, Previous: Polyline sweeps, Up: Swept objects

#### 2.7.3 Nested sweeps

When the center point of rotation is omitted, the origin is assumed. When a point has only two coordinates, they are taken as x and y, with z=0 assumed. A toroid is therefore obtained with this code.

      def n_toroid_segs 20   def n_circle_segs 16
      def r_minor 1          def r_major 1.5
      sweep { n_toroid_segs, rotate(360 / n_toroid_segs, [0,1,0]) }
        sweep { n_circle_segs, rotate(360 / n_circle_segs, (r_major,0,0)) }
          (r_major + r_minor, 0)

For intuition, the idea of the code is to sketch a circle to the right of the origin in the xy-plane, then rotate that circle “out of the plane” about the y-axis to make the final figure. This produces the following. (A view rotation and some axes have been added.)

This example also shows that the swept object may itself be another `sweep`. In fact, it may be any `sketch` expression that results in a list of one or more points or, alternately, a list of one or more polylines and polygons. The latter kind of list can be created with a `{ }`-enclosed block, perhaps following a `put` or `repeat`.