Method: Joules.time_period_v2
- Defined in:
- lib/joules/oscillations.rb
.time_period_v2(mass, spring_constant) ⇒ Float
Note:
There are two other methods for calculating time period.
Calculates the time period of a mass-spring system given mass and spring constant.
106 107 108 109 110 111 112 |
# File 'lib/joules/oscillations.rb', line 106 def time_period_v2(mass, spring_constant) if spring_constant.zero? raise ZeroDivisionError.new('divided by 0') else return 2 * Math::PI * ((mass / spring_constant.to_f) ** 0.5) end end |