Advertisement

How can this Physics Trouble be simulated?

Started by May 24, 2001 11:10 PM
10 comments, last by ogracian 23 years, 8 months ago
Hello I am trying to do a 3D simulation of a ball rolling over a simple 3D terrain but I am having troubles with it, so I really appreciate if any could help me with this.. Well my troubles is that I want to simulate the rolling ball physics with gravity and friction, I mean, if the ball is rolling down a hill it must incres its velocity, and if it is rolling up a hill, it must decres its velocity. Some one told me that it can be solved using vectors but I am really stuck with it, so I really appreciate any help, Thanks!
Ahh, the physics.

When something falls straight down, ignoring the forces of friction, the acceleration is 9.8 m/s on Earth. If you are talking about a hill, you have to know the angle in which it is tilted and separate the X and Y components to figure out the results. Give me some example problems and I could show you through the examples.
Advertisement
Have you taken a physics class before? I hate to tell you this, but if you haven't, or if you haven't taken some sort of Trigonometry (SP?) class, you are going to have a lot of stuff that is going to be really confusing to do.
Personally, I would suggest you either take a physics class, or read some books on physics. I know that doesn't really help your problem much, But I just wanted to say that you'd have an easier time if with this, and other things, if you had a good understanding of physics and knew some of the formulas. I'd try to tell you some of the formulas that would help you, but it's midnight where I am, and my screen has become a blur...
Hope I have helped, or atleast not confused you much.

Drakonite


[Insert Witty Signature Here]

Edited by - Drakonite on May 24, 2001 12:47:53 AM
Shoot Pixels Not People
Hello Thanks for your response.

Well supouse I have a Simple 3D Terrain in the Following way (Side View)

O ------->
_________
\ ________________
\ /
\ /
\ /
\_______________/

Well my trouble is how can I obtain the correct Velocity of my Ball?

About the Angle, I know the point in which my Ball collides with the Terrain, and it give me the Normal to collision plane, so I was thinking if I can obtain the Angle using the Normal of the Collision Plane, as you see I am really stuck with it so I really need help, thanks!

PS: I was thinking if is posible to derive some general formula to get the ball''s velocity, instead of have to separate each component (X, Y, Z)?
It's quite simple, really. You have three vectors for your ball (assuming you don't want to make the ball actually rotate when it goes down a hill - that's much harder).

You have, position, velocity and acceleration. Each time you draw the ball, you add it's velocity * time_since_last_frame to the position, acceleration * time_since_last_frame to the velocity, and total_forces * time_since_last_frame to the acceleration.

Then, to make it look right, you just need to know all the forces acting on it. If it's in the air, then the only force (ignoring wind resistance) is gravity, and it's magnitude is 9.8 * balls_mass.

If it's on flat ground, then forces are gravity (as above) and a normal force, equal to the force of gravity, but in the opposite direction.

If it's on a slope, there are three forces, gravity, as above, the normal force which acts tangential to the surface, with the same magnitude as gravity, and friction, which acts opposite to the ball's velocity, and proportional to the velocity and some constant for the surface (so rubber has higher friction than glass)

Here's a diagram to show you what I mean:



To get the final force, you just add all the contributing forces together.


War Worlds - A 3D Real-Time Strategy game in development.

Edited by - Dean Harding on May 25, 2001 1:01:30 AM
About the Terrain Image, sorry I dont know why it looks that Way, It must be a Terrain with a Hill in a Side Way.

Here is other Try of the Side View, Hope it looks ok.

O -------->
________________
,,,,,,,,,,,,,,,,\
,,,,,,,,,,,,,,,,,\
,,,,,,,,,,,,,,,,,,\
,,,,,,,,,,,,,,,,,,,\___________________

About the physics class, yes I have taken some physics calss I now which formulas need I to apply but I am Trying to resolve it using Vectors and I having some troubles with the computer simulation, so it is why I need some Help.

Advertisement
Just further to my first post, acceleration is actually total_forces / mass.

Anyway, that''s apparently not what you''re after. You want a way to represent vectors, yes?

Try this:

  class Vector{public:    float x, y, z;    Vector( float x, float y, float z )       : x( x ), y( y ), z( z )    {}    Vector operator + ( const Vector &v ) { return Vector( x + v.x, y + v.y, z + v.z ); }    Vector operator - ( const Vector &v ) { return Vector( x - v.x, y - v.y, z - v.z ); }    Vector operator * ( const float s ) { return Vector( x * s, y * s, z * s ); }    // more methods here.};// now vector operations are done like:Vector v1( 1, 2, 3 ), v2( 10, 2, 1 );Vector v3 = v1 + v2;  


This is really basic C++. If you don''t understand this, you should get yourself a book on C++ (I hear "Teach Yourself C++ in 21 Days" is quite good). If you''re not using C++, then it''s a bit more compilcated. You need a vector struct, and methods that will add, subtract, multiply by scalar, etc.


War Worlds - A 3D Real-Time Strategy game in development.
Hello

Thanks so much for all your responses.

To Dean Harding, Yes! your first replay was exactly what I was looking for but maybe I dont expres well, I mean I was trying to Resolve the Physics formulas using Vectors Math instead of compute each Force Component with Sin and Cos of angel.

Well about your First Replay I have just one more question:

you said:
" If it''s on a slope, there are three forces, gravity, as above, the normal force which acts tangential to the surface, with the same magnitude as gravity, and friction, which acts opposite to the ball''s velocity, and proportional to the velocity and some constant for the surface (so rubber has higher friction than glass) "

Well my trouble is To add all three Forces (Gravity, Normal, and Friction), Need it to be Normalized first, or just I need to add the three Vector without any transform?

Thanks so much!
I would suggest you add the vectors and then normalize, as that results in fewer calculations. (Fewer calculations is always good!)
Thanks so much for all your posts, It help me a lot!

Best Regards!!

This topic is closed to new replies.

Advertisement