Class: Laser::Cutter::Geometry::Shift

Inherits:
Struct
  • Object
show all
Defined in:
lib/laser-cutter/geometry/path_generator.rb

Constant Summary collapse

POINTERS =
{[1, 0]  => '   ->',
[-1, 0] => '<-   ',
[1, 1]  => '  V  ',
[-1, 1] => '  ^  '}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deltaObject

Returns the value of attribute delta

Returns:

  • (Object)

    the current value of delta



6
7
8
# File 'lib/laser-cutter/geometry/path_generator.rb', line 6

def delta
  @delta
end

#dim_indexObject

Returns the value of attribute dim_index

Returns:

  • (Object)

    the current value of dim_index



6
7
8
# File 'lib/laser-cutter/geometry/path_generator.rb', line 6

def dim_index
  @dim_index
end

#directionObject

Returns the value of attribute direction

Returns:

  • (Object)

    the current value of direction



6
7
8
# File 'lib/laser-cutter/geometry/path_generator.rb', line 6

def direction
  @direction
end

Instance Method Details

#next(point1) ⇒ Object



12
13
14
15
16
# File 'lib/laser-cutter/geometry/path_generator.rb', line 12

def next(point1)
  p = Point.new(point1.to_a)
  p.coords[dim_index] += (delta * direction)
  p
end

#to_sObject



17
18
19
# File 'lib/laser-cutter/geometry/path_generator.rb', line 17

def to_s
  "shift by:#{sprintf('%.2f', delta)}, #{POINTERS[[direction,dim_index]]}"
end