ielyamani
ielyamani

Reputation: 18591

SKPhysicsJointSpring frequency & damping in Swift

What is the difference between damping and frequency properties of a SKPhysicsJointSpring ?

the code I have is

var spring = SKPhysicsJointSpring.jointWithBodyA(
            body1.physicsBody,
            bodyB: body2.physicsBody,
            anchorA: body1.position,
            anchorB: body2.position)
spring.frequency = 1.8
spring.damping = 0.5
self.physicsWorld.addJoint(spring1)

body1.physicsBody?.dynamic = false
body2.physicsBody?.dynamic = true

In what range of values should frequency and damping fall so that the spring acts naturally?

Upvotes: 4

Views: 854

Answers (2)

KSR
KSR

Reputation: 231

It is useful to think of frequency as a measure of the spring's "stiffness", how it responds to compressive or lateral forces. Higher frequency means a stiffer spring. You'll often see values like 4.0 or 9.0. A frequency of 0.0001 is very, very loose!

However, a word of caution: this logic breaks down at the default frequency of 0.0. At frequency == 0.0, the spring is entirely rigid and non-compressive.

Upvotes: 0

duffymo
duffymo

Reputation: 308793

Answer depends on what you consider "natural".

Damping means that the spring will dissipate energy with each oscillation and eventually come to rest.

Zero damping means that the mass attached to the spring will oscillate forever.

Such a system usually has three constants associated with it:

  1. mass m (lbm)
  2. spring stiffness k (lbf/in)
  3. damping coefficient c

It's well known that frequency f^2 = k/m.

When that system talks about spring "frequency" it makes no sense to me.

Upvotes: 3

Related Questions