Skip to main content
GameDev.net gamedev.net
🔒 Locked

The Normal Force (3D Inclined Plane)

Started by c0der_ Jan 10, 2011 at 10:29 PM 3 replies 6.8k views
Original Post
c0der_
c0der_
Hi,

I am simulating a particle travelling down a 3D inclined plane. In OpenGL you rotate about the z axis, to rotate about the y axis in spherical coordinates. The code below works as it is, but isn't it supposed to be that the YAngle, being the angle of phi (starting from the positive y axis to the negative y axis) in spherical coords is supposed to be PI/2-rYAngle, to get it to be the actual angle of the plane?

|y
|
|______x
/
/z

Here is the code for computing the normal force in 3D:

Vector4 ParticleForceUpdater::computeNormalForce(Particle *pParticle, real rXZAngle, real rYAngle)
{
real rGravity = GRAVITY_CONSTANT * pParticle->getMass();
real rNormal = rGravity * real_cos(rYAngle);

Vector4 vNormalForce;
vNormalForce.x = -rNormal * real_cos(rXZAngle) * real_sin(rYAngle);
vNormalForce.y = rNormal * real_cos(rYAngle);
vNormalForce.z = rNormal * real_sin(rXZAngle) * real_sin(rYAngle);

[color="#0000ff"][color="#0000ff"] return vNormalForce;
}



Zakwayda
Zakwayda
In OpenGL you rotate about the z axis, to rotate about the y axis in spherical coordinates.[/quote]
Although I'm not entirely sure what you mean by this, I can tell you with almost complete certainty that it's wrong. OpenGL doesn't care what axis you rotate around, and it certainly doesn't impose any restrictions or have any implications regarding spherical coordinate conversions.

In short, you can perform a spherical coordinate conversion using whatever conventions you prefer; the fact that you're using OpenGL makes no difference. (Also, it's more common to solve this sort of problem using vector math than using angles and trigonometry. Is there any particular reason you feel angles need to be involved?)
c0der_
c0der_
Because since gravity points straight down, the normal force is dependant upon the angle of inclination of the surface, so I am resolving each component of the normal force and in the end, I use vector addition to get the total net force to apply to the particle. How would you work out the normal force using vector math alone?
Zakwayda
Zakwayda

Because since gravity points straight down, the normal force is dependant upon the angle of inclination of the surface, so I am resolving each component of the normal force and in the end, I use vector addition to get the total net force to apply to the particle. How would you work out the normal force using vector math alone?

Ok, I'm looking at the Wikipedia article, here. The article gives the magnitude of the normal force as:

N = mgcos(?)

Let's say for the sake of example that +y is up. Since for two unit-length vectors dot(a, b) = cos(angle(a, b)), we know that:

cos(?) = dot(surface_normal, y_axis) = surface_normal.y

Therefore, if I'm not mistaken, you can simply plug that in for cos(?) in the original equation, and thereby solve for N using vector math rather than trig.

Also, if you check out the article, there's a section entitled 'Using vectors' that discusses how to solve the problem using vector math. (The article goes a little more in-depth though and computes the normal force in terms of the surface normal and the 'stress tensor'.)
Emergent
Emergent
The net force is just the linear projection of the gravitational force onto the constraint plane.

If n is a plane's (unit-length) normal, then, for any vector v, the vector <v, n>n is the projection of v onto the orthogonal complement to the plane, and the vector v - n is its projection onto the plane. Notice that these two vectors add up to v itself. Here, I use angle brackets to denote inner ("dot") products; i.e., for any vectors a and b, I use <a, b> to denote the inner product of a with b.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.