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

Senior Member

 « 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 Member

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 Member

 « 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 Member

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 Member

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 Member

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 Member

 « 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 Member

 « 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.
 BurntPizza (21 views) 2014-09-19 03:14:18 Dwinin (35 views) 2014-09-12 09:08:26 Norakomi (62 views) 2014-09-10 13:57:51 TehJavaDev (87 views) 2014-09-10 06:39:09 Tekkerue (42 views) 2014-09-09 02:24:56 mitcheeb (65 views) 2014-09-08 06:06:29 BurntPizza (47 views) 2014-09-07 01:13:42 Longarmx (35 views) 2014-09-07 01:12:14 Longarmx (40 views) 2014-09-07 01:11:22 Longarmx (36 views) 2014-09-07 01:10:19
 BurntPizza 37x Riven 18x princec 17x Rayvolution 17x ags1 16x basil_ 16x KevinWorkman 15x kevglass 12x theagentd 11x LiquidNitrogen 11x nsigma 11x HeroesGraveDev 9x The Lion King 7x deathpat 7x TehJavaDev 6x Gibbo3771 6x
 List 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:06List of Learning Resources2014-07-31 11:54:12HotSpot Optionsby dleskov2014-07-08 01:59:08
 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