StageTools - Documentation (StageManager/Samples/Klein)

# The Klein Bottle in StageManager:

The following StageManager script uses CenterStage to generate and manipulate a parametrized Klein bottle.

The script asks CenterStage to start and load the file containing the Klein bottle (this file follows the script below), then select the "Klein" object in that file. The next four lines set up the background color and the initial viewpoint. The `Loop` command causes the main action for the script: a value between .15 and 1 is computed (depending linearly on the iteration count of the loop), and CenterStage is asked to set its slider to that value (the `w` slider controls how much of the surface to show). A frame is taken automatically at the end of each iteration of the loop.

## Klein.sm

```   CenterStage Start
CenterStage File "Klein.cs"
CenterStage ::cs::GUI Display "Klein"

Background {0.855 0.855 0.855}
Transform {Scale .8}
Transform {Translate {-.2 0 0}}
Transform {XZ \$pi/4}

Loop 35 {
set n [Percent .15 1]
CenterStage Klein Slider w Set \$n
}
```

## Klein.cs

### Script:

```   Domain {{pi/4 w*9pi/4 int(20w)+1} {-pi pi 10}}

Function {t u} {
if {\$t < 5*\$pi/4} {
let X = ( cos t, a (sin(2t) - 1) / 2, 0)
let V = (-sin t, a cos(2t), 0)
let U = B >< Unit(V)
let (x,y,z) = X + c cos(u) U + c sin(u) B
} else {
let r = c + a (1 + sin(2t - 3pi))/2
let (x,y,z) = (cos t, r cos u, r sin u)
}
}

let B = (0,0,1)

ColorFunction NormalizedT {(t-pi/4)/(2pi)}

Slider a 0 1 .5
Slider c 0 1 .15
Slider w .1 1
```

 StageTools Documentation web pages Created: 03 Jun 1996 Last modified: Nov 6, 2006 6:40:26 AM Comments to: `dpvc@union.edu`