Next: Scale Up: Transformations Previous: Shift

## Stretch

The stretch function can be specified in two ways:

Either with three variables: the amount the object is to be stretched in the x, y and z directions.

```
object stretch(double xstretch, double ystretch, double zstretch,
object x);```

Or you can specify a vector which contains the amount the object is to be stretched in the x, y and z directions.

`  object stretch(vector stretchvec, object x);`

The object is stretched by multiplying the x coordinates of the object by the x stretch factor, the y coordinates of the object by the y stretch factor and the z coordinates of the object by the z stretch factor. NB: This causes the object to shift its location if it is not at the origin. Note also that no stretch is a stretch by 1, not by 0.

The example is shown in figure 2

Example

`  red_torus = stretch(2,3,1,red_torus);`

Or

```  vector stretch_amount = {2, 3, 1};
red_torus = shift(stretch_amount,red_torus);```

Figure 2: Stretching a torus (2,3,1).

Sophie Day
Fri Feb 20 15:47:19 NZDT 1998