Scripted Mount Demo #1
======================
:source-highlighter: highlight.js

== Summary ==
The focus of this demo is to show the user how to use the "scriptable"
mount feature in DIRSIG.  This is one of two dynamic mounts in DIRSIG
that are driven by the user (the second is the "tabulated" (data-driven)
mount).  The user supplies a script that is executed during the DIRSIG
simulation that computes the mount pointing as a function of time.

== Inputs ==
=== Scene ===
The scene is the simple scene containing the North and East arrows with
the shadow pole.

=== Platform ===
The platform contains a single camera with a small 128 x 128 array.
The platform itself is stationary, but the mount changes the platform
relative pointing of the camera as a function of time.

The script for the mount is stored in the `demo.platform` file.
A new script can be imported into the platform file by right-clicking
in the script editor in the GUI and selecting the *Import* item. A
copy of the script is included below:

----
// whisk scan parameters
startAngle =  5.0 * (Math.PI / 180.0);
stopAngle  = -5.0 * (Math.PI / 180.0);
spinFactor = 6;

// compute the current fraction of a full scan
fraction = 0.5 - 
    Math.cos( this.currentScanFraction * spinFactor * 2.0 * Math.PI ) / 2.0;

// compute the current scan angle for this fraction
scanAngle = startAngle + fraction * ( stopAngle - startAngle );

// compute the current spin angle for this fraction
spinAngle = this.currentScanFraction * 2.0 * Math.PI;

// compute the rotation transform
transformResult = 
    this.matrixMultiply( this.makeZRotationMatrix( spinAngle ),
                this.makeXRotationMatrix( scanAngle ) );
----

The script makes a "rosette" pattern.  This is accomplished by
creating a sinusoidal oscillation that is rotated about the Z
axis.  The key input parameter provided by DIRSIG at run-time is 
`this.currentScanFraction`, which is the current unitless fraction 
of the scan that must be computed.  This allows the scan rate to
be handled external to the script (enabling things like master and
slave clocking, etc.).  The user must set the `transformResult`
variable to contain an 4x4 affine transform for the current scan
fraction.

=== Simulation ===
The scan rate for the mount is 1 Hz and the collection task lasts
1 second.  This allows the mount to complete one full scan.  The
camera is capturing at 100 Hz, so 100 frames will be generated
during the simulation.

.Animation of a complete scan
image::video.gif[]
