Sha256: 0e78ba8a3d1acfb5d5abd90b3d04efe9e6494527024b1675457f6469f29d104e

Contents?: true

Size: 444 Bytes

Versions: 2

Compression:

Stored size: 444 Bytes

Contents

# -*- coding: utf-8 -*-

##
# A generic geometery point.
#
#  * Intended to be implemented via Array.
#  * Intended to be N-dimensional.
#
module Point
  module Array

    def +(other)
      raise ::IndexError unless self.size == other.size
      self.size.times.map{|i| self[i] + other[i] }
    end

    def -(other)
      raise ::IndexError unless self.size == other.size
      self.size.times.map{|i| self[i] - other[i] }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sixarm_ruby_geometry-4.0.0 lib/sixarm_ruby_geometry/point/array.rb
sixarm_ruby_geometry-3.1.1 lib/sixarm_ruby_geometry/point/array.rb