• Advertisement
Sign in to follow this  

How to apply randomness in an impact?

This topic is 4980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets say I have two points x, y to apply the force between them i take the vector of the two points and i multiply it by some force. What if I want to apply some randomness in degrees? This is what i have now:
// no y force, already added.
Vector3_t cHorizontal(  vX1-vX2,0,vY1-vY2);
int nRandomDir = (rand() % (nHorizontalRandomness*2)) - nHorizontalRandomness;
// where to apply randomDir?
cHorizontal.Normalize();
cHorizontal *= vImpactNeeded;
Impact(cHorizontal);

[Edited by - _Kami_ on September 2, 2004 4:48:09 AM]

Share this post


Link to post
Share on other sites
Advertisement
[img=http://www.tkoc.net/rotation.jpg]

http://www.tkoc.net/rotation.jpg

Here you can see a drawing of it.. maybe easier to understand then.

Share this post


Link to post
Share on other sites
ok, this is what I came up with.. Hope this can help some others as well:)


float vDir = 45.0 * 3.14 / 180.0; // to radians
Quaternion_t cRot(Vector3_t(0,1,0),vDir);
cHorizontal = cHorizontal * cRot;
cHorizontal.Normalize();
cHorizontal *= vImpactNeeded;

Share this post


Link to post
Share on other sites
There is no such thing as randomness in impact, every collision, every force, every velocity can all be modelled by physics. there is such a thing as odd-shaped objects that do bounce funny & we would have a hard time designing up a physics model for them. but if you simply using spheres... its very simple, every entity has rotational & translational kinetic energy & there is potential energy too. Do you need help with a good model?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement