Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Setting Gravity #23280
02/15/04 11:27
02/15/04 11:27
Joined: Oct 2003
Posts: 44
Kentucky
Teelo888 Offline OP
Newbie
Teelo888  Offline OP
Newbie

Joined: Oct 2003
Posts: 44
Kentucky
All those who are willing to listen, please answer.

I was wondering in 3DGS how to set a gravitational point inside of a sphere, to make objects be drawn to it, and how to remove the default gravity already there. Please reply, im very desperate and I have been researching this topic for a few days now.

Re: Setting Gravity [Re: Teelo888] #23281
02/15/04 18:53
02/15/04 18:53
Joined: Aug 2003
Posts: 275
Germany
kopitzki Offline
Member
kopitzki  Offline
Member

Joined: Aug 2003
Posts: 275
Germany
If you are talking of 3dGS physics system, maybe this:

Code:
 
//while(1)
var sphere_pos[3];
var grav_vec[3];

vec_set(sphere_pos,sphere.x);
vec_diff(grav_vec, sphere_pos.x, my.x);
vec_normalize(grav_vec,grav_force);
phent_addcentralforce ( my, grav_vec );



Re: Setting Gravity [Re: kopitzki] #23282
02/16/04 04:13
02/16/04 04:13
Joined: Oct 2003
Posts: 44
Kentucky
Teelo888 Offline OP
Newbie
Teelo888  Offline OP
Newbie

Joined: Oct 2003
Posts: 44
Kentucky
So which variables do i change according to where the sphere is and stuff?
and I dont see any variable telling the y pos or anything, wouldnt that be needed?
as you can tell im pretty newbish at C-Script but thanks for your help so far, I really appreciate it

Also my Aim name is Teelo888 also my MSN e-mail is teelo888@msn.com if someone would please help me on there

Re: Setting Gravity [Re: kopitzki] #23283
02/18/04 22:42
02/18/04 22:42
Joined: Aug 2003
Posts: 275
Germany
kopitzki Offline
Member
kopitzki  Offline
Member

Joined: Aug 2003
Posts: 275
Germany
Code:
 
entity sphere*;
var grav_force=1;//or 10 or 100 or 20.5 or 2500 or ...

action sphere//assign spheremodel to it
{
sphere=my;
}

action theothermodels //assign models affected by faked spheregravity to it
{
//
//phent_settype and all the usual physics setting stuff
//

var sphere_pos[3];
var grav_vec[3];

while(1){
vec_set(sphere_pos,sphere.x);
vec_diff(grav_vec, sphere_pos.x, my.x);
vec_normalize(grav_vec,grav_force);
phent_addcentralforce ( my, grav_vec );
wait(1);}
}



Re: Setting Gravity [Re: kopitzki] #23284
02/19/04 03:05
02/19/04 03:05
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Your code simulates attraction TO a sphere not INSIDE a sphere.

As per an earier post, gravity inside a hollow sphere is zero and gravity inside a non-hollow sphere is dependent on how much mass is the sphere "beneath" you so to speak.

If you just want gravitational attraction between bodies, then freakys code is right on. If you truly want gravity INSIDE a sphere, you'll have to follow what I said above and use some other scheme.

Re: Setting Gravity [Re: fastlane69] #23285
02/19/04 03:54
02/19/04 03:54
Joined: Sep 2003
Posts: 51
Newton Offline
Junior Member
Newton  Offline
Junior Member

Joined: Sep 2003
Posts: 51
I going to tap here if I may. Gravity inside a spherical object is linear with the distance from the object to center of the sphere. (assume more or less contant density).

So you do not need to use spherical coodenate in order to get the value of the gravity at any point inside the sphere.

all yo need is to now the magnitud of gravity on the surface, and the interpolate that value with the distance to the center.

somethin like this (pseudo code)

let G be the gravity
let R be the radius of the sphere
let P be the center of the sphere
lep Q be the point inside the sphere

distVector = substract (Q, P);
magOfdistVector = Magnitud (distVector)

gravDirVector = Normalize (distVector);
gravMag = G * (magOfdistVector / R)


this is valid in for any spherical object as long as the point is inside the sphere.

when the point is outside the it ovey Newton Gravitation Law

Newton


Re: Setting Gravity [Re: Newton] #23286
02/19/04 06:38
02/19/04 06:38
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Just wanted to make clear that Newtons Law of gravity applies to point sources. We approximate all the mass at the center of a planet or sun and thus treat it as a point source, but this is just an approximation. When inside an object, you can no longer use this point source appoximation since you have mass everywhere around you.

But youre absolutely right; spherical coords are overkill inside a uniformly dense spherical object

Re: Setting Gravity [Re: fastlane69] #23287
02/19/04 07:29
02/19/04 07:29
Joined: Sep 2003
Posts: 51
Newton Offline
Junior Member
Newton  Offline
Junior Member

Joined: Sep 2003
Posts: 51
no that is not an aproximation that is a fact

Newton

Re: Setting Gravity [Re: Newton] #23288
02/19/04 09:06
02/19/04 09:06
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Don't care to have this degrade into "Quen es mas Phisico", but you yourself stated a set of assumptions regarding geometry and mass; hence it's an approximation.

While your statments as to the linear behaiviour of gravity is fact, it is still a fact based on approximation that the earth is uniformly dense and a perfect sphere. A true Integration on the Oblate Spheroid that is the Earth and most Planets would not give a uniformly linear increase in gravitational Force. Gravitational Mapping of the surface of the earth show clearly how it varies across the face of the earth.

Further, the 1/(r*r) behaiviour that we so carelessly apply is in Fact a point source approximation. We "Put" all the mass at the center of a planet/star as an approximation that works well when we are far away from the mass so that it "looks" like a point mass. Hence, all the planets can be considered points like in calculating their gravitational interaction and thus, their orbits and little-g.

However, if you are close to the mass, or as in this case inside, then this simple point source approximation fails and you acutally have to use, gulp, Calculus to integrate all of the point source around you, in essense every atom, to account for the mass around you to give you the gravity. The fact that we are considering a symmetrical uniformly dense object (to whit a sphere) means that this integration (which BTW is easiest in spherical coords ) gives us an easy result, the linear behaiviour you mentioned.

Maybe we just debating semantics here, but all I was addressing was that Newtons Universal Gravitation Law is for point sources and should be used with care on extended objects. Usually, nice clean answers like the behaiviour you described is based on one approximation or another....

Finally, to get a bit esoteric, there is mounting evidence that while Newtons Grav law works well at our distance scales, on the scale of the Quantum or the Cosmic, then it **seems** that the traditional f= (Gm1m2)/(r*r) actually fails; new facts ursurping old laws!


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1