Sha256: 0e0cb37097a4b4ffb5cfd2cd287c2829484ab26485ba388e8df6f606f8c6e836

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require_relative '../line'
require_relative 'skewb_grid'
require_relative 'left_element_factory'

module GridGenerator
  module Skewb
    class LeftSkewbGrid < Skewb::SkewbGrid
      def factory_class
        GridGenerator::Skewb::LeftElementFactory
      end
  
      def points
        [
          Matrix.column_vector([ x, y ]),
          Matrix.column_vector([ x + side_size*2*units, y + side_size*units ]),
          Matrix.column_vector([ x + side_size*2*units, y + side_size*3*units ]),
          Matrix.column_vector([ x, y + side_size*2*units ])
        ]
      end 
  
      def rows
        Array.new(side_size) do |i|
          a = Matrix.column_vector([
            x + (2*i)*units,
            y + (3*i+2)*units,
          ])

          b = Matrix.column_vector([
            x + (2*i+2)*units,
            y + (3*i+1)*units
          ])

          GridGenerator::Line.new(a: a, b: b) 
        end
      end
  
      def columns
        Array.new(side_size) do |i|
          a = Matrix.column_vector([
            x + (2*i)*units,
            y + (-1*i+2)*units,
          ])

          b = Matrix.column_vector([
            x + (i+1)*2*units,
            y + (-1*i+5)*units
          ])

          GridGenerator::Line.new(a: a, b: b) 
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grid_generator-0.3.2 lib/grid_generator/skewb/left_skewb_grid.rb