Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Physics: Angular momentum (spinning top) testing

Scalar Tardis
SL Scientist/Engineer
Join date: 5 Nov 2005
Posts: 249
01-22-2006 21:24
And so in the continuing saga of my physics experiments, yes indeed, the engine does understand angular momentum.

A top-shaped object with a mass of 162, lying on the ground will right itself and lift off the ground at an Omega-Z of about 20 radians/sec



(NOTE: The physics for this is less than 2 ms. The high value in the image is from another sandbox person.)


The next question is how to make a rezzed/dropped spinning top immediately accelerate to at least 20.0 rads/sec before it can have a chance to tip over. :)

I have been using this, but without really knowing what sort of force it is applying:
llApplyRotationalImpulse(<0,0,50> * llGetMass(), FALSE);

It's unclear how to make something keep spinning at exactly a certain speed, but now that I know I can get the rotational speed with llGetOmega, that allows for a simple speed regulator feedback loop:

while Omega-Z < desired-speed, apply another rotational impulse
Beatfox Xevious
is THOUSANDS OF PEOPLE
Join date: 1 Jun 2004
Posts: 879
01-22-2006 21:58
From: Scalar Tardis
It's unclear how to make something keep spinning at exactly a certain speed
Have you tried using llTargetOmega? Haven't tested it myself, but the Wiki says it becomes a server-side function when used on physical objects.

(though it also says it can end up doing... interesting things with said objects :p )
_____________________
My Beatworks: Zephyr Chimes wind chimes, the KanaMaster Japanese kana tutor, and the FREE Invisibility Prim Public. Look for them at the Luskwood General Store in Lusk (144, 165).

"You have been frozen. You cannot move or chat. A pony will contact you via instant message (IM)."
- mysterious system message I received after making off with Pony Linden
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-23-2006 02:35
From: Scalar Tardis
The next question is how to make a rezzed/dropped spinning top immediately accelerate to at least 20.0 rads/sec before it can have a chance to tip over. :)
dunno if this cheat would work - but should be worth a try:

Use llSetStatus to prevent rotation around the two horixontal axes before packaging the top. When it rezzes it would then be constrained to the vertical just long enough to get your rotation going - after which you drop the constraints.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
01-23-2006 05:52
Hi Scalar, although not quite as critical as yours I've got something I want to rotate at an even speed as mass changes etc. It's basically a spinning seat and as people get on and off the mass changes, inevitably...

llTargetOmega is a nightmare for this - every time an av starts the typing anim it resets the spin, so physical twisting it was.

I ended up with a timer event and llGetOmega, setting a positive or negative rotational impulse if I was away from the target speed. It's not 100% smooth, if I'm just under and apply a 'kick' I can be moderately obviously over and then slow down rather abruptly, but it's quite acceptable 95%+ of the time - I think I'm the only person that's noticed the jump in speed and that might be the fact that I know it can happen, so I'm aware of it.

Anyway, the checking and applying an acceleration to get the steady speed approach works nicely.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
01-23-2006 10:10
From: Scalar Tardis

It's unclear how to make something keep spinning at exactly a certain speed


Well, I see you multiplied by llGetMass(), which works for lateral movement. The reason for that is that for translative movement, Force = Mass * Accel, and Impulse = Mass * Velocity. For angular movement, it's Torque = Moment-of-Inertia * Accel, or Angular-Impulse = Moment-of-Inertia * Angular-Velocity. I've been chafing at the lack of a llGetMoment() function in my own work recently... I know the physics engine has to know about moments of inertia to handle angular movement, but LSL doesn't give us a way to get it.

Moment of inertia is kind of like mass, but it factors in the distances that pieces of the object are from the center. Basically, it's a sum of all the little bits of an object, weighted by their distance from the center of the object. It takes into account the fact that it's going to take more torque to spin a 1-meter-long bar of matter than a sphere of matter, even if both objects have exactly the same mass.

If you want to calculate the moment of inertia yourself, you can try. Normally you'd do an integral over the entire object's mass, adding up the mass of each part times its distance from the center, but primitives give us a way to cheat. Just find the mass of each primitive, and multiply it from the distance that its _center of mass_ is from the center of mass of the link set (in meters). This'll require some delinking and llGetCenterOfMass() calls and some math... but I think it should work. Take the resulting number, multiply it by a velocity in radians per second, and pass it to llApplyRotationalImpulse... and I _think_ it should set that rotational velocity. Post back here if this works ;)
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
01-23-2006 17:48
I made a gyro top over a year ago and i still
see ppl use it in the sandbox now and again
i used targetomega and it is up to speed
as soon as it rez. im at work now but ill
drop you a copy when i get home :)
-LW