Rectangular vectors, angular physics

Started by
5 comments, last by Splinter of Chaos 13 years, 10 months ago
It's been a little while since physics class, but not too long... Anyway, in my game, i have these stick men inside a circle. As far as collision detection or physics is concerned, the stick men are represented as points and the circle is a circle. The stick man, point, spawns inside the circle, and is pulled by gravity until it hits the circumference. It then, ideally, should be pulled by gravity down the slope of the circle. Friction isn't a feature i care about, yet. I was able to get the code working such that the stick men are pulled by gravity and while on the rim of the circle a normal force sums up to a force tangent to the circle. This means that every frame, my stick men move slowly away from the center of the circle. What i need is a centripetal force, but i'm using a linear one. I understand the equations and basics, but i believe my problem to be not having a good understanding of how to relate the linear data (position, velocity, acceleration) to angular data. Even if i can produce a tangential acceleration, i can't understand how to product angular motion. I believe my problem to be similar to a pendulum and there are a lot of physics examples i found through google for that, but i wasn't able to produce the expected results at all. I'd show what i've written, but i haven't written anything worth not erasing. I'd be grateful for some sources on this. Right now, i'm trying to get the stick man physics right, but eventually i'll be making the circle a physical object as well and complexities like colliding with sticks and circle while maintaining system momentum will be keeping me up at night. So, sources that go beyond the scope of this discussion are appreciated.
Advertisement
*bump*

Is there any way i can better describe the problem so i can get help on this? As mentioned, i believe the math should be the same as a pendulum. If i have a pendulum at point P1 and gravity & tension (or normal) are the two forces acting on it, can anyone help my find P2 given an arbitrary change in time?

Of course, this isn't a physics simulation, it's a game. I'm looking for a reasonable algorithm, not an accurate one. (Does that help?)
The way I had cetrifugal/cenripetal forces explained to me, was that they're "emergent" from linear forces.

Take the earth orbiting the sun, it has a huge momentum propelling it tangential to the sun's surface, and gravity accelerates it towards the suns surface. That's two linear directions at 90º to each other.
Taking "one step" in this simulation, we add the acceleration to the velocity, which bends the velocity slightly towards the sun, and then move the earth in that direction. On the next step of the sim, the earth has coincidentally moved into a position where it's velocity is once again tangential to the suns surface, and the process repeats.
The whole "angular force" is just an illusion that arises from the repeated application of the linear forces.


So if you've got the constant downward force of gravity, a "reaction force" from bouncing off your circle, and a build up of momentum/velocity, then assuming the direction of the "reaction force" changes based on position, you should be able to get angular effects to "emerge".
There is no torque present in the simulation you described. (angular force == torque)

Now if your men consisted of two points, each point having it's own normal force applied to it, at an offset from the center of mass (between the two points) a torque would be generated for each point, and a net angular acceleration would present itself.

This is what happens when a box slides down the rim. The normal forces are applied at each corner, the difference from the center of mass is a torque arm and the resultant angular acceleration can be computed.

If your men are represented as a single point, with linear forces applied to the center of mass, there will never be any rotation. Only once the force is applied offset from the center can torque happen.

Centripetal force has little to do with the issue you're having.

Two quickly fake the rotation by just aligning your men so that their "up" direction is aligned to the rim normal when they're in contact.
Quote:Original post by Hodgman
Taking "one step" in this simulation, we add the acceleration to the velocity, which bends the velocity slightly towards the sun, and then move the earth in that direction. On the next step of the sim, the earth has coincidentally moved into a position where it's velocity is once again tangential to the suns surface, and the process repeats.


Sounds correct. My problem, then, is figuring an acceleration that causes this behavior. I can properly figure the normal force and when added to its weight does produce a tangential acceleration, but i don't understand how to derive that normal force, how it changes over time.

Quote:Original post by bzroom
Centripetal force has little to do with the issue you're having.


Correct. I misspoke.

Quote:Two quickly fake the rotation by just aligning your men so that their "up" direction is aligned to the rim normal when they're in contact.


When i tried that technique, the stick men behaved unpredictably. Sometimes seeming hindered by the friction i haven't programmed yet, sometimes accelerating for no reason. I believe this was because the velocity would think the stick man was going tangential, when it's really being pushed into the circle.

I'm convinced the only real solution to this problem involves properly solving for acceleration.
Quote:Original post by Splinter of Chaos
When i tried that technique, the stick men behaved unpredictably. Sometimes seeming hindered by the friction i haven't programmed yet, sometimes accelerating for no reason. I believe this was because the velocity would think the stick man was going tangential, when it's really being pushed into the circle.


You should start by figuring out why this happens. It's the simplest of all the methods. (and i'm still not sure you're on the right track with the other stuff, so stick here for a second while you figure this vector math stuff out)

Using the method i'm describing, the orientation of the characters is not dependent on any physical property other than their position. That is, it's not dependent on the velocity, direction, acceleration, force, none of that. Only the position around the rim of the environment.

If you drew a vector from the character to the center of the circle which describes the rim. this is the character's up vector. His head should always be pointing in this direction which would put his feet on the rim. Figure out how to properly compute the angle of that vector and set this to be the rotation angle of your characters.

(The vector drawn is collinear with the rim's normal for the same point, so either will suffice)

Yeah it is the simplest of methods, alright. And i realized the amount the stick man moves away from the center is incredibly small, only noticeable after a couple of minutes of gameplay, depending on the intensity of gravity, so i found that every 100 times the function is called, if it re-calculates the stick-person's position, the physics don't get screwy and my bug isn't much a problem.

Though, i'm not sure that just because i've found an easy solution to my problem now, it won't resurface later, like when i make the circle a physical object as well. Oh well, if the problem erupts again, i'll deal with it then, again.

This topic is closed to new replies.

Advertisement