Class: Laser::Cutter::Notching::Shift

Inherits:
Struct
  • Object
show all
Defined in:
lib/laser/cutter/notching/shift.rb

Overview

One step of a notched path: delta along one axis, x (0) or y (1), forwards (1) or backwards (-1).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delta ⇒ Object

Returns the value of attribute delta

Returns:

  • (Object) —

    the current value of delta



8
9
10
# File 'lib/laser/cutter/notching/shift.rb', line 8

def delta
  @delta
end

#dim_index ⇒ Object

Returns the value of attribute dim_index

Returns:

  • (Object) —

    the current value of dim_index



8
9
10
# File 'lib/laser/cutter/notching/shift.rb', line 8

def dim_index
  @dim_index
end

#direction ⇒ Object

Returns the value of attribute direction

Returns:

  • (Object) —

    the current value of direction



8
9
10
# File 'lib/laser/cutter/notching/shift.rb', line 8

def direction
  @direction
end

Instance Method Details

#next_point_after(point) ⇒ Geometry::Point

Returns the point one step on.

Parameters:

Returns:



11
12
13
14
15
16
17
# File 'lib/laser/cutter/notching/shift.rb', line 11

def next_point_after(point)
  p = point.clone
  shift = []
  shift[dim_index] = delta * direction
  shift[(dim_index + 1) % 2] = 0
  p.plus(*shift)
end