llForceOfFriction(float U, float Fn);
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
11-05-2006 17:50
First off, I would like to say my understanding of the mechanics of friction is limited. None the less, I would like to submit for review, a peice which calculates the force of friction on prims. This script does not allow for variable coefficients of friction  , it baselines it at 0.5. This functionality will be added later if the script proves to handle other circumstances well enough. It was an attempt of mine to use rotation force in the calculation to add a bit more realism and accuracy. All improvments, optimizations and questions are welcome. // llForceOfFriction(float U, float Fn) Script // Created by: Cid Jacobs // Original by: Cid Jacobs // Last Updated: 11-04-06 // Notes: Speak with Cid Jacobs about any concerns. // // //--------------------Globals //Normal Force float Fn; //Force of Friction float FoF; //Coefficient of Friction (needs to be remodeled for accuracy) float U = 0.5; // // //--------------------User Defined Function //Calculate Normal Force float llForceNormal(float x, rotation y, float z) { //Normal Force is Equal to Mass * Rotational Force * Gravity Fn = -x * llTan(llAngleBetween(y,ZERO_ROTATION)) * z; //Rational Normal Force Check if(Fn < 0.0) { //Equalize if Offset by Rotational Force Fn = -Fn; } //No Rotational Force Check if(Fn == 0.0) { //Normal Force Equation, Excluding Rotational Force Fn = -x * z; } return Fn; } //Calculate Force of Friction float llForceOfFriction(float U,float Fn) { //Force of Friction is Equal to Coefficient of Friction * Normal Force FoF = U * Fn; //Return Force of Friction return FoF; } // // //--------------------States //Mandatory Default State default { //Triggered By The Start Of Agent Clicking touch_start(integer num_detected) { //Enter Normal Force Calculation Function llForceNormal(llGetMass(),llGetRot(), -9.8); //Enter Force of Friction Calculation Function llForceOfFriction(U,Fn); //Output on Open Channel llSay(0,(string)FoF); } }
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
Puzzled.
11-05-2006 17:59
Why are naming your functions as Linden Lab functions? Linden Lab uses the ll at the beginning of the name to designate that a name is a Linden Lab built-in library function.
_____________________
- ninjafoo Ng Says:
November 4th, 2006 at 7:27 am We all love secondlife so much and were afraid that the magic will end, nothing this good can ever last…. can it?
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
11-05-2006 18:02
From: Llauren Mandelbrot Why are naming your functions as Linden Lab functions? Linden Lab uses the ll at the beginning of the name to designate that a name is a Linden Lab built-in library function. I do this with all of my weather functions and my physics functions, its wishful thinking.
|
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
11-05-2006 18:15
I do this with all of my weather functions and my physics functions, its wishful thinking.Oh.
_____________________
- ninjafoo Ng Says:
November 4th, 2006 at 7:27 am We all love secondlife so much and were afraid that the magic will end, nothing this good can ever last…. can it?
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
11-05-2006 18:20
Although, I guess it should be llGetForceOfFriction, but that really isn't important. Any questions about the code itself?
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
11-06-2006 04:35
From: Cid Jacobs Although, I guess it should be llGetForceOfFriction, but that really isn't important. Any questions about the code itself? or perhaps cjGetForceOfFriction? Maybe I'll start using nnGetSomeValue to denote functions I have written but anyhoo, onto the script. If I'm not mistaken the physics of friction between two objects (ignoring fluid mechanics for now) is dependent on a cooefficient of friction which varies for each object-object interface, the area of contact, force of contact (as I see you've worked out normal force). One thing to note is that the coefficient of friction is different for static objects and objects in motion, i.e. once you start something moving it requires slightly less force to counteract friction and keep it moving. Just some ideas for you to look into =).
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
11-06-2006 11:38
From: nand Nerd If I'm not mistaken the physics of friction between two objects (ignoring fluid mechanics for now) is dependent on a cooefficient of friction which varies for each object-object interface, the area of contact, force of contact (as I see you've worked out normal force). One thing to note is that the coefficient of friction is different for static objects and objects in motion, i.e. once you start something moving it requires slightly less force to counteract friction and keep it moving. Just some ideas for you to look into =). You are correct about FoF being dependent on a variable coefficient, I made it a static amount at this time to focus on making sure the rest of the code itself works. I am guessing that an approximation will have to be made for U down the road, probably with llGetPrimitiveParams( [PRIM_MATERIAL]); and some predetermined variable scale. Are you saying that you do agree that the Fn equation is correct? The part I really find myself questioning is the rotational force value.
|
|
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
|
11-06-2006 18:37
From: nand Nerd If I'm not mistaken the physics of friction between two objects (ignoring fluid mechanics for now) is dependent on a cooefficient of friction which varies for each object-object interface, the area of contact, force of contact (as I see you've worked out normal force).
I thought the basic Coulomb friction force approximation equation was Force_sub_friction = mu * force_sub_normal, which is irrespective of contact surface area...?
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
11-06-2006 20:55
From: Kage Seraph I thought the basic Coulomb friction force approximation equation was Force_sub_friction = mu * force_sub_normal, which is irrespective of contact surface area...? I believe it is respective of the contact surface and only applies to static friction. It is an incomplete approximation of friction.
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
11-07-2006 03:01
Hmm, I think Kage is correct...
but, mu depends on several things, including surface materials and area, and there are different values for static and moving mu as well the way I was taught it.
Of course my mechanics was a long time ago and included other things such as infinite plane surfaces and objects acting as if point masses and things like that.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
11-07-2006 06:41
Not to be a pain (in the), but any half decent compiler is going to throw a warning or an error on that because of local & global variables sharing the same names.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
11-08-2006 00:34
From: Strife Onizuka Not to be a pain (in the), but any half decent compiler is going to throw a warning or an error on that because of local & global variables sharing the same names. It compiled fine in world for me.
|
|
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
|
11-08-2006 07:08
Because llMaim(key id,integer how_badly); is funny, damnit!
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
11-08-2006 09:05
From: Strife Onizuka Not to be a pain (in the), but any half decent compiler is going to throw a warning or an error on that because of local & global variables sharing the same names. Well, this is LSL compiler we talk about, so it accepts it without issue. A _possible_ issue is, with this sort of naming scheme the value of global variable with shared name is ignored while local variable with the same name is in scope. Which, since you get no warning from compiler about the shared names, can be lot of fun and time wasted on debugging... not that it'd ever happen to me, no sire... >>;
|