Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (522) Games in Android Showcase (127) games submitted by our members Games in WIP (590) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Air Resistance  (Read 2306 times) 0 Members and 1 Guest are viewing this topic.
darkprophet

Senior Devvie

 « Posted 2004-10-16 09:25:33 »

Hi,
I am trying to simulate air resistance in Ode. But im having a bit of trouble doing it in a proper way that doesn't affect alot of gravity stuff:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15 `            if (airResistance < 1) {                  javax.vecmath.Vector3f velocity = bod.getLinearVel();                  javax.vecmath.Vector3f angVeloc = bod.getAngularVel();                  velocity.x *= airResistance;                  velocity.y *= airResistance;                  velocity.z *= airResistance;                  angVeloc.x *= airResistance;                  angVeloc.y *= airResistance;                  angVeloc.z *= airResistance;                  bod.setLinearVel(velocity);                  bod.setAngularVel(angVeloc);            }`

Seems a hack to me, and not the way i should be doing things...

Any ideas?

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Mithrandir

Senior Devvie

Cut from being on the bleeding edge too long

 « Reply #1 - Posted 2004-10-16 19:54:27 »

When working with physics models, forces are far better to model in rather than velocity - that's why you're using a physics model in the first place.

Air resistance should be calculated as a force.  In general, air resistance is proportional to the square of the speed. Find out what your velocity is for the frame, calculate the airresistance in the exact opposite direction to the velocity, and add a force which is equivalent to the amount of power you're getting from the engine providing forward motion.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
darkprophet

Senior Devvie

 « Reply #2 - Posted 2004-10-16 21:11:10 »

right, ok.

So I have a force thats making a sphere move forwads, say 10 newtons. So i have to make 100 newtons oppose it, wouldn't that just make it go backwards?

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Malohkan

Senior Devvie

while (true) System.out.println("WOO!!!!");

 « Reply #3 - Posted 2004-10-16 22:25:38 »

if your air resistance force is calculated to be stronger than the original force you're exerting, you've done something wrong.

GameLizard.com
Play Rimscape!    |    Play Conquer!
the2bears

Senior Devvie

Projects: 2

Little Bear: Code Fu!

 « Reply #4 - Posted 2004-10-17 00:34:40 »

Quote
...In general, air resistance is proportional to the square of the speed....

Not *is* the square, as quoted the air resistance is proportional to the square... big difference:)

Bill

the2bears - the indie shmup blog
Mithrandir

Senior Devvie

Cut from being on the bleeding edge too long

 « Reply #5 - Posted 2004-10-17 01:17:34 »

Ya. The proportionality factor is normally known as the drag-coefficient ( cd).  For most ground vehicles, this is in the range of 0.2 to 0.45. For aircraft, values are around 0.05 to 0.15.

Also note that the values are proportional to the velocity of the object not to the force that is applied by the motor.  A vehicle at rest has no air resistance, so that motor force of 10N can be all used to accelerate the vehicle. Once you start getting a decent velocity, then the air resistance force starts to increase, until you get to the point of equilibrium.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
darkprophet

Senior Devvie

 « Reply #6 - Posted 2004-10-17 08:17:56 »

thank you all for your help. Il implement it, and il come back with the good news

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
dansoton

Innocent Bystander

Java games rock!

 « Reply #7 - Posted 2005-01-07 08:01:34 »

darkProphet (or anyone else),

Any update on this? I'm looking to do a similar thing - attempting to model the EDL (entry, descent and landing) of the nasa rover on mars, and so air resistance is crucial in this.

(I'm trying to create a simulation which allows the user to select a custom EDL (when to open the parachute etc) and see the results modelled, very ambitious for a newbie i must admit, but i'm game for trying!)

Also Is ODEJava still the best java phyics engine to use in this scenario where most of the forces applied will be through air resistance and drag?

Thanks
darkprophet

Senior Devvie

 « Reply #8 - Posted 2005-01-11 08:50:47 »

well...

I know pretty much what im supposed to do to get air resistance working. But im preoccupied with getting an API neutral physics system for jme at the moment.

What you need to do is approximate a contact constant for the object depending on its width/height/length. Basically, a face to it. Then you need to "map" those values on the different faces... (imaging a 2 dimentional quad, the longer side would obviously have more resistance).

Then when the object is moving, obtain the force by doing something like body.getForce() or something similar (i dont have it infront of me sorry). This will give you a Vector3f and a float. The Vector3f represents the direction of movement the force.

Then you find out which face is facing the direction of movement (you might have to guess sometimes). Then you do this:

float secondForce = faceConstant * drivingForce * drivingForce

And you have air resistance. It looks pretty complicated, but its not really. The only complex bit is the approximation and mapping (usually onto a boundingBox, unless its a sphere, then the constant is always the same).

Hope that helps,
DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 trollwarrior1 (33 views) 2014-11-22 12:13:56 xFryIx (73 views) 2014-11-13 12:34:49 digdugdiggy (52 views) 2014-11-12 21:11:50 digdugdiggy (46 views) 2014-11-12 21:10:15 digdugdiggy (40 views) 2014-11-12 21:09:33 kovacsa (65 views) 2014-11-07 19:57:14 TehJavaDev (69 views) 2014-11-03 22:04:50 BurntPizza (67 views) 2014-11-03 18:54:52 moogie (82 views) 2014-11-03 06:22:04 CopyableCougar4 (82 views) 2014-11-01 23:36:41
 basil_ 29x theagentd 28x HeroesGraveDev 25x BurntPizza 21x Riven 19x Spasi 18x princec 17x KevinWorkman 15x SHC 13x gouessej 11x Grunnt 10x kpars 10x LiquidNitrogen 10x CopyableCougar4 9x Nate 9x Gibbo3771 9x
 Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50List of Learning Resources2014-07-31 16:26:06
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org