Sha256: 07c2df48c19cf07cfb1054d48d51675c60b9bbb07ebb04f964daac0d6c1b427d

Contents?: true

Size: 503 Bytes

Versions: 5

Compression:

Stored size: 503 Bytes

Contents

module GridGenerator
  module Helper
    def self.distance(a, b)
      Math.sqrt((b[0,0] - a[0,0])**2 + (b[1,0] - a[1,0])**2)
    end

    # 1 -> / 2 | 
    # 2 -> / 3 | 
    def self.intervals(a, b, i)
      dx = b[0,0] - a[0,0]
      dy = b[1,0] - a[1,0]

      Array.new(i) do |n|
        interval_x = dx / (i + 1) 
        interval_y = dy / (i + 1)
        x = a[0,0] + (n + 1) * interval_x
        y = a[1,0] + (n + 1) * interval_y
        Matrix.column_vector([x, y])
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grid_generator-0.2.12 lib/grid_generator/helper.rb
grid_generator-0.2.11 lib/grid_generator/helper.rb
grid_generator-0.2.10 lib/grid_generator/helper.rb
grid_generator-0.2.9 lib/grid_generator/helper.rb
grid_generator-0.2.8 lib/grid_generator/helper.rb