Return the angle degree in radians.
# File lib/bullshit.rb, line 161 def angle(degree) Math.tan(Math::PI * degree / 180) end
Let a window of size window_size slide over the array array and yield to the window array.
# File lib/bullshit.rb, line 172 def array_window(array, window_size) window_size < 1 and raise ArgumentError, "window_size = #{window_size} < 1" window_size = window_size.to_i window_size += 1 if window_size % 2 == 0 radius = window_size / 2 array.each_index do |i| ws = window_size from = i - radius negative_from = false if from < 0 negative_from = true ws += from from = 0 end a = array[from, ws] if (diff = window_size - a.size) > 0 mean = a.inject(0.0) { |s, x| s + x } / a.size a = if negative_from [ mean ] * diff + a else a + [ mean ] * diff end end yield a end nil end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.