Class: Laser::Cutter::Notching::AngledEdge
- Inherits:
-
Object
- Object
- Laser::Cutter::Notching::AngledEdge
- Extended by:
- Forwardable
- Defined in:
- lib/laser/cutter/notching/angled_edge.rb
Overview
Notches along a side at any angle: the sloped side of a wall under a tilted panel.
It lays the side flat along the x axis of a local frame, notches it there with the same Edge and PathGenerator every other side uses, and turns the lines back onto the side. A side of the same length therefore gets the same notch count and width wherever it points, so a tilted panel, itself a plain rectangle, mates with the sloped wall.
It draws no corner boxes: the corners of a sloped side are not square. Kerf moves the ends along the side as it does on a square corner, which is close but not exact when the corner is not square.
Constant Summary collapse
- SIDES =
The side of the run, from
fromtoto, the material lies beyond. { left: 1, right: -1 }.freeze
Instance Attribute Summary collapse
-
#transform ⇒ Geometry::Transform
readonly
From the local frame onto the page.
Instance Method Summary collapse
-
#initialize(from, to, outward:, **options) ⇒ AngledEdge
constructor
A new instance of AngledEdge.
-
#lines ⇒ Array<Geometry::Line>
The notched path, on the page.
Constructor Details
#initialize(from, to, outward:, **options) ⇒ AngledEdge
Returns a new instance of AngledEdge.
35 36 37 38 39 40 41 42 |
# File 'lib/laser/cutter/notching/angled_edge.rb', line 35 def initialize(from, to, outward:, **) sign = SIDES.fetch(outward) { raise ArgumentError, "outward must be one of #{SIDES.keys}, got #{outward.inspect}" } length = Geometry::Line.new(from, to).length raise ArgumentError, "a run needs a length, but it starts and ends at #{from}" unless length > Geometry::Tuple::PRECISION @transform = Geometry::Transform.along(from, to) @edge = Edge.new(*local_lines(length, .fetch(:thickness), sign), .merge(corners: false)) end |
Instance Attribute Details
#transform ⇒ Geometry::Transform (readonly)
Returns from the local frame onto the page.
29 30 31 |
# File 'lib/laser/cutter/notching/angled_edge.rb', line 29 def transform @transform end |
Instance Method Details
#lines ⇒ Array<Geometry::Line>
Returns the notched path, on the page.
45 46 47 |
# File 'lib/laser/cutter/notching/angled_edge.rb', line 45 def lines PathGenerator.new(@edge).generate.map { |line| transform.apply(line) } end |