Sha256: 347cea53ef94b5fba636b969316cfec41499eb21d2c898a56860938abb0bb731

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require_relative '../line'
require_relative '../base_element'
require_relative 'skewb_grid.rb'
require_relative 'right_element_factory.rb'

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

          b = Matrix.column_vector([
            x + (2*i+2)*units,
            y + (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 + (-3*i+4)*units,
          ])

          b = Matrix.column_vector([
            x + (i+1)*2*units,
            y + (-3*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/right_skewb_grid.rb