# How to apply randomness in an impact?

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

## 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 on other sites
[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 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 radiansQuaternion_t cRot(Vector3_t(0,1,0),vDir);cHorizontal = cHorizontal * cRot;cHorizontal.Normalize();cHorizontal *= vImpactNeeded;

##### 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?

1. 1
2. 2
3. 3
4. 4
Rutin
19
5. 5

• 14
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632926
• Total Posts
3009252
• ### Who's Online (See full list)

There are no registered users currently online

×