Rock the view

PURPOSE:
The script below will rock the current view side to side a number of times, based on three simple parameters (default value):
The maximum angle to rock (30)
The number of times to rock (3)
The total number of steps (200)

DISCLAIMER:
This custom script is compatible with Discovery Studio 2.5. It is provided "as is" and is NOT supported by Accelrys nor is it warranted for any purpose whatsoever. The user assumes responsibility for any malfunctions or bugs.

REQUIREMENTS:
A molecule window containing something visible.

EXPECTED RESULTS:
As provided the view will rotate up to +15 degrees in the Y axis, then to -15 degrees and back to zero three times. As usual, you can cancel the running script by clicking on the "x" by the progress bar.

use MdmDiscoveryScript; my \$document = DiscoveryScript::LastActiveDocument(MdmModelType); die "No open Molecule Windows" unless \$document; use constant PI => 3.14159; # The maximum angle you want to rock to my \$maxangle = 30; # The number of full rocks you want to perform my \$numrocks = 3; # The number of steps to get there, decrease to speed up my \$steps=200; my \$lastY = 0; for my \$i (1..\$steps) { my \$angle = \$i*360*\$numrocks/\$steps; my \$newY = \$maxangle * sin(PI*\$angle/(180)); my \$deltaY = \$lastY - \$newY; \$document->RotateView(0,\$deltaY,0); \$lastY = \$newY; }