Created
May 22, 2019 20:22
-
-
Save aybekckaya/ecdaf88a9cc59a74c3e742e800304028 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UISpringTimingParameters { | |
public convenience init(dampingRatio: CGFloat, frequencyResponse: CGFloat) { | |
precondition(dampingRatio >= 0) | |
precondition(frequencyResponse > 0) | |
let mass = 1 as CGFloat | |
let stiffness = pow(2 * .pi / frequencyResponse, 2) * mass | |
let damping = 4 * .pi * dampingRatio * mass / frequencyResponse | |
self.init(mass: mass, stiffness: stiffness, damping: damping, initialVelocity: .zero) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment