You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
llApplyRotationalImpulse(vector impulse, integer local)
Apply an instant change to the angular momentum of a physical object. It has no effect on non-physical objects or on attachments.
A vector specifying the impulse to apply, which will add to the object's current angular momentum. The vector's direction indicates the impulse's axis and its length indicates the magnitude. The units of the angular impulse vector seem to be lindograms·m²/s. Like in the real world, the effect on the angular velocity depends not only on the mass of the object, but also on its shape, as it's the product of moment of inertia (which itself depends on the shape of the object) and angular velocity.
Boolean value indicating whether the impulse
axis' coordinates are local to the root prim (if TRUE) or in sim coordinates (if FALSE).
When TRUE, the impulse
axis' coordinates are local to the root prim. For example, if impulse
is <1, 0, 0> and the X axis of the root prim is looking northwest, then the impulse will have its axis oriented in the northwest direction, aligned with the root prim's X axis.
When FALSE, the vector specifies sim coordinates, where positive X is east, positive Y is north, positive Z is up, and vice versa for negative; for example, if impulse
is <-1, 0, 0>, the rotational impulse will have its axis pointing west, no matter how the root prim is oriented.
llGetOmega
will not return a value with a magnitude greater than 62.8 rad/s (about 599.7 rpm).// Assuming a 1x1x1 cube with no gravity and no initial angular velocity, // the following line will make it spin at an initial angular velocity of 0.6 rad/s // over its local Z axis: llApplyRotationalImpulse(<0, 0, 1>, TRUE); // 0.6 rad/s is derived from the moment of inertia of a cube spinning over its // axis (m*l^2/6, where l is the length of the side) and the impulse applied. // The mass of such a cube is 10 lindograms. Measurement with llGetOmega // indicates that it works this way.
This example verifies the physical accuracy of llApplyRotationalImpulse on an undeformed box of any dimensions. Moment of inertia varies with shape, so most deformations affect the results.
float IMPULSE = 1.31; // change this value to any value to test default { touch_start(integer n) { // Disable gravity, enable physics, wait for the setting to take effect llSetPhysicsMaterial(GRAVITY_MULTIPLIER, 0, 0, 0, 0); llSetStatus(STATUS_PHYSICS, TRUE); llSleep(0.5); // Begin the test llApplyRotationalImpulse(<0, 0, IMPULSE>, TRUE); llSleep(0.03); // let a simulator frame pass // NOTE: Rotational friction is applied almost instantly, meaning the // returned value will be less than the theoretical one most of the // times. Sometimes we're lucky and get the actual value. vector omega = llGetOmega(); // Disable physics again, return to zero rotation. llSetStatus(STATUS_PHYSICS, FALSE); llSetRot(<0, 0, 0, 1>); // Calculate and report results. vector size = llGetScale(); // Predicted omega is impulse divided by moment of inertia. // Moment of inertia of a box rotating on its z axis is m*(size.x²+size.y²)/12. float predicted = IMPULSE/(llGetMass()*(size.x*size.x+size.y*size.y)/12); llSay(0, "Theoretical omega: " + (string)predicted + ", actual omega: " + (string)omega.z + ", difference:" + (string)(predicted - omega.z) ); } }
llApplyImpulse
is similar but for linear momentum instead of angular.llSetAngularVelocity
applies the rotational impulse necessary to set the given angular velocity for an object.llGetOmega
obtains the current angular velocity of the object.llTargetOmega
tries to keep a constant angular velocity.llSetTorque
applies an angular force (a torque) to an object continuouslyllSetForce
is the linear equivalent to llSetTorque.llSetForceAndTorque
sets both force and torque at the same time.llSetVelocity
and llGetVel
are the linear equivalents of llSetAngularVelocity/llGetOmega.llGetMass
returns the mass in Lindograms of an object.llGetMassMKS
returns the mass in kilograms of an object. Most LSL functions use Lindograms, so this function is of limited use in physics calculations.llVecNorm
to obtain a unit vector from a given one.