Newton's law...

Started by
24 comments, last by ogracian 22 years, 6 months ago
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
Advertisement
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
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.
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..."
<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>
No, I think it´s 1N = 1kg ms^-2,
because F = m.a, and m is expressed in kgs, and a is expressed in ms^-2
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!


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
Hello

Thank you nickm for your replay, I will try your method.

Thanks for your help.
Oscar
There´s a little mistake in my code, the line

F = cos(angle) * Fz;

should read

F = sin(angle) * Fz;

This topic is closed to new replies.

Advertisement