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 / The Force..... of Gravity *dun dun dun*

Author
Message
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 25th Jun 2011 16:58
Ok, I'm tired and my mind is fried. I think this pseudo-code below accurately describes the force of gravity. Are my suspicions correct?

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Jun 2011 17:10
If timeElapsed() gives the result as milliseconds rather than seconds you'll have to divide your increment product by 1000, but otherwise I think it looks about right, yes.


"Why do programmers get Halloween and Christmas mixed up?"
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 25th Jun 2011 17:33
I don't think that's right, you're incrementing by too much.

Shouldn't it be



or



During the first second, the speed attained is 32 feet per second.

During the second second the speed attained is 64 feet per second.

So, you increment velocity by 32 fps, not by 32, then 64, etc.

This from Wikipedia:
Quote: "
The strength of the gravitational field is numerically equal to the acceleration of objects under its influence, and its value at the Earth's surface, denoted g, is approximately expressed below as the standard average.

g = 9.81 m/s2 = 32.2 ft/s2

This means that, ignoring air resistance, an object falling freely near the Earth's surface increases its velocity by 9.81 m/s (32.2 ft/s or 22 mph) for each second of its descent. Thus, an object starting from rest will attain a velocity of 9.81 m/s (32.2 ft/s) after one second, 19.6 m/s (64.4 ft/s) after two seconds, and so on, adding 9.81 m/s (32.2 ft/s) to each resulting velocity. Also, again ignoring air resistance, any and all objects, when dropped from the same height, will hit the ground at the same time."


Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 25th Jun 2011 18:48
Depends on the value given back by timeElapsed().
If it returns the total time falling it shoud be as Rich Dersheimer says.
If it returns the time since the last frame, your code is ok.
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 25th Jun 2011 20:48
Haha, yup.
Every frame, for the most part, GetTimeElapsed() returns .0167
SJPro
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 25th Jun 2011 20:55
To be a picky with variables names here, even though it doesn't effect the coding, gravityForce is really the velocity of the object. The gravitational force is approximately constant over small distances (and good for your purpose). So gravity does have an effect immediately, but the velocity starts at 0. Also it is worth noting that the object will behave like it is in a vacuum.

www.freewarehub.net
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Jun 2011 05:41 Edited at: 26th Jun 2011 05:45
uhhh...
I don't see anything here that represents gravity.

How much force gravity applies is dependent on the mass of the object. So you usually don't try to get force, but instead force per unit of mass, AKA acceleration.

If you want to describe earth surface-gravity pretty much accurately, you just have to say that the acceleration is constant. IE:


So, for the standard view of surface-of-the-earth gameplay, downwards acceleration is constand.

Of course, as you get closer to the object you're being attracted to, the acceleration due to gravity increases, but this is an inverse relationship, and doesn't represent your pseudocode at all.


THIS represents gravity:

F=G*m1*m2/r^2

the force pulling the two objects, masses m1 and m2, at a distance r, is F. G is called the "gravitational constant", and is a very very small number.

If you say that one object needs to be locked in place (IE the earth), then you can say:
A=G*m/r^2

Just to check my math,
mass of the earth=5.9742 × 10^24 kg
radius of the earth=6378.1 km=6378100 m
G=6.67300 × 10^(-11) m^3/(kg*s^2)

6.67300 × 10^(-11) * 5.9742 × 10^24 / (6378100)^2=9.79982305 m/s^2

not bad, huh?

[edit]
also, using "feet per second" just makes it harder on yourself. keep in mind:
feet and meters are both measures of distance
pounds and newtons are both measures of force
slugs and kilograms are both measures of mass

Not many americans seem to know about "slugs", but it's right up the alley of feet and pounds. Pounds don't necessarily correlate to kilograms. one pound on pluto could be a million kilograms. Use the metric system!!!


Why does blue text appear every time you are near?
SJPro
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 26th Jun 2011 19:24
Quote: "uhhh...
I don't see anything here that represents gravity."


As I said he is modelling the results correctly, just his variable name should be velocity not gravityForce.

www.freewarehub.net
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Jun 2011 22:45
Quote: "As I said he is modelling the results correctly, just his variable name should be velocity not gravityForce."


the variable is named gravityForce and it is never used anywhere, so seeing as how he doesn't use the variable for anything, there are no results of the program.


Why does blue text appear every time you are near?
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 27th Jun 2011 04:27
It's pseudocode, Fuzzy. It was making that sample, vs. pOsting an entire module worth of code. And yes, the labelling is inaccurate, but it's my code. As long as I understand it, who cares

Also, all of my objects in game are represented by 32 units=1 foot. Yes, I could use meters. But I am using what works best for me, and also is comparable to how everything else is in the program why don't you use imperial measurements Fuzzy i mean, it'd American and better than everything else...

*coughjokingcough* lol
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 27th Jun 2011 06:41
Quote: "It's pseudocode, Fuzzy. It was making that sample, vs. pOsting an entire module worth of code. And yes, the labelling is inaccurate, but it's my code. As long as I understand it, who cares"


The labelling is plain wrong, and if you disregard variable names, since you don't apply the variables anywhere there's no telling whether or not the pseudocode is right or wrong!


Why does blue text appear every time you are near?
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 27th Jun 2011 06:59
Quote: "The labelling is plain wrong, and if you disregard variable names, since you don't apply the variables anywhere there's no telling whether or not the pseudocode is right or wrong!"


I think you're just being difficult. Though, I do understand where you're coming from, but I have a hunch everyone got what I meant. Anyway, I was tired and up all night when I wrote said post :3

Though, making normal accurate labels might help with code readability later on though....

/I has no normal sleep schedule :p lol

Login to post a reply

Server time is: 2026-07-11 03:38:07
Your offset time is: 2026-07-11 03:38:07