Slopes? As in, a sloped surface? Or finding the slope of a function?
For a sloped surface, well, lets talk some physics for a second.
For every force exerted there is an equal and opposite force that is also exerted on the thing that originally exerts the force. This is Newton's 3rd law (IIRC). We also need to consider Newton's 2nd law, which states that Force is proportional to the change in it's momentum in a given time; For our purposes, just remember that
Force is mass x acceleration., or F
net = ma. This also works for the components (basically, what part of the vector is along a single axis, either x, y, or z), so F
net,z = maz for example.
Why is this part important? Lets say you have a mass of 60kg and you are standing on a perfectly flat surface. Because there is gravity, you have weight (W, or F
g), which is a force. This force (your weight) will equal
roughly 600 Newtons (kg*m/s/s [kilogram meters per second per second]) because the acceleration due to Earth's gravity is 9.8 meters per second per second (m/s/s). This is Newton's 2nd law.
When trying to figure out where these things are going, you need to identify what the acceleration of the object is.
Now, if you are imparting a force on the Earth and have acceleration, why aren't you moving through the ground or free falling? This is where Newton's 3rd law comes in. Your mass is exerting a force (your weight) on the earth and the earth is also exerting a force on you - this is called the normal force (F
n) and is exactly equal to your weight. Let's draw a force diagram for this.

So that means that this mass is perfectly balanced while sitting there by itself. But what happens when we sit it on an incline?
Something I didn't mention before - the normal force is always perpendicular to the surface that the force is being applied to. So if our object is on an incline than the force diagram will look like this,
assuming there is no friction:

Notice now that the normal force is pointing off in a different direction (in this case the incline is at an angle of 45 degrees) - perpendicular to the incline. The normal force is no longer canceling out the force of gravity; in fact, the y component of the gravitation force is greater than the upward force produced by the normal force. The normal force is also pointing away from the incline, which means that there will be some force on the x-axis. What does all of this mean?
Yup, the object will slide down the incline. But how do we determine the net force of the object?
The easy way is to just remember this formula:
Fnet = Fg * sinθ, where θ is the degree of the incline. If you want a detailed description of how I got this, PM me.
Back to our example; suppose you weigh 60kg and are lying on a frictionless 45 degree incline. Assuming you aren't clinging onto the incline for dear life, you would be sliding down the incline with roughly 424.26 Newtons of force: F
net = ( 60
x 10 )
x sin(45) = 600
x 0.707 = 424.26. From here you can find your acceleration by using F
net = ma; your acceleration would end up being 7.071 m/s/s.
Luckily, adding friction is really simple. To begin, there are two kinds of frictional force; static friction and kinetic friction.
A good example to explain these two types of friction is that of a crate on a surface with friction. If you lightly tap the crate, it probably will not move. If you continue to push the crate a little bit harder, it still will not move. However, if you put every ounce of energy you can into moving it, the object will begin to move, although it feels as if something is lightly pushing the crate back towards you; not enough to make it impossible to move, but it still isn't incredibly easy to move.
The friction that you experience just before the crate begins to move is the static friction; as soon as you reach that maximum amount of static friction the object will begin to move and you will be experiencing kinetic friction. Kinetic friction is light opposing force you feel while moving the crate.
In picture form:
Where the x-axis represents the amount of force you exert and the y axis represents the amount of force the crate exerts back through friction. Basically, at any point before the maximum static friction, the object will stay put. Any point after that and it will move.
The math behind determining these forces is very easy. What makes this even easier is that the frictional force is perpendicular to the incline or surface; The net force is just the force of the object minus the friction.
The maximum force of static friction is determined by the function f
μs,max = μs*Fn. Because an object does not move while under the influence of static friction, the net force is always 0 in these instances and there is no acceleration.
The force of kinetic energy is determined by the function f
μk = μk*Fn. In this case there is a net force (since the object is moving) and this can be determined by subtracting the force of the object sliding down the incline ( F = F
g * sinθ ) by the frictional force and setting it equal to the net force. So...
F
net = F
g x sinθ -
μk x Fn
If we wanted to find the acceleration of the object we could combine this with the formula for net acceleration like so....
F
net = ma
F
net = F
g x sinθ -
μk x Fn
ma = ( ( m
x g )
x sinθ ) - (
μk x( m x g ) )
a = g x sinθ - ( μk x g)
There you go. You now have the acceleration of the object.
"But, umm...How does this relate to Flash again?"
Using the following formulas you can get the displacement, velocity or acceleration as long as you have a few of the others. I'll let you figure the algebra part.
(note: these functions only work when acceleration is constant)
v = v0 + at; missing (x - x0)
x - x0 = v0t + (at^2)/2; missing v
v^2 = v0^2 + 2a(x - x0); missing t
x - x0 = ((v0 + v)t)/ 2; missing a
x - x0 = vt - (at^2)/2; missing v0
Where anything with a 0 following it is the starting value ( I guess it could also be the value as of last rendered frame; not sure about that though ).
For the programming part, I'm honestly not sure how you should go about implementing that. From a lesson I sat in during a visit to Digipen I heard that one way to go about doing that would be to make a list of forces for every object that is moving, add those up at the end of a frame, find the acceleration and displace the object based off of that. Other than that, I really don't know.
I'll leave you to figure out the rest :P.
Bookmarks