# spring and damping effect

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

## Recommended Posts

Hi, I would like implement this spring and damping effect to my project. I looked into spring equations and Hooke's law (I'm in the exploratory phase) but the info I found doesn't really address the rotation of a vector. The quicktime shows a positional offset but also imagine a rotation influencing the sway and drag of the vector.

Can the vets out their point me in the right direction? What subjects should I google? Is there a good book you recommend? Do you have the working equation that achieves this? I'll take anything. Thanks.

Nikos

##### Share on other sites
if you have a rigid body system in place, adding a spring/damper is just adding forces to a rigid body... the rotations will be handled by that automatically.

if you dont have a rigid body system in place... get one .
You can code it yourself (good fun and learning experience) or just grab ODE, PhysX, Bullet, Havok and use theirs.

##### Share on other sites

if you have a rigid body system in place, adding a spring/damper is just adding forces to a rigid body... the rotations will be handled by that automatically.

if you dont have a rigid body system in place... get one .
You can code it yourself (good fun and learning experience) or just grab ODE, PhysX, Bullet, Havok and use theirs.

Using those engines is not an option All I have to work with are 2 vectors. Using these nominal vectors, I would like to calculate a third that represents those spring and drag forces. I thought about doing a simple weighted average of the two using their magnitudes as a weight but it seemed too much like a hack. So I'm appealing to the math gurus on this one. I'll take anything

##### Share on other sites
that doesn't make any sense.

you need to formulate your problem properly or no guru is ever going to be able to help you.

##### Share on other sites
You could apply three one dimensional damped springs, one for each axis. This would give you the "swaying grass" effect you seem to be looking for. Also, this method does not requre a call to sqrt() or other cpu-expensive functions. For each axis, the force F would be F = -x*k - v*d, where x is displacement from rest position along given axis, k is spring stiffnes coefficient, v is velocity relative to rest position along given axis, and d is spring damping coefficient. Along the vertical axis, force would be F = -(x-xr)*k - v*d, where xr is rest distance above ground.

Alternatively, you could apply an angular or rotational spring, but this is considerably more complicated.

Cheers,
Mike

##### Share on other sites

You could apply three one dimensional damped springs, one for each axis. This would give you the "swaying grass" effect you seem to be looking for. Also, this method does not requre a call to sqrt() or other cpu-expensive functions. For each axis, the force F would be F = -x*k - v*d, where x is displacement from rest position along given axis, k is spring stiffnes coefficient, v is velocity relative to rest position along given axis, and d is spring damping coefficient. Along the vertical axis, force would be F = -(x-xr)*k - v*d, where xr is rest distance above ground.

Alternatively, you could apply an angular or rotational spring, but this is considerably more complicated.

Cheers,
Mike

That is exactly what I was looking for. Thanks Mike!

##### Share on other sites

You could apply three one dimensional damped springs, one for each axis. This would give you the "swaying grass" effect you seem to be looking for. Also, this method does not requre a call to sqrt() or other cpu-expensive functions. For each axis, the force F would be F = -x*k - v*d, where x is displacement from rest position along given axis, k is spring stiffnes coefficient, v is velocity relative to rest position along given axis, and d is spring damping coefficient. Along the vertical axis, force would be F = -(x-xr)*k - v*d, where xr is rest distance above ground.

Alternatively, you could apply an angular or rotational spring, but this is considerably more complicated.

Cheers,
Mike

BEAUTIFUL. thanks h4tt3n. works great!

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631768
• Total Posts
3002244
×