Author Topic: applying multiple forces to ridgid body  (Read 5249 times)

0 Members and 1 Guest are viewing this topic.

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
applying multiple forces to ridgid body
i kinda hit a roadblock while working on my atmospheric script. by adding conservation of angular momentum, i made flying in the atmosphere almost impossible because drag forces arent stabilizing the flight model (in other words i need to simulate a tail). there are a whole bunch of other forces/torques i want to consider as well, control surfaces, pitching moment and so on. right now all the forces act on the center of gravity, and the only way i have of changing my angular momentum is with a set of assumed rcs torques. this works for space flight, but in the atmosphere it doesnt work so well.  what im thinking of doing is specifying multiple sets of airfoil properties (one for each wing, horizontal and vertical stabilizer, canard and whatever else) per ship each with their own properties. using those properties to computing lift, induced drag, pitching moment and other forces/torques i forgot to mention. these fores would act upon the center of the airfoil. for each airfoil i intend to produce a total force produced by that foil's interaction with the atmosphere, as well as a pitching moment.

what i dont know how to do is apply all those force vectors of varying origin to the whole model as a single ridgid body, and then figure out how much of theese forces become linear force, and how much becomes angular force (torque). once i have theese forces i can convert them to accelerations and apply those to the momentum (angular and linear) of the ship every frame. ive been reading info on physics for at least a week and i still havent made any headway. physics gurus unite!
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Mika

  • 28
Re: applying multiple forces to ridgid body
I could give you some information based on my best guesses, but you are likely best served by Thaeris. Other than that, I cannot provide you with actual physical stuff with respect to airflow (I don't bother to learn them for this occasinon), but I can probably help you with forces and torques coming from different positions. However, they might not be related to actual physical properties, as I'm not educated in aerodynamics.
Relaxed movement is always more effective than forced movement.

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: applying multiple forces to ridgid body
Well, uh, each force can be divided into two components, one that is directed towards the center of gravity and causes linear acceleration, and one that acts rectangularly in relation to the direction to the center point and works as moment and causes angular acceleration.

Like this:




But, because you have forces that affect different points in the model, you can't immediately combine the forces and then calculate their sum. You have to first separate each force into angular and linear component, THEN combine linear and angular components to the net linear force and net moment affecting the body.

EDIT: And, of course, you should probably break each moment force into three components (pitch, roll, yaw) for easier handling. Since pitch, roll and yaw moments of inertia tend to be very different in most non-symmetric objects, directly lumping all moment forces together would be mathemathically annoying and wouldn't probably give correct results unless you were working with a perfect sphere.
« Last Edit: January 21, 2010, 05:28:52 pm by Herra Tohtori »
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline Thaeris

  • Can take his lumps
  • 211
  • Away in Limbo
Re: applying multiple forces to ridgid body
I could give you some information based on my best guesses, but you are likely best served by Thaeris. Other than that, I cannot provide you with actual physical stuff with respect to airflow (I don't bother to learn them for this occasinon), but I can probably help you with forces and torques coming from different positions. However, they might not be related to actual physical properties, as I'm not educated in aerodynamics.

I'm glad to know I'm so highly thought of. Unfortunately, I've still got a rather long way to go in terms of the sciences and programming.

...What I can do, should you be interested, is try to get you in touch with some former professors of mine... who happen to be doctors of engineering. However, I'll certainly look into what I can.  :nod:
"trolls are clearly social rejects and therefore should be isolated from society, or perhaps impaled."

-Nuke



"Look on the bright side, how many release dates have been given for Doomsday, and it still isn't out yet.

It's the Duke Nukem Forever of prophecies..."


"Jesus saves.

Everyone else takes normal damage.
"

-Flipside

"pirating software is a lesser evil than stealing but its still evil. but since i pride myself for being evil, almost anything is fair game."


"i never understood why women get the creeps so ****ing easily. i mean most serial killers act perfectly normal, until they kill you."


-Nuke

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
I could give you some information based on my best guesses, but you are likely best served by Thaeris. Other than that, I cannot provide you with actual physical stuff with respect to airflow (I don't bother to learn them for this occasinon), but I can probably help you with forces and torques coming from different positions. However, they might not be related to actual physical properties, as I'm not educated in aerodynamics.

the airflow mechanics i pretty much have worked out to the point where i have the forces ready to go, my problem is what to do with them. my only aerodynamic problem right now is dealing with supersonic flight, but i dont think thats something i cant figure out. ive already written functions to determine all major forces dealing with aerodynamics.

Well, uh, each force can be divided into two components, one that is directed towards the center of gravity and causes linear acceleration, and one that acts rectangularly in relation to the direction to the center point and works as moment and causes angular acceleration.

Like this:




But, because you have forces that affect different points in the model, you can't immediately combine the forces and then calculate their sum. You have to first separate each force into angular and linear component, THEN combine linear and angular components to the net linear force and net moment affecting the body.

EDIT: And, of course, you should probably break each moment force into three components (pitch, roll, yaw) for easier handling. Since pitch, roll and yaw moments of inertia tend to be very different in most non-symmetric objects, directly lumping all moment forces together would be mathemathically annoying and wouldn't probably give correct results unless you were working with a perfect sphere.

thats the best explanation ive seen so far (in that i understood it and it didnt make my neurons screem in terror at me to take more asprin). computing forces by plane kinda fits into the way im already doing things. so i can have x torque, y torque, and z torque about orthagonal axes in the models frame of reference. this kinda also lets me do complex thruster modeling, though i kinda want to keep it simple on the modding side, so that modders dont need to have a degree in aerospace engineering to setup their ships to fly.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: applying multiple forces to ridgid body
...And then you need to take into account that torques that cancel each other will actually become a linear force (as in airplane's wing tips both torque the wing upwards, but since it's a rigid structure it ends up becoming upward force).
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
now my brain hurts
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: applying multiple forces to ridgid body
Hmm.

Actually, refreshing my memory, you can just pretty much sum all the force vectors together to determine the linear net force. Haven't done rigid body dynamics in a while.

ou still need to dissect the torque out of each individual vector in relation the three major rotational axes, and then you have the necessary details for determining the necessary values for the simulation; linear and angular acceleration around pitch, roll and yaw (which probably all have different specific moment of inertia values) at the time.

When you know the original position, linear and angular velocities at t0, you can then predict the state of the motion of the body at t+dt, and so forth...

Determining a suitable dt value would be problematic. The smaller the value, the more accurate and CPU intensive simulation you get.


...So, are you going to take propellant/fuel mass loss into account in the simulation?  :drevil:
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
i figure once i have figured out the torque about the 3 major axes, can i just stick those in a vector and transform it by the (inverse)moi matrix that is determined when a model is converted? linear forces would be compared against mass. i dont want to convert the forces to acceleration immediately, as i still have gravity to consider. frametime pretty much covers the time dimension. accelerations are multiplied by the length of the frame (technically the previous frame) before being added to the momentums. the momentum and angular momentum are also multiplied by the frametime to determining the new position and orientation. so pretty much all i need to do is simplify the forces before doing that.

as for fuel, maybe. i kinda also want to also consider ordinance weight. every weapon has a mass value, so i can just look at the number available and multiply. the mass would be added to the ship's dry mass. im not sure how i will modify the moment of inertia based on that though. engine modeling is also something i want to do, have different types of engines or different engine performace in the atmosphere than in space. perhaps by supplying booster fuel or air breathing engines for atmospheric flight that would produce more power than usual, sort of a "launch configuration". performance for air breathing engines would relate to the atmospheric density, speed and other factors.

another idea is to compute recoil forces as well, get that a-10 stall when firing effect. supersonic modeling is one more idea. drag reaches a peak around mach 1.2, then begins to fall at around mach 1.3, because once a shock cone is established, a local wind velocity begins to manifest. i definately want to do this for weapons, since supersonic bullets and missiles slow down too rapidly due to extreme drag, producing a fire backwards effect.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: applying multiple forces to ridgid body
i figure once i have figured out the torque about the 3 major axes, can i just stick those in a vector and transform it by the (inverse)moi matrix that is determined when a model is converted? linear forces would be compared against mass. i dont want to convert the forces to acceleration immediately, as i still have gravity to consider. frametime pretty much covers the time dimension. accelerations are multiplied by the length of the frame (technically the previous frame) before being added to the momentums. the momentum and angular momentum are also multiplied by the frametime to determining the new position and orientation. so pretty much all i need to do is simplify the forces before doing that.

For the sake of this purpose, gravity is one of the vectors that you should already be taking into account when determining linear acceleration. It just always happens to have uniform direction and no torque effect on a body, so it's an easy addition.

Stuff like velocity dependant air resistance forces in non-standard flight attitude (flying sideways, or belly-first, or backwards), and transition from lift to stall condition would probably be the most challenging things to get right, and that's practically required for any semblance of accuracy for aerobatic maneuvers like sideslips, tailslides, autorotation (spins and flat spins) or negative stalls like the ones you can get in IL-2 when you pitch down and cross the rudder and aileron controls to either direction, depending on the propeller rotation direction, which results in a fairly controllable negative stall, and a negative flat spin which means you're flying the cockpit canopy first, with about -90 degrees angle of attack. It's an excellent maneuver for quick energy bleed, and a purely evasive/aerobatic one. With good timing you can almost make a hammerhead maneuver with some planes, which is all sorts of awesome....

Quote
as for fuel, maybe. i kinda also want to also consider ordinance weight. every weapon has a mass value, so i can just look at the number available and multiply. the mass would be added to the ship's dry mass. im not sure how i will modify the moment of inertia based on that though.

Apply a multiplier to the torque to achieve desired effect based on the configuration. That way you would require a pre-determined multiplier table for each possible loadout configuration.

On the other hand that doesn't allow real-time fuel consumption weight loss and such effects. You'll need real time tracking of mass and it's distribution for that, so you can take the model's empty weight as the base value, and then do a simple MOI calculation real-time to see how much each piece of loadout increases the MOI of the total ship. Calculating MOI is not that hard if you just use distance to center of gravity and use a simplified model where each piece of loadout is attached to a single hardpoint in the model.

Quote
engine modeling is also something i want to do, have different types of engines or different engine performace in the atmosphere than in space. perhaps by supplying booster fuel or air breathing engines for atmospheric flight that would produce more power than usual, sort of a "launch configuration". performance for air breathing engines would relate to the atmospheric density, speed and other factors.

If I may suggest, make the basic physics work first before you start fiddling with HOW the thrust vector is produced... that kind of thing would be easy to add later on as it doesn't have too much to do with the flight dynamics model.

Quote
another idea is to compute recoil forces as well, get that a-10 stall when firing effect. supersonic modeling is one more idea. drag reaches a peak around mach 1.2, then begins to fall at around mach 1.3, because once a shock cone is established, a local wind velocity begins to manifest. i definately want to do this for weapons, since supersonic bullets and missiles slow down too rapidly due to extreme drag, producing a fire backwards effect.

The A-10 doesn't stall when it's firing. At low speed the combustion gases from the gun can end up in the jet engines which can cause an engine flameout or stall, but really, the recoil force of the GAU-8 Avenger is greatly exaggerated - it doesn't notably slow down the jet. Besides, stall is not a condition that depends on air speed, it's only dependant on angle of attack (and wing profile). The reason why slowing down too much can result in a stall is that the lift is a result of airspeed and angle of attack; when airspeed is decreased, angle of attack must be increased to produce the required amount of lift for level flight. If the stall threshold angle is surpassed, then the wing stalls and lift is lost, but stall itself doesn't depend on airspeed.

The rest, though, is interesting. Truely ballistic primaries would be incredibly awesome. I'm just beginning to worry about how many vectors and objects can modern computers handle during one frame time, and how will the collision detection work.
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
right now im cleaning up the code trying to make everything more organized. functionizing a lot of complex code thats repeated for both weapons and ships. i also have to idiot proof some functions so they will not crash the game if something important is omitted from the physics.tbl. also want to add some features from the cockpit demo (mainly advanced input tweaks). then i will try to implement simple drag and control surface modeling. once thats done il post a teaser release and then work on advanced thruster and airfoil modeling.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: applying multiple forces to ridgid body
you know angular representations are not going to work very well, you should be using a matrix, a 4X4 matrix. otherwise you are going to get gimbal lock.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
that usually not a problem unless the rate of change for a frame is insanely large. gimbal lock will always manifest with matrix multiplication if any axis wants to rotate more that 90 degrees in one step. while in a per second format this would cause issues, but youre usually dealing with a period of time roughtly 1/60th of a second (the actual number depends on the return value of the frametime function). so that 90 degrees change every second is reduced to 1.5 degrees every frame. you could probibly rotate as fast as 2 or 3 rotations a second without gimbal lock. of course the faster you go the lest precise the rotation. i could simply cap the maximum, make it so that thrusters wont fire in a specific direction if the rotation rate in that direction is more than x degrees per second. only forces, accelerations and momentum will be stored in a euler format. a force is usually converted to an acceleration and then scaled by frametime before it gets applied to momentum, so the change every frame is small. momentum is what you cap, the "flight computer" simply locks you out if you try to do something stupid, like turn the ship beyond its "structural limits". when this is applied to the orientation of the ship, it is again multiplied by frametime, so the rate of change is small. here is where its converted to a 3x3 matrix and the current orientation matrix gets multiplied by it.

ive already implemented angular momentum and it works fairly well, even at insane rotation speeds. once i implement my virtual fly by wire system, this will be capped, and moving the joystick will indicate the desired rate of rotation (in relation to a specified frame of reference, which for now is the center of the level) instead of how much thrust to apply. the capped rotation rate will probibly be settable in a per ship basis, it would definitely want to be higher on an interceptor (ship with low mass) than a bomber (ship with high mass). some would argue that capping the rotation rate is not newtonian, but it is a common practice in high end military aircraft to lock out the pilot when they try to exceed the maximum angle of attack (b2), maximum g load (dont kill the pilot), or some other design tolerance. the imortant thing is that its a pilot lockout, and not a violation of the laws of physics.
« Last Edit: January 25, 2010, 11:17:44 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: applying multiple forces to ridgid body
You may be able to gander some code in these sources for clues about how to handle the moments of intertia (keeping in mind we're talking about Java in one case and C++ in the others, presumably).  All this stuff is open source, I believe.

http://www.flightgear.org/features.html
http://code.google.com/p/exoflight/

Good luck!  :yes:

  

Offline Thaeris

  • Can take his lumps
  • 211
  • Away in Limbo
Re: applying multiple forces to ridgid body
Heard of FlightGear before, but never used it as I've got X-Plane.

...Exoflight though... that's a new one.  :nod: I know Herra's brought up Orbiter several times (I've only been mildly interested in getting into that one, but perhaps I should at some point), but this is something I've never, ever, heard of...

...I'm downloading this now, actually. Hopefully it's more moddable than Laminar Research's "Space Combat," thus allowing me to get that realistic spacecraft performance I crave...  ;7
"trolls are clearly social rejects and therefore should be isolated from society, or perhaps impaled."

-Nuke



"Look on the bright side, how many release dates have been given for Doomsday, and it still isn't out yet.

It's the Duke Nukem Forever of prophecies..."


"Jesus saves.

Everyone else takes normal damage.
"

-Flipside

"pirating software is a lesser evil than stealing but its still evil. but since i pride myself for being evil, almost anything is fair game."


"i never understood why women get the creeps so ****ing easily. i mean most serial killers act perfectly normal, until they kill you."


-Nuke

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: applying multiple forces to ridgid body
for some reason I can't help but think there will be some artifacts, but if you say it's working then I guess I'm just overly paranoid
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
for some reason I can't help but think there will be some artifacts, but if you say it's working then I guess I'm just overly paranoid

theres not a doubt in my mind that there are artifacts. its just for now they appear to be very small. there will be situations however where a frame will run much longer than expected, and this is where the biggest of those artifacts will occur. you could probably get around this with efficient use of graphics so that slowdowns are less common. or detect situations where gimbal lock will occure and deal with it for that frame, perhaps cut up the rotation and apply it over the course of several frames.
« Last Edit: January 26, 2010, 03:51:35 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: applying multiple forces to ridgid body
theres not a doubt in my mind that there are artifacts. its just for now they appear to be very small. there will be situations however where a frame will run much longer than expected, and this is where the biggest of those artifacts will occur. you could probably get around this with efficient use of graphics so that slowdowns are less common. or detect situations where gimbal lock will occure and deal with it for that frame, perhaps cut up the rotation and apply it over the course of several frames.


In my opinion, it would be far better to use a fixed dt value and interpolate the results to the next frame position from that than using the time between frames as dt value. Frametime is after all dependant (and correct me if I'm wrong) on not only the physics running smoothly, but also all the other stuff on the screen. At 1/30 s dt the simulation could be quite imprecise already in certain conditions, not to mention occasions where frame rate drops to 10-15 FPS. If you set dt to 10 ms, it would give a 100Hz fixed precision on the physics regardless of the actual frame rate on display, and it would be more consistent and logical in handling responses.
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: applying multiple forces to ridgid body
that would make the program structure very complicated, assuming its even possible at all. the clock is where it is when the lua simulation hook runs, which may be every 1/60th of a second or 1/10th of a second since the last time it was run. you could maybe handle it with a timestamp, if the time since the last time physics was handled is larger than the 10ms interval then physics would run, but theres no guarantee it would be exactly 10ms, it could be 12 ms, and dt would be just as variable. in a multithreaded engine that would be a very good idea, physics would run independant of the rest of the game, and the time it takes to run physics is usually proportional to the number of objects, so a flat dt could be possibly be established. if that was the case then interpolation would be easy. its a good idea, but im not sure how to pull it off with the current engine.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Mika

  • 28
Re: applying multiple forces to ridgid body
Here are a couple of things to check if you haven't already:
http://en.wikipedia.org/wiki/Flight_dynamics#Lateral_modes
http://en.wikipedia.org/wiki/Directional_stability

No doubt you have considered them. What I would like to point out is the surprising amount of components, sometimes hard to notice, but obvious after it has been noted. Wind with a small deviation angle with respect to aircraft velocity vector can for example, make tail to work as a wing and to push aircraft sideways. This is somewhat different from perpendicular wind that works on the whole exposed aircraft hull. Depending on the aircraft mass distribution, moments will cancel each other, or a yaw will develop. It will also add perpendicular component to airframe's velocity vector. End result is the same, but mechanics are slightly different.

Note that the component properties may depend on the local velocity, like spin or inverted spin. Be advised that the wing profiles cause different lifts (and drags!) depending on the velocity. Higher velocity adds lift and aircraft has to apply compensate with the tail. One of the most glaring examples is the Valkyrie bomber which had to change its wing profile quite drastically after certain speed (Mach 2?).

Is your simulation supposed to work as an ideal airplane or as a more conventional airframe with all flight dynamics included? Phogoid motion or automatic trims?

But again, this is after brief reading of the subject by somebody who has never read a book of aerodynamics.
Relaxed movement is always more effective than forced movement.