Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Forces in Newton??

Author
Message
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 2nd May 2010 22:52
Howdy,
I'm working with Newton in my new project.
Basicly, I'm making a "gravity" point at (0,0,0) and applying gravity force to all the bodies in the scene.
BUT, when I apply the same force (via NDB_BodyAddForceGlobal) to all the bodies (with different masses), they accelerate the same! (it should be a=F/m)

Does anyone has any idea what to do? It's driving me insane

Thanks!
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd May 2010 07:01
Perhaps there is some way you could keep a record of the sizes of each object and modify the drop speed of each object according to that size?
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 3rd May 2010 07:38
That's not the issue, drop speed should be the same for every object (it's gravitiy after all), but I won't be able to calculate anything else in the game this way
And Newton should really use the a=F/m equation, so I guess I'm doing something wrong....
jasonhtml
22
Years of Service
User Offline
Joined: 20th Mar 2004
Location: OC, California, USA
Posted: 3rd May 2010 08:06
but isn't that what you want? all objects accelerate equally under gravity...

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 3rd May 2010 08:13
You should try giving some sample code so we can take a look at and isolate the error. Either you're doing something wrong (like somehow accidentally creating all objects with the same mass) or the command actually does apply an acceleration per body instead of a force ("NDB_BodyAddForceGlobal" could be thought of as adding force per object mass, as the programmer may have intended it).

But... I don't know enough about newton to rig up my own demo and experiment (without a tiny bit of effort ). Setting up one might help?

If you can't get this command to work it should be simple enough to just loop through all the objects and applying a force.

Also...
Quote: "the a=F/m equation"

just a pet peeve of mine... but... saying "the ___ equation" always seems blatantly shortsighted, and connotates just plugging numbers in, instead of understanding the fundamental relationship (not that you don't... it's just... every time someone says that I cringe on the inside).


Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 3rd May 2010 16:13
@jasonhtml
Not exactly. All objects accelerate equally when applying the same force to them (in Newton), but gravity isn't equal for all objects (it depends on mass). The problem is not gravty itself, it's everything else, since I can's calculate anything if acceleration isn't equal to F/m.

@Neuro Fuzzy
I know physics, don't worry about that
And you were right, "NDB_BodyAddForceGlobal" actually sets the body's acceleration (which is really, really lame and uncalled for), just found it in the FPS example.

Thanks, guys

Here's the screeny anyway:
jasonhtml
22
Years of Service
User Offline
Joined: 20th Mar 2004
Location: OC, California, USA
Posted: 4th May 2010 06:17
Quote: "All objects accelerate equally when applying the same force to them (in Newton)"


No, that is incorrect. If I apply 1N of force to 2 objects, one having a mass of 1kg and another having a mass of 2kg, the first object will accelerate at 1m/s^2 and the second will accelerate at 0.5m/s^2.

If gravity is what he is after, then setting the constant of acceleration to 9.8m/s^2 or whatever value he chooses would display the correct behavior.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 4th May 2010 06:29
Quote: "No, that is incorrect. If I apply 1N of force to 2 objects, one having a mass of 1kg and another having a mass of 2kg, the first object will accelerate at 1m/s^2 and the second will accelerate at 0.5m/s^2.

If gravity is what he is after, then setting the constant of acceleration to 9.8m/s^2 or whatever value he chooses would display the correct behavior.
"


That isn't being contested. the problem is what happens within the newton physics engine


Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 4th May 2010 17:07 Edited at: 4th May 2010 17:12
@jasnohtml
Problem with Newton is that it doesn't apply force, it applies acceleration, so things happend just like I wrote.
That's why I posted it, after all.

[edit]
Oh, you probably misunderstood that "in Newton" thingy. I meant "in Newton physics engine".
Actually, the problem is in the wrapper for DBPro.

[edit2]
And as I said, I know Newton's mechanics. I study physics at the university.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th May 2010 17:29 Edited at: 4th May 2010 17:35
All objects accelerate the same under gravity.

force of gravity = mg
f = ma
ma = mg
a = g

Acceleration = Gravitational field strengh, hence why the earth's gravitational field strength is roughly 9.8m/s²

All objects accelerate at the same rate in a gravitational field.

Here is an example:
Take two objects, 1kg and 2kg.

The force of gravity on the first is mg = 1kg * 9.8m/s² = 9.8N
The force of gravity on the second is mg = 2kg * 9.8m/s² = 19.6N

Acceleration on the first is f/m = 9.8N/1kg = 9.8m/s²
Acceleration on the second is f/m = 19.6N/2kg = 9.8m/s²

The two objects have the same acceleration!

http://en.wikipedia.org/wiki/Gravitation#Equivalence_principle

Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 4th May 2010 17:33
@Diggsey
You can just read my second post and stop talking to me like I'm retarded.
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 6th May 2010 22:29
I think you might be getting confused between the two equations:

F = m*a

and

F = G*m1*m2 / r^2

(http://en.wikipedia.org/wiki/Gravitational_constant)

If you are trying to work out the acceleration on the fallingobject then you need to use both equations, so:

m1*a1 = G*m1*m2 / r^2

where m1 and a1 and the mass and acceleration of the falling object.

Dividing both side by m1

a1 = G*m2 / r^2

G is a constant and m2 is the mass of your central object, which will also be a constant.

The acceleration of the falling object is inversely proportional to the square of the distance between the two object. So the acceleration will increase as the objects get closer but will still be the same for all objects that are the same distance from the central object (even if they are of difference masses).

I have no idea how to apply this in "Newton" as I'm a DBC user but I hope this helps.
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 7th May 2010 00:31
@29 games
That's not the issue. And as I said, I know classical mechanics.
The issue is in Newon's wrapper for DBPro which sets body's acceleration with "NDB_BodyAddForceGlobal" function and that's contra-intuitive and uncalled for.
I said "gravity" only because I stumbled upon this problem while working out the gravity in a game I'm working on.
And thanks for trying to help
tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 8th May 2010 23:59
Quote: "The issue is in Newon's wrapper for DBPro which sets body's acceleration with "NDB_BodyAddForceGlobal" function and that's contra-intuitive and uncalled for."


NDB_BodyAddForceGlobal just adds to the force (a vector) value applied during NDB_NewtonUpdate on the object. It doesn't "set" anything, there is another function for setting the force to act upon an object.

During the NDB_NewtonUpdate the wrapper calls the Newton function NewtonBodySetForce on the object which uses the accumulation of all forces on the object from NDB_BodyAddForceGlobal (and its Local counterpart). Then the SDK NewtonUpdate() function gets called and that applies the forces.

Here's the SDK documentation for that function:


I don't see anything mentioning this function setting acceleration. If you think the Newton function NewtonBodySetForce is not setting a force but really setting acceleration, that is something inside the Newton Game Dynamics Engine itself and I would suggest you go on the Newton forums and talk to Julio. Do your homework and check your attitude at the door about people doing things which are "uncalled for" because he doesn't take that from anyone.


A 3D marble platformer using Newton physics.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 9th May 2010 00:31
I bet that... julio? Intended the function to be used for global, downwards gravity. Maybe originally setting force, but then by request (or just because) changed it.

Also, never said this, but thebeely, that screenshot looks really cool I love stuff like that. I'm currently working on (well, testing for school and stuff, so not like at this moment) a 2d n-body simulation (I'm having a hard time on quadtree optimization and stuff). I might expand it to 3d when I get it working. Stuff like that is so cool!


Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 9th May 2010 16:08 Edited at: 9th May 2010 16:14
@Neuro Fuzzy
Thanks I'm not going to leave it wireframed (if that's what you mean by "stuff like that"), I'm planing on making a mini planet out of it (many mini panets actually, it's made via heightmap).

@tiresius
I'm aware of the things happening when calling the "NDB_NewtonUpdate" function. I was pointing at this:

Quote: "
`finally, we just need to apply this force to the Player! we'll use the AddForceGlobal command.
`NOTE- in the forumla above, I said F = m * a. we calculated "a", but we never multiplied by the mass!
` this is because my wrapper does this for you. it automatically multiples the force by the body
` mass inside the function.


`set temp vector 1 to force location
NDB_BodyGetPosition Player
`set temp vector 2 to force direction
NDB_SetVector 2, AccelX#, 0.0, AccelZ#
NDB_BodyAddForceGlobal Player"


It's a qoute from the "FPS demo" downloaded with the wrapper and it clearly says what it does. And that's what I call contra-intuitive and uncalled for, when the function which is supposed to add the body's FORCE (as clearly stated in a function's name) actually adds body's ACCELERATION (I made the "force" in the qoute italic). I don't think if I can get any more clear about this.

[edit]
And as I said, it's not the "engine" issue, it's the "wrapper" issue. So, yes, I did my homework.
tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 10th May 2010 04:28
Ah, now I see the confusion. Yes NDB_BodyAddForceGlobal will scale the force to the mass of the object if the vector W component is equal to 1.00. There should be documentation on that behavior, I'll have to look into adding it.

Do you set your vector W component when calling NDB_SetVector or do you take the default (which is 1.00) ?

It's the difference between calling it like this

and this


Try it the second way, making sure W does not equal 1.00 and see if it makes a difference. It should, based on the code in the wrapper.


A 3D marble platformer using Newton physics.
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 10th May 2010 16:33
I don't see why would the "w" coordinate be used in this case.
If the "w" coordinate is used here, then I should re-calculate the force vector (x=x/w,y=y/w,z=z/w) which, again, complicates things.

However, I did try setting the "w" coordinate to values both bigger than 1.0 and smaller than 1.0 and then there was no force applied at all in that cases.

Bottom line, the problem was found and it's because of the wrapper scaling the force.
It would be better if this was managed via some kind of "ScaleForce" flag or with a function "NDB_NewtonAddAcceleration(Global/Local)", but the world isn't perfect, I guess Then, again, setting the force is as easy as setting different accelerations
tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 23rd Jun 2010 06:41
Fixed with a Newton wrapper update, please see the original 1.53 thread.


A 3D marble platformer using Newton physics.

Login to post a reply

Server time is: 2026-07-25 08:11:46
Your offset time is: 2026-07-25 08:11:46