// LSL script to rotate an orbiting object
// If the rotating object is two linked spheres, the result
// can resemble lunar motion around a planet (depending on
// timer settings and network performance, etc.).
vector rotationCenter;
rotation Z_15;
default
{
state_entry()
{
llSetTimerEvent( 3.0 );
vector startPoint = llGetPos();
rotationCenter = startPoint + < 3,3,3 >;
Z_15 = llEuler2Rot( < 0, 0, 15 * DEG_TO_RAD > );
}
touch_start(integer total_number )
{
llTargetOmega( < 0, 1, 1 >, .2 * PI, 1.0 );
}
timer()
{
vector currentPosition = llGetPos();
vector currentOffset = currentPosition - rotationCenter;
// rotate the offset vector in the X-Y plane around the
// distant point of rotation.
vector rotatedOffset = currentOffset * Z_15;
vector newPosition = rotationCenter + rotatedOffset;
llSetPos( newPosition );
}
}