Advertisement

Simple Coin Kinematics

Started by July 01, 2003 06:03 PM
7 comments, last by rendicil 21 years, 7 months ago
Does anyone know how to do this. I''m trying to model a coin flip using straight up physics not rand(). Need this to be a coin flip with projectile motion. I got the projectile part but unfortunately I can''t figure out the rotation while it''s in the air. Also I need to model it that you can hit it anywhere on half of the coin so it''s different based on where you hit it. This is the code for the projectile: while (i <= 100000) { x = V0x*i; y = y0 + V0y*i - 0.5*grav*(i*i); cout << "X is now: " << x << "\n"; cout << "Y is now: " << y << "\n"; i = i + h; cout << "The value of i is: " << i << "\n"; if (y >= 0) cout << "Still going" << "\n"; else { cout << "The object has landed." << "\n"; break; } } Help please (am very bad C++ coder).
You can''t NOT use rand at all. Think about it, the only reason that a coin ever ends up on a different side is due to some randomness, usually something as simple as different impulse given to the coin, or a different starting height, etc., but possibly even as complex as varying air currents and stuff like that.

In other words, even if you''re doing a physical simulation of a coin flipping, if you want heads or tails (and not just one or the other), you''re going to have to add in some randomness.
Advertisement
I think he meant not doing something like rand() % 2.
That''s right. I don''t want to use rand() % 2 but this is also solvable without using rand() at all... It''s a matrix of three equations. One for projectile motion (which I got already), one for rotation during flight (just straight heads over tails motion) and then the wobble side to side which if it exceeds a certain angle flips the coin over.
Maybe I''m misunderstanding, but if you use the same parameters each time, you will get the exact same result each time. The only rand use you would have to use is to vary slightly the matrix.
That''s all well and good, but I think he is looking for information on rotational kinematics. I''ll give what help I can:

When a body undergoes rotation, it has a number of quantities associated with it that are akin to the quantities associated with a body undergoing translation.
First of all, you should know what a torque is. A torque is simply the rotational analog to a force. Just as a force causes linear acceleration, a torque causes rotational acceleration. That is, a torque changes the angular velocity of a body around a certain axis. A body''s angular velocity is the time rate of change of the body''s angular "displacement." So now you have four quantities: angular displacement, angular velocity, angular acceleration, and torque. There is one more that you need to know: the moment of inertia, the rotational analog to mass. The linear formula F = ma has the rotational analog t = Ia (the t and a are supposed to be the greek tau and alpha). The geometry and mass of a body determine its moment of inertia. With all that in mind, you can learn about ways to represent rotations inside a program, a topic undoubtedly covered here in the gamedev archives.

I hope that was helpful. I''m not sure if that''s what you were looking for, but I like writing about physics, so, no loss.
You know what I never noticed before?
Advertisement
quote:
Original post by vanillacoke
That's all well and good, but I think he is looking for information on rotational kinematics. I'll give what help I can:

When a body undergoes rotation, it has a number of quantities associated with it that are akin to the quantities associated with a body undergoing translation.
First of all, you should know what a torque is. A torque is simply the rotational analog to a force. Just as a force causes linear acceleration, a torque causes rotational acceleration. That is, a torque changes the angular velocity of a body around a certain axis. A body's angular velocity is the time rate of change of the body's angular "displacement." So now you have four quantities: angular displacement, angular velocity, angular acceleration, and torque. There is one more that you need to know: the moment of inertia, the rotational analog to mass. The linear formula F = ma has the rotational analog t = Ia (the t and a are supposed to be the greek tau and alpha). The geometry and mass of a body determine its moment of inertia. With all that in mind, you can learn about ways to represent rotations inside a program, a topic undoubtedly covered here in the gamedev archives.

I hope that was helpful. I'm not sure if that's what you were looking for, but I like writing about physics, so, no loss.


reminds me my school days(mostly i was not attentive is phy class).

[edited by - DirectXXX on July 2, 2003 3:56:07 AM]
3D Side-Scroller game demo Project-X2 "playable"Lashkar: A 3D Game & Simulation Project demo @ lashkar.berlios.de
yeah... I read way too many math and science books.
You know what I never noticed before?
You can never read too many of those

This topic is closed to new replies.

Advertisement