Pendulums and rotational impulses...
|
|
Thom Perun
Registered User
Join date: 13 Sep 2005
Posts: 31
|
08-15-2006 20:43
I want to create a pendulum. The best thing I thought to do was to find out the resting rotation (It pointing straight down) then using some good old physics from school apply a rotational impulse in one direction, then the reverse, repeat and decrease force. Here's the thing... I've been wracking my brain on trying to figure out the math for find a vector force to go towards a certain rotation... You've got rotResting and rotCurrent, and want to apply a force in a direction to go towards rotResting a pass it... like llApplyRotational(llGetMass() * vectorDirection);
Does this make sense? Any ideas on the math?
|
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
08-15-2006 22:17
A pendulum is basically a swing, and all the swings I've seen or heard about in SL have been non-physical, so I doubt whether you could actually make a realistic looking physical pendulum. For a better discussion, search this forum for "swing"; there have been many other people asking essentially the same thing.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
08-16-2006 02:51
From: Thom Perun Any ideas on the math? http://www.myphysicslab.com/pendulum1.html ? note since joints have been ripped out of SL, it'd likely need to be done with manually setting rotation at suitable intervals... o.O;
|
|
Thom Perun
Registered User
Join date: 13 Sep 2005
Posts: 31
|
08-16-2006 07:08
I'm still interested in trying to make this work in a physical manner. I can set the bupyancy to 1, and "theoretically" if I only apply rotational impulses, it should not move from is position. I also think I can make it look real by adding in a little bit of friction via an oposite inpulse, hence making it look like a swing and decelerate on the upwards climb.
This is the only bit of math that I am lacking... I have a current rotation A and a target rotation B, I'm trying to figure out the vector force that needs to be applied to an object currently rotated to A to get it to pass through the rotation B... The reast is easy math...
|
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
08-16-2006 09:01
Smooth Rotation/Oscillation can be done without tons of SetRots. My fully configure able script is complete. unfortunatly I cannot realse it due to a Bugged function on SL part. My my work around cause a little more data to be forced from the servers therefore Lag.
it can be set up as Link, Touch, Listen, and Collide, enable. Start and Stop sounds as well as moving sounds. AnyOne, Owner, Group response to commands. Angle to rotate which can be over 180 or 360 degress, heck 30000 degrees if you want. Time to open as well as time to pause at the start and end positions. Can be set to Oscillate, Wait a certian time to auto close, or stay open until command is give. Chose from which local axis of object to rotate around and can be position at any angle in world.
Now if LL would only fix the bugged function it would be nice. Maybe I should realse it to force them to fix it quicker. grrr!
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
I haven't tried this, but...
08-16-2006 09:17
From: Thom Perun
Does this make sense? Any ideas on the math?
A pendulum doesn't really *need* outside force other than gravity, does it? Move the pendulum into starting position, and then just let go. Gravity dos the rest. i you want it to go on forever, then you would need to give it a little push each swing, but that could be any push perpendicular to the Axis. Does SL have friction and wind resistance? If not, it should go forever. Remember, I have no SL experience to speak of. I am thinking real world physics.
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
Not fully configurable quasi-physical script
08-16-2006 09:40
This one sets a timer every update seconds. You cna recalculate the position of the pendulum/swing there. It listens for commands on channel 2, and starts and stops on touch. //Public Domain from Lee Ponzu, if that is his real name 8-)
integer ch = 2; // Use /2 <cmd> float update = .25; //How often to update the swing
default { state_entry() { llOwnerSay("The swing is still."); llListen(ch, "", llGetOwner(), "swing" ); } listen(integer c, string n, key o, string m ) { llOwnerSay( m ); state swinging; } on_rez(integer n) { state default; }
touch(integer total_number) { llOwnerSay( "Touched"); state swinging; } }
state swinging { state_entry() { llOwnerSay("Start swinging..."); llSetTimerEvent( update ); llListen(ch, "", llGetOwner(), "noswing" ); } timer() { llOwnerSay("...swing..."); // adjust swing here... } touch(integer n) { state default; } listen(integer c, string n, key o, string m ) { llOwnerSay( m ); state default; } }
|
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
08-16-2006 09:57
From: Lee Ponzu A pendulum doesn't really *need* outside force other than gravity, does it? Move the pendulum into starting position, and then just let go. Gravity dos the rest..... Technically yes. If the old joint method was still around you could have the object just hang. Other problem that occurs with physics rotation. it rotates around the Object or Link of Objects center of mass and not the non-physical roation axis. So you would have to set up invisble object to counter balance the mass of the pendulum which is alway fun to figure out. Then there is always the old Ring around a cylinder for a pivot point. Well those sometime go a muck and come of the pivot and end god knows where.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-16-2006 11:00
From: Lee Ponzu A pendulum doesn't really *need* outside force other than gravity, does it? Move the pendulum into starting position, and then just let go. Gravity dos the rest. ... Remember, I have no SL experience to speak of. I am thinking real world physics. A pendulum needs a hinge force as well as gravity. Otherwise it would accelerate linearly toward the ground and there would be no net torque to cause it to rotate.
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
08-16-2006 11:28
Here's an idea:
You could make the "swing" physical, with llSetForce( <0,0,9.8> * llGetMass(), FALSE ) and the part above the center 100% transparent. Then it should just "float" there. Now you can make it volume detect so it can collide with stuff. Then use a ring to tether it - not for support, but so you can use llMoveToTarget to recenter it when you get a collision.
If someone sits on it you'll have to rescale a prim at the opposite end to match their mass, but avatars don't mass much.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-16-2006 11:45
Hmm. I'm not sure the engine uses linearly applied forces to calculate torque (except maybe for ground collisions?). If so, do things like, 'llSetForce()', 'llApplyImpulse()', and 'llPushObject()' always apply at the center of gravity (CG)? I know when you sit on a physical object that doesn't have a flat bottom it will tend to fall over, but how much of this is a realistic physical calculation and how much of it is just a dirty hack? Hmm....
|
|
Thom Perun
Registered User
Join date: 13 Sep 2005
Posts: 31
|
08-16-2006 12:37
Looks like dirty hacking the physics to me.
I've been playing around here... Took me a few tries to realise the object need to be perfectly balanced on it's physical center.
But the wierd thing is that after it gets it's rotational impulse aplied, it will come to a rotational stop, will start to fly off in the direction of the force vector, so it is not applying the rotational force as "Human Physics" would think it would work.
Looks like creating a pendulum using rotational impulses will not be possible on the size of object I am using... Was making a swinging log trap that in all was about 10m cubed.
Any idea if our Linden friends will be bringing joints back? Was it too much lag?
|