Class: Laser::Cutter::Sloped::Notcher

Inherits:
Object
  • Object
show all
Defined in:
lib/laser/cutter/sloped/notcher.rb

Overview

Draws the notched path between two points of a panel, and says how it begins. Every panel of the sloped box is walked counter-clockwise, so the material a path notches into always lies to its right.

Paths are drawn without kerf: a panel is grown by half the kerf once its outline is whole.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(notch_width:, thickness:) ⇒ Notcher

Returns a new instance of Notcher.

Parameters:

  • notch_width (Numeric) —

    the notch length asked for, a guide only

  • thickness (Numeric) —

    of the material



18
19
20
21
22
# File 'lib/laser/cutter/sloped/notcher.rb', line 18

def initialize(notch_width:, thickness:)
  @notch_width = notch_width.to_f
  @thickness = thickness.to_f
  freeze
end

Instance Attribute Details

#thickness ⇒ Float (readonly)

Returns the thickness of the material.

Returns:

  • (Float) —

    the thickness of the material



14
15
16
# File 'lib/laser/cutter/sloped/notcher.rb', line 14

def thickness
  @thickness
end

Instance Method Details

#path(from, to, center_out:) ⇒ Array<Geometry::Point>

Returns the path, from the one corner to the other.

Parameters:

  • from (Geometry::Point) —

    a corner of the inside outline

  • to (Geometry::Point) —

    the next corner

  • center_out (Boolean) —

    whether the middle notch is a tab

Returns:



28
29
30
31
# File 'lib/laser/cutter/sloped/notcher.rb', line 28

def path(from, to, center_out:)
  lines = edge(from, to, center_out).lines
  lines.map(&:p1) << lines.last.p2
end

#tab_first?(length, center_out:) ⇒ Boolean

Returns whether the side begins, and so ends, with a tab.

Parameters:

  • length (Numeric) —

    of a side

  • center_out (Boolean) —

    whether its middle notch is a tab

Returns:

  • (Boolean) —

    whether the side begins, and so ends, with a tab



36
37
38
# File 'lib/laser/cutter/sloped/notcher.rb', line 36

def tab_first?(length, center_out:)
  edge(Geometry::Point[0, 0], Geometry::Point[length, 0], center_out).first_notch_out?
end