Class: Laser::Cutter::Notching::Edge
- Inherits:
-
Object
- Object
- Laser::Cutter::Notching::Edge
- Defined in:
- lib/laser-cutter/notching/edge.rb
Overview
This class represents a single edge of one side: both inside and outside edge of the material. It’s also responsible for calculating the “perfect” notch width.
Instance Attribute Summary collapse
-
#adjust_corners ⇒ Object
Returns the value of attribute adjust_corners.
-
#center_out ⇒ Object
Returns the value of attribute center_out.
-
#corners ⇒ Object
Returns the value of attribute corners.
-
#inside ⇒ Object
Returns the value of attribute inside.
-
#kerf ⇒ Object
Returns the value of attribute kerf.
-
#notch_count ⇒ Object
Returns the value of attribute notch_count.
-
#notch_width ⇒ Object
Returns the value of attribute notch_width.
-
#outside ⇒ Object
Returns the value of attribute outside.
-
#thickness ⇒ Object
Returns the value of attribute thickness.
-
#v1 ⇒ Object
Returns the value of attribute v1.
-
#v2 ⇒ Object
Returns the value of attribute v2.
Instance Method Summary collapse
-
#add_across_line?(face_setting) ⇒ Boolean
face_setting determines if we want that face to have center notch facing out (for a hole, etc).
- #adjust_for_kerf! ⇒ Object
-
#first_notch_out? ⇒ Boolean
True if the first notch should be a tab (sticking out), or false if it’s a hole.
-
#initialize(outside, inside, options = {}) ⇒ Edge
constructor
A new instance of Edge.
- #kerf? ⇒ Boolean
- #move_line_for_kerf(line) ⇒ Object
Constructor Details
#initialize(outside, inside, options = {}) ⇒ Edge
Returns a new instance of Edge.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/laser-cutter/notching/edge.rb', line 17 def initialize(outside, inside, = {}) self.outside = outside.clone self.inside = inside.clone # two vectors representing directions going from beginning of each inside line to the outside self.v1 = [inside.p1.x - outside.p1.x, inside.p1.y - outside.p1.y].map{|e| -(e / e.abs).to_f } self.v2 = [inside.p2.x - outside.p2.x, inside.p2.y - outside.p2.y].map{|e| -(e / e.abs).to_f } self.v1 = Vector.[](*self.v1) self.v2 = Vector.[](*self.v2) self.center_out = [:center_out] || false self.thickness = [:thickness] self.corners = [:corners] self.kerf = [:kerf] || 0 self.notch_width = [:notch_width] self.adjust_corners = [:adjust_corners] calculate_notch_width! adjust_for_kerf! end |
Instance Attribute Details
#adjust_corners ⇒ Object
Returns the value of attribute adjust_corners.
13 14 15 |
# File 'lib/laser-cutter/notching/edge.rb', line 13 def adjust_corners @adjust_corners end |
#center_out ⇒ Object
Returns the value of attribute center_out.
13 14 15 |
# File 'lib/laser-cutter/notching/edge.rb', line 13 def center_out @center_out end |
#corners ⇒ Object
Returns the value of attribute corners.
13 14 15 |
# File 'lib/laser-cutter/notching/edge.rb', line 13 def corners @corners end |
#inside ⇒ Object
Returns the value of attribute inside.
10 11 12 |
# File 'lib/laser-cutter/notching/edge.rb', line 10 def inside @inside end |
#kerf ⇒ Object
Returns the value of attribute kerf.
12 13 14 |
# File 'lib/laser-cutter/notching/edge.rb', line 12 def kerf @kerf end |
#notch_count ⇒ Object
Returns the value of attribute notch_count.
14 15 16 |
# File 'lib/laser-cutter/notching/edge.rb', line 14 def notch_count @notch_count end |
#notch_width ⇒ Object
Returns the value of attribute notch_width.
11 12 13 |
# File 'lib/laser-cutter/notching/edge.rb', line 11 def notch_width @notch_width end |
#outside ⇒ Object
Returns the value of attribute outside.
10 11 12 |
# File 'lib/laser-cutter/notching/edge.rb', line 10 def outside @outside end |
#thickness ⇒ Object
Returns the value of attribute thickness.
12 13 14 |
# File 'lib/laser-cutter/notching/edge.rb', line 12 def thickness @thickness end |
#v1 ⇒ Object
Returns the value of attribute v1.
14 15 16 |
# File 'lib/laser-cutter/notching/edge.rb', line 14 def v1 @v1 end |
#v2 ⇒ Object
Returns the value of attribute v2.
14 15 16 |
# File 'lib/laser-cutter/notching/edge.rb', line 14 def v2 @v2 end |
Instance Method Details
#add_across_line?(face_setting) ⇒ Boolean
face_setting determines if we want that face to have center notch facing out (for a hole, etc). This works well when we have odd number of notches, but
60 61 62 |
# File 'lib/laser-cutter/notching/edge.rb', line 60 def add_across_line?(face_setting) notch_count % 4 == 1 ? face_setting : !face_setting end |
#adjust_for_kerf! ⇒ Object
39 40 41 42 43 44 |
# File 'lib/laser-cutter/notching/edge.rb', line 39 def adjust_for_kerf! if kerf? self.inside = move_line_for_kerf(inside) self.outside = move_line_for_kerf(outside) end end |
#first_notch_out? ⇒ Boolean
True if the first notch should be a tab (sticking out), or false if it’s a hole.
65 66 67 |
# File 'lib/laser-cutter/notching/edge.rb', line 65 def first_notch_out? add_across_line?(center_out) end |
#kerf? ⇒ Boolean
53 54 55 |
# File 'lib/laser-cutter/notching/edge.rb', line 53 def kerf? self.kerf > 0.0 end |