Method: Joules.particle_velocity

Defined in:
lib/joules/oscillations.rb

.particle_velocity(angular_velocity, amplitude, particle_displacement, return_sign = nil) ⇒ Float+

Calculates the velocity of a particle in oscillation given angular velocity, amplitude, and particle displacement.

Examples:

Joules.particle_velocity(2.4, 5, 3) #=> [9.6, -9.6]

Parameters:

  • angular_velocity (Int, Float)

    angular_velocity is in radians per second

  • amplitude (Int, Float)

    amplitude >= 0; amplitude is in metres

  • particle_displacement (Int, Float)

    particle_displacement is in metres

  • return_sign (String) (defaults to: nil)

    return_sign is either ‘-’ or ‘+’

Returns:

  • (Float, Array<Float>)

    return list has a length of 2; each velocity in return list or return value is in metres per second



58
59
60
61
62
63
64
65
66
67
# File 'lib/joules/oscillations.rb', line 58

def particle_velocity(angular_velocity, amplitude, particle_displacement, return_sign = nil)
  return_value = angular_velocity * (((amplitude ** 2) - (particle_displacement ** 2)) ** 0.5)
  if return_sign == '-'
    return (- return_value)
  elsif return_sign == '+'
    return return_value
  else
    return [return_value, (- return_value)]
  end
end