Hi, I have a little problem. I recently got the nerve to try and teach myself all of the physical properties necessary to program a physics engine (the insomnia is a DIFFERENT problem). It's going much better than I could've hoped (considering I started a few days ago). My knowledge of physics is quite limited, but I'll do the best I can to explain my problem. I have presented the main question at the bottom of the post, but just to try and make sure I'm clear on the issue I've provided how I came upon the problem, seeing as I don't really know too much about physics.(adsbygoogle = window.adsbygoogle || []).push({});

My objective (and a HUGE issue in computer theory) is to handle collision detection between two rigid bodies. My algorithm works fine and I'm not having problems with it at all, but just so I can explain my problem I'm going to try and not leave anything out.

Essentially, for a physics simulation to function realistically, you must make calculations using discrete timesteps, usually equal to one frame that could be displayed (so, 1/60th of a second is a common discrete timestep), as you'll only ever need to know where an object WILL be at the end of a timestep, and not necessarily where it IS exactly.

Next Position = Position + Velocity * DiscreteTimeStep.

All points in between current position (Position) and next position (Position + Velocity * TimeStep) can be determined with an alpha variable (that is, a variable which represents all possible values between 0 and 1).

Position + Velocity * (TimeStep * Alpha). Will give us all instances of position in time at the beggining and end of the timestep (again, imagine that being 1/60th of a second).

We need to compare the distance over Alpha between two objects. When the Distance is 0 we can find a contact point (point of collision). If the resulting Alpha is larger than 1 or less than 0, then we know there won't be a collision within the discrete time step (as alpha is more like a Percentage variable).

for ( Alpha >= 0 and Alpha < 1)

Distance = (A.Position + A.Velocity * (TimeStep * Alpha)) -

(B.Position + B.Velocity * (TimeStep * Alpha))

I then set the distance to 0 and solve alpha for all possible combinations of all points on the surface of each object (it's a LOT of planar intersection tests- that's not a problem though). The Velocity for each point is the same as the center of mass (it is a rigid body after all). So this conceptually works.

Distance = (A.Position + A.Velocity * (TimeStep * Alpha)) -

(B.Position + B.Velocity * (TimeStep * Alpha))

Distance is 0 for a contact point...

(A.Position + A.Velocity * (TimeStep * Alpha)) = (B.Position +

B.Velocity * (TimeStep * Alpha))

Isolate Alpha...

Alpha = (A.Position + B.Position)/(TimeStep * (A.Velocity + B.Velocity))

Now, EVERY point between the two objects gets compared and The smallest alpha between 1 and 0 is our contact point if a contact has occurred (we only want to find ONE contact point, because after a contact point has been found, forces are applied and the projected location of the object changes, at which point we need to run all the tests over again). Alpha is most likely going to be some insane irrational floating point value, which means a computer automatically rounds it off, which means there will be a small amount of rounding error for every collision. So somewhere the Permittivity of Free Space constant needs to go... (epsilon: 8.854 187 817... x10^-12). That's certainly not my main concern at this point (but if anyone has a clue on that one it'd be helpful, though that's more of a computer science question).

If the center of mass is rotating, then the position of any given point relative to that center of mass will also move as a function of time. That means my distance formula needs to compensate for the angular rotation of the center of mass as applied to every point in the rigid body.

In other words, I have Angular velocity, the Position of all points on a Rigid body, and the center of mass.

Point Position

AngularVelocity*DiscreteTimeStep

Velocity*DiscreteTimeStep

Center of Mass

AngularVelocity and Velocity are determined by an RK4 integration method (for all values of alpha within the timestep). So my angularVelocity and Velocity are NOT constant, but with 'good guessing' I think I get them close enough (And I can already handle the velocity change from acceleration relative to alpha- or however that works :P, I just mean to say that all of these values are different at any given point in time).

Problem:

How do I apply the AngularVelocity and Velocity to a Point on a rigid body, as a function of time?

For linear velocity, it's really simple- the x,y,z values of velocity just get added to the x,y,z values of the current position of a point, and that's the next position. I use a scalar to bring it down into the desired time range and test to see, at which scaling (alpha), two given points will collide given their current velocities. I guess it's just like

When Angular Velocity is considered, I'm clueless, even though I know what the value of Angular Velocity will be.

I just need to fitAngularVelocityinto the following expression somewhere--

Position + Velocity*DiscreteTimeStep*Alpha

...And I need to know exactly how to do it.

Thanks!

**Physics Forums - The Fusion of Science and Community**

# Physics Simulation- Angular Velocity Applications

Know someone interested in this topic? Share a link to this question via email,
Google+,
Twitter, or
Facebook

Have something to add?

- Similar discussions for: Physics Simulation- Angular Velocity Applications

Loading...

**Physics Forums - The Fusion of Science and Community**