Archived

This topic is now archived and is closed to further replies.

ogracian

Newton's law...

Recommended Posts

ogracian    180
Hello I am trying to write an application wich simulate a box sliding down a slope, using real physics, but I am having troubles with it, in how can I compute the surface''s normal force of reaction, so I dont know how to get my total forces acting over my system. Here is a Diagram : \0 (Sliding box) \ \ \ \ \ ------ \ SLOPE So the data wich I count is as follows: I know my cube mass, so I got W = mg the slope angle is 45* the cube is sliding down from rest. I really appreciate if someone could help me with this, maybe some formulas will be great!. PS: I am trying to do this in 3D using vector math. Thanks in advance! Oscar

Share this post


Link to post
Share on other sites
R3sistance    122
you have consider the fact that gravity = 9.82, angle 45 and weigth. have you consided that ever force has an opposite force in this case you need three line that should look like

---\
---o===
---|
---|
downwards you have gravity time weight of the object. left you have the direction created by the slope and the 3rd line in the opposing force to the other to items which include friction and air resistance. most people don't include air resistance. hope this help . my diagram isn't appearing as it should .

Edited by - R3sistance on October 5, 2001 7:41:32 AM

Share this post


Link to post
Share on other sites
furby100    102
What happens is that gravity pulls the block downwards into the slope. The slope then pushes in the direction of its normal. The upward component of the slope''s force will equal gravity and then you can work out the sideways force which pushes the block sideways.

Share this post


Link to post
Share on other sites
Fresh    122
Hullo.

You know that the box will either remain stationary or accelerate down the slope. This is because the normal reaction will always equal whatever force the box applies perpendicular to the slope.

So it will not acceleration to, or from the slope, as there is no net force. It may accelerate down the slope however, if there is a net force down the slope.

Let''s define some things we will need:

m = mass of box (kg)
g = gravitational field strength (9.81 N/kg)
a = angle of the slope
u = coefficient of friction
F = the frictional force (acts in the opposite direction to motion)
N = the normal reaction (equal and oppsite to the force applied by the box perpendicular to the slope)

Ok, you know that ''net force = mass * acceleration.'' (for a constant mass).

We know the force, we know the mass, we want the acceleration.

Let''s first compute the net force. We will resolve down the slope so we will get an acceleration to apply down the slope (signs will therefore not become a problem).

Ok, you should know that the frictional force is given by the coefficient of friction multiplied by the normal reaction, in the direction opposing motion.
F = uN, where 0 <= u <= 1.

The force down the slope due to the weight of the box is m*g*sin(a). The normal reaction is given by m*g*cos(a). However, it has no effect when resolving perpendicular to it, which we are. What it does affect is the frictional force, which is uN. Hence the frictional force is u*(m*g*cos(a)).

So, net force down the slope = m*g*sin(a)-u*m*g*cos(a).
i.e. net force down the sope = m*g(sin(a) - u*cos(a)).

We know to produce acceleration we divide by mass, m.

So acceleration *down* the *slope* = g(sin(a) - u*cos(a)).

This may or may not be immediately applicable to your box and slope world. This is the magnitude of an acceleration vector, the direction of which will be equivalent to the slope. I''ll assume you know how to split up the magnitude into its i and j components given its direction. You can then move the box in its 2d plane. But I''ve no idea how your simulation works.

There''s the physics though. If you need more help, ask again.

r.




"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."

Share this post


Link to post
Share on other sites
core    106
<anal retentive>

I believe a Newton is 1 kilogram per meter, 1kg/m = 1N.
You made a simple error of using N/kg.

</anal retentive>

Share this post


Link to post
Share on other sites
ogracian    180
Thank you all for all your help, but unfortunatly I still having troubles simulating it, so I post my code here hopping if some one could help me:

PS: I am doing this without friction;

#define PI 3.141516

int controlador;
int modo;

float i = 0.0f;
int angle = 90 - 45;
float mass = 2000.0f;
float gravity = 9.8f;
float velx = 0.0f;
float vely = 0.0f;
float accelx = 0.0f;
float accely = 0.0f;
float xpos = 10.0f;
float ypos = 110.0f;
float Fx = 0.0f;
float Fy = 0.0f;
float weight = 0.0f;

void main()
{
controlador = DETECT;
modo = DETECT;
initgraph(&controlador, &modo, "");
setfillstyle(1,BLACK);
bar(0,0,640,480);

// Draw terrain
setcolor(2);
line(10, 110, 310, 410);

//
// Draw ball
setcolor(1);
circle((int)(xpos), (int)(ypos), 10);

//
// wait a key to begin sim
getch();

//
// Compute Forces
weight = mass * gravity;
Fx = weight * sin((float)(angle)*PI/180.0f);
Fy = weight * cos((float)(angle)*PI/180.0f);

for (; i < 30; i+=0.1f)
{
//
// Compute ball accel
accelx = Fx / mass;
accely = Fy / mass;

//
// Compute velocity
velx = velx + accelx * i;
vely = vely + accely * i;

//
// Update ball''s pos
xpos = xpos + velx * i;
ypos = ypos + vely * i;

//
// Draw objects
setcolor(2);
line(10, 110, 310, 410);
setcolor(1);
circle((int)(xpos), (int)(ypos), 10);

delay(50);

if (kbhit())
break;
}
getch();
closegraph();
}

PS: I am using Turbo C++.

Thanks!


Share this post


Link to post
Share on other sites
nickm    122
Let me explain this to you by using a so-called `model´. You cannot copy-paste this in your code I´m afraid (I just don´t feel like reading all this code ;-) ), but here´s how you could do the physics part in c++.

#include

float t, Fg, F, a, v, s, x, y, m; // time, gravity force, force, acceleration, speed, position, coordinates and mass
float dt, dv, ds, dx, dy; // the d should be a greek delta here, but these variables represent delta-time, delta-velocity, delta-space, delta-x and and delta-y
const float angle = 50.0 * M_PI / 180.0; // horizontal = 0°, convert degrees to radians
const float m = 20.0; // mass in kgs



t = 0.0;
a = 0.0;
v = 0.0;
s = 0.0;
x = 0.0;
y = 10.0; // start at 10 meters
dt = 0.1; // you could change dt in 1 / 30 at a 30 fps framerate for example. Smaller numbers make it more accurate



while(1)
{

// increment the time.
t = t + dt;

// calculate the forces on the box. I am using a somewhat different approach then Fresh (this one''s easier), but I think it''s a valid way to solve this problem... correct me if it is not or if I''m forgetting anything
Fz = 9.81 * m;

// calculate the force down the slope, by splitting up Fz in components of which one heads in the same direction as the slope does
F = cos(angle) * Fz;

// here you could subtract are resistance, but in most cases this is not really important. It becomes important at speeds above approximately 40 m/s.
F = F - 0.0;

// calculate the acceleration, F = m . a
a = F / m;

// now the acceleration has been calculated calculate speed and position
dv = dt * a;
v = v + dv;

ds = dt * v;
s = s + ds;

// split up the delta-distance vector (direction angle), and calculate the real (onscreen) position
dx = cos(angle) * ds;
dy = sin(angle) * ds;

x = x + dx;
y = y + dy;

// use the variables, draw something, etc.

}



Here you go. As you can see, it´s an infinite slope, but changing that shouldn´t be difficult. Probably there are some syntax errors, but I think this code is useable. Good luck!

Nick

Share this post


Link to post
Share on other sites
R3sistance    122
Actual n or newtons are proptional to gravity if you are on the moon the value for 1 newton is different to the value of n on the Earth. on earth 1 newton equals one kilogram.

Share this post


Link to post
Share on other sites
E-we    122
I just can't let this slip by unnoticed

The gravity constant(on earth) is not 9.81 m/s^2
It should be g = 9.82 m/s^2

=)



EDIT: Though one Newton is allway one newton, not depending on planet/gravity. It is a measure of force. Thus the force i.g. may vary depending on the gravity of the location.


Edited by - E-we on October 9, 2001 4:47:58 AM

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
quote:
Original post by E-we
I just can''t let this slip by unnoticed

The gravity constant(on earth) is not 9.81 m/s^2
It should be g = 9.82 m/s^2

=)



If you want to get picky about things, , then you should consider that gravitational acceleration is NOT 9.81 or 9.82 m/s2! It depends on where you are and both of those values are valid somewhere. At the equator, it is roughly 9.78 m/s2, while at the poles it is roughly 9.83 m/s2. Check out this reference page on the web site for NASA''s Goddard Space Flight Center:

http://helios.gsfc.nasa.gov/qa_earth.html#earth

But I admire your mind for perfection, which reminds me of myself, .

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Scarab0    122
quote:
Original post by grhodes_at_work
If you want to get picky about things, , then you should consider that gravitational acceleration is NOT 9.81 or 9.82 m/s2! It depends on where you are and both of those values are valid somewhere. At the equator, it is roughly 9.78 m/s2, while at the poles it is roughly 9.83 m/s2. Check out this reference page on the web site for NASA''s Goddard Space Flight Center:

http://helios.gsfc.nasa.gov/qa_earth.html#earth

But I admire your mind for perfection, which reminds me of myself, .



Yeah if you want your box to be sliding realistically you should use Fz = G * (m*M)/r2 where G = 6.6726*10-11 Nm2kg-2, m is your box''s mass in kg, M is the mass of the Earth (5.976*1024 kg), and r is the distance from your cube to the Earth''s center of mass in m.

Also, you should model box-air and box-slope frictional forces for total accuracy. And of course all the forces that I forgot to mention.


LOL

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by Scarab0
[quote]Original post by grhodes_at_work
If you want to get picky about things, , then you should consider that gravitational acceleration is NOT 9.81 or 9.82 m/s2! It depends on where you are and both of those values are valid somewhere. At the equator, it is roughly 9.78 m/s2, while at the poles it is roughly 9.83 m/s2. Check out this reference page on the web site for NASA''s Goddard Space Flight Center:

http://helios.gsfc.nasa.gov/qa_earth.html#earth

But I admire your mind for perfection, which reminds me of myself, .



Yeah if you want your box to be sliding realistically you should use Fz = G * (m*M)/r2 where G = 6.6726*10-11 Nm2kg-2, m is your box''s mass in kg, M is the mass of the Earth (5.976*1024 kg), and r is the distance from your cube to the Earth''s center of mass in m.

Also, you should model box-air and box-slope frictional forces for total accuracy. And of course all the forces that I forgot to mention.


LOL


And you''d have to include some trig there, since the center of mass of the earth is not necessarily aligned with your Z axis.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by Scarab0
[quote]Original post by grhodes_at_work
If you want to get picky about things, , then you should consider that gravitational acceleration is NOT 9.81 or 9.82 m/s2! It depends on where you are and both of those values are valid somewhere. At the equator, it is roughly 9.78 m/s2, while at the poles it is roughly 9.83 m/s2. Check out this reference page on the web site for NASA''s Goddard Space Flight Center:

http://helios.gsfc.nasa.gov/qa_earth.html#earth

But I admire your mind for perfection, which reminds me of myself, .



Yeah if you want your box to be sliding realistically you should use Fz = G * (m*M)/r2 where G = 6.6726*10-11 Nm2kg-2, m is your box''s mass in kg, M is the mass of the Earth (5.976*1024 kg), and r is the distance from your cube to the Earth''s center of mass in m.

Also, you should model box-air and box-slope frictional forces for total accuracy. And of course all the forces that I forgot to mention.


LOL


And you''d have to include some trig there, since the vector to the center of mass of the earth is not necessarily aligned with your Z axis.

Share this post


Link to post
Share on other sites
Scarab0    122
quote:
Original post by Anonymous Poster
And you''d have to include some trig there, since the vector to the center of mass of the earth is not necessarily aligned with your Z axis.


It''s not???

Share this post


Link to post
Share on other sites
Shannon Barber    1681
quote:

quote:
--------------------------------------------------------------------------------
Original post by Anonymous Poster
And you''d have to include some trig there, since the vector to the center of mass of the earth is not necessarily aligned with your Z axis.
--------------------------------------------------------------------------------



It''s not???



Though close, the Earth is not a perfect sphere - particularily if you''re hanging side-ways off a mountain.

9.81-9.83, I never knew g varied that much across the globle...

Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Scarab0    122
quote:
Original post by grhodes_at_work
Perhaps g = 9.8 m/s2 will be close enough for games?


Why use meters in games anyway? I usually stick to units/second or pixels/second for velocities.

Share this post


Link to post
Share on other sites
nickm    122
It´s much easier to convert to pixels or whatever after calculating everything you need. This way you can just apply physics in an easier way (newton and others have thought of the formulas already ;-) ), the only thing you need to do is to apply these formulas. Otherwise you would have to come up with new measuring units (pixels per second) for velocity, pixels per second per second for acceleration, and kg.pixels.s^-2 for force. So with all these new units, how would you call them? Force is easy (call it after yourself .. newton did! :-)), but for the others you''ll have to come up with other names to keep things clear.
I admit, it is possible to do it that way, but it´s not the easiest way to go.

Share this post


Link to post
Share on other sites
Dracoliche    122
You don''t need new names for units. No-one stores velocities as 100 ms^-1 anyway, they just store it as 100. As long as you use the same unit of length for everything, the mathematics is exactly the same as with metres. The same if you use frames instead of seconds, ''weight units'' instead of kilograms (I know that doesn''t really add up ), or anything else. Constants will need to be recalculated, of course, but you can use trial and error until they look right if you don''t feel like working them out.

Share this post


Link to post
Share on other sites