@Codger
Quote: "Maybe it is beyond the scope of the update but.... would it be possible to set multiple gravity points such as black holes or a binary star or perhaps a gravity gun?"
You can already do this easily. I've written and posted an example of simple Newtonian gravitation in a separate thread. If you want multiple gravity sources, you just apply multiple forces to each object, each force representing the separate gravity source. I'll post a further example of how to do this in the other thread. In fact, I might just use Sir Issac's gravitational field equation instead ...
@Hoozer
Quote: "
I must say a simple command-list like:
get gravity postion x,y,z (to get the actual position of the garv-point)
set gravity postion x,y,z (to set the position of the grav-point)
get gravity mass m (gets the mass of the grav-point)
set gravity mass m (sets the mass of the grav-point and the resulting force)
get gravity force f (gets the force of the grav-point)
set gravity force f (sets the force of the grav-point)
get force radius r (gets the radius in which the force gets applied to objects within this range)
set force radius r (set the radius)
would be very userfriendly!
"
Actually, it is a relatively trivial matter to write your own code to replicate those commands, based on good old Sir Issac's law of universal gravitation. For example, in pseudo code you would work out the force exerted on an object by a gravity point as follows:
type grav
x as float
y as float
z as float
mass as integer
endtype
type vec
x as float
y as float
z as float
endtype
gravity_sources(1) AS grav
gravity_sources(1).x = 30
gravity_sources(1).y = 20
gravity_sources(1).z = 10
gravity_sources(1).mass = 1000
(and we'll assume that there is an object called obj with a mass of 50 and the gravitational constant of the universe is 3)
null = make vector3(1)
set vector3 1, obj.x - gravity_sources(1).x, obj.y - gravity_sources(1).y, obj.z - gravity_sources(1).z
length# = length vector3(1)
normalize vector3 1, 1
unit_vec AS vec
unit_vec.x = x vector3(1)
unit_vec.y = y vector3(1)
unit_vec.z = z vector3(1)
force AS vec
force = 3 x ((obj.mass * gravity_sources(1).mass) / (length# * length#)) * unit_vec
I forget if in DBPro it is possible to multiple scalars by types to produce a typed result. If the line immediately above does not work, it would have to be broken down into each of the dimensions of the vector, i.e.:
force.x = blah blah blah * unit_vec.x
force.y = blah blah blah * unit_vec.y
force.z = blah blah blah * unit_vec.z
All that said, I do take your point that for coders who don't know or want to learn some physics, it might be nice to have some built in equations instead.
Cheer if you like bears! Cheer if you like jam sandwiches!
"I highly recommend Philip" (Philip)