Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by AndrewAMD. 12/05/23 10:56
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (3run, AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip), 605 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Simple physics question...i think #111336
02/07/07 18:33
02/07/07 18:33
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi,
My physics knowledge its terrible
I am using a simple code for a sphere / ball like in the manual just for test:

Code:

entity* eSphere;
var sphereGravity = -500;
var sphereMass = 1.0;
var sphereFriction = 90.0;
var sphereBounciness = 75.0;
var sphereMinimumSpeed = 100.0;
var sphereLinearDamping = 30.0;
var sphereAngularDamping = 5.0;

action ds_sphere
{
eSphere = my;

phent_settype(my,ph_rigid,ph_sphere);
phent_setmass(my,sphereMass,ph_sphere);
phent_setfriction(my,sphereFriction);
phent_setelasticity(my,sphereBounciness,sphereMinimumSpeed);
phent_setdamping(my,sphereLinearDamping,sphereAngularDamping);
}



I want to do a simple thing. I have the sphere / ball and it is static, and a point (static target - vector) where i want the ball to reach and stop exactly there. Like this:



I know the distance to be covered (vec_dist) and i want to know how much velocity (phent_addvelcentral(my, vectorSpeed) i need to apply in order the sphere cover the given distance and stop exactly on target.

How can this be anchieved with the physics engine?
Thanks.

Re: Simple physics question...i think [Re: demiGod] #111337
02/07/07 19:36
02/07/07 19:36
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
maybe check at which point you want your ball to begin decelerating, based on the distance given you can calculate the amount of force needed to slow down the ball at to a full stop at the given point


BASIC programmers never die, they GOSUB and don't RETURN.
Re: Simple physics question...i think [Re: bstudio] #111338
02/07/07 21:51
02/07/07 21:51
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
How am i suppose to do that, not taking in count the mass, the friction, the linear and angular velocity, if the ball is rolling or sliding?

Re: Simple physics question...i think [Re: demiGod] #111339
02/08/07 09:20
02/08/07 09:20
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
well this would require a rather complex (well for me that is) mathematical formula. When i posted my other post I had something in mind, just have to work out how to make it work


BASIC programmers never die, they GOSUB and don't RETURN.
Re: Simple physics question...i think [Re: bstudio] #111340
02/08/07 21:06
02/08/07 21:06
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hey, any ideas?

Re: Simple physics question...i think [Re: demiGod] #111341
02/14/07 21:49
02/14/07 21:49
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
Hi there,
This is very experimental and I have no clue if it is of use for you.

First of all you have to test out, how much force is needed to reach a given position.
Then use a force calculated by the distance between the object and the given position.

if(vec_dist(object, given_position) >= 100) && (vec_dist(object, given_position) <= 200)
{
force.x = 10;
force.y = 0;
force.z = 0;

}

if(vec_dist(object, given_position) >= 200) && (vec_dist(object, given_position) <= 300)
{
force.x = 20;
force.y = 0;
force.z = 0;

}

phent_addvellocal(object, force);

...

This can and will be inaccurately. You have to use Tracing(for example scan_entity) to find out if the object is
very near the given position. If so you will have to use a force or a sticky thing to bind
the object to the given position.

as I mentioned already, very experimental but maybe of use for you

cheers

zwecklos

Last edited by zwecklos; 02/14/07 21:52.
Re: Simple physics question...i think [Re: zwecklos] #111342
02/15/07 15:50
02/15/07 15:50
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi zwecklos, thanks for your answer.
I see what you mean but like you said its a inaccurate solution and i need something more reliable.

I have been messing with this problem more time than i really liked too, because there is no true support for the physics engine here.
Actually there is no support elsewhere cause i made many researches in the web and the ODE support really sucks and there is no examples we can actually adapt to use in the 3dgs PE.

Of course there are people who knows how to do it the right way, considering all the variables but simply dont put it here, probably because it envolves complicated formulas and gave it him much much work.

Well, too bad for those who dont have serious physics knowledge..

Re: Simple physics question...i think [Re: demiGod] #111343
02/28/07 22:34
02/28/07 22:34
Joined: Mar 2005
Posts: 514
Brazil
Carloos Offline
User
Carloos  Offline
User

Joined: Mar 2005
Posts: 514
Brazil
I dont know if you still need a solution for this, I would be glad to help with code, but my edition doesnt have physics, I use sometimes newton and sometimes I made my own physics, and, make my own physics sometimes has much to do with experimentation.

One thing I can point you to, is an ideia I have and is the same logic I use sometimes to achieve some results for other similar physics problems.

I think you can work with some simple experiment to obtain a "magic" constant. How ?

Define any physics properties you want for your ball. Using this method doenst matter if the ball is heavy or light. You can make the same experiment with different mass values, and any other different values, to get sample values to different physical properties.

Place the ball in a flat surface and apply a force in any direction.

Then, get the inicial force applied, and the distance the ball was able to move with the amount of force you applied.

After this, you will have a very close value of "how much force to dixtance X" , that can be used as a constant to get forces needed to different distances with very simple math.

keep in mind also that any slopes in the surface will have influence in the final ball position, so this applies only to very smooth surfaces.

You can also use the same method and change one value per time, such as increasing only the mass and applying the force to see how the mass change affects the result of movement. This will help you to understand how that especifically value influences the simulation overall result.

Hope my idea can help you.

Last edited by Carloos; 02/28/07 22:37.
Re: Simple physics question...i think [Re: Carloos] #111344
02/28/07 23:05
02/28/07 23:05
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi Carloos, thank you for your reply and yes, i still need a solution for this question.

I see exactly what you mean and i had ran so many tests with this idea in mind:
Find a proportional factor between the force / velocity applied to the object and the given distance it will cover.

Actually, the surface i am using it just flat, no slopes and i can tell the result of my tests:

- imagine you apply 100 units of velocity (phent_addcentralvel) and the sphere covers exactly 1000 quants distance. Each time apply it, the ball always covers 1000 quants, so no big deal;

- the problem is, if you apply it 200 units of vel the ball will not cover 2000 quants of distance, but a little more and if you apply 300 the distance will be almost 3500 quants (depending on friction, elasticity, damping, etc that are applied to it);

- so, this is not a precise solution and this is also very stupid cause i didnt understand yet why this system fluctuation occours;

- then, because there is almost no information about the internal function system of the ODE solver around here, there is a big task trying to understand how can i use the object properties and manipulate them in order to obtain a precise future position prediction, or deal with interception algorithms, or time to cover a given distance;

If i had enough physics knowledge i would make a sphere / ball physics system from scratch and throw away the PE, too bad i have not such skill..

Well Carloos, thank you anyway for your idea and considerations.
Cheers.

Re: Simple physics question...i think [Re: demiGod] #111345
02/28/07 23:57
02/28/07 23:57
Joined: Mar 2005
Posts: 514
Brazil
Carloos Offline
User
Carloos  Offline
User

Joined: Mar 2005
Posts: 514
Brazil
Quote:


- the problem is, if you apply it 200 units of vel the ball will not cover 2000 quants of distance, but a little more and if you apply 300 the distance will be almost 3500 quants (depending on friction, elasticity, damping, etc that are applied to it);





Its not a system flutuation. The ODE system behaves aproximating real life situations.

The case is, when you apply bigger forces to the ball, it acumulates more dinamical forces, so, it will get more space to stop completely, and this is the way real physics happen. so :

100 units = 1000 quants
200 units = 2500 quants ( as an example )

The 500 quants added to the distance of the movement is just the force, being bigger, makes the inercial forces take more time to stop the ball.
Still so I think this is enough to get the factor behind it.

Anyway I´m interested in this also, and will try to give some workaraound when I get something, if you want.

Page 1 of 2 1 2

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