Class: Laser::Cutter::Notching::AngledEdge

Inherits:
Object
  • Object
show all
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 from to to, the material lies beyond.

{ left: 1, right: -1 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, outward:, **options) ⇒ AngledEdge

Returns a new instance of AngledEdge.

Parameters:

  • from (Geometry::Point) —

    where the inside line starts

  • to (Geometry::Point) —

    where it ends

  • outward (Symbol) —

    :left or :right of the run from from to to

  • options (Hash) —

    as for Edge: notch_width, thickness, kerf, center_out

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
# File 'lib/laser/cutter/notching/angled_edge.rb', line 35

def initialize(from, to, outward:, **options)
  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, options.fetch(:thickness), sign), options.merge(corners: false))
end

Instance Attribute Details

#transform ⇒ Geometry::Transform (readonly)

Returns from the local frame onto the page.

Returns:



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.

Returns:



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