Method: Processing::GraphicsContext#mag
- Defined in:
- lib/processing/graphics_context.rb
#mag(x, y) ⇒ Numeric #mag(x, y, z) ⇒ Numeric
Returns the magnitude (or length) of a vector.
2674 2675 2676 2677 2678 2679 2680 2681 |
# File 'lib/processing/graphics_context.rb', line 2674 def mag(*args) x, y, z = *args case args.size when 2 then Math.sqrt x * x + y * y when 3 then Math.sqrt x * x + y * y + z * z else raise ArgumentError end end |