Class: Laser::Cutter::Sloped::Profile

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

Overview

The side view of a box whose front slopes back: the inside outline of a side wall, and the lengths of the panels that close it.

Seen from the left, front to the left, the outline runs

        top (Dt)
      +--------+
     /         |

tilted / | / | back (H) + | front | | (Hf) ------------ bottom (D)

Every length is of the inside outline, in the box's units. The tilted panel rises at slope degrees, so the top strip is whatever depth is left: Dt = D - (H - Hf) / tan(slope). A strip of zero size is dropped.

Where the tilted panel meets a strip, the corner is obtuse and the joint is a plain butt joint: the strip runs past the corner over the end of the tilted panel, and the tilted panel stops short of it, so their outside faces meet with no gap and no overlap. Where it meets the back or the bottom directly, the corner is acute, and both panels simply end at the corner.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(depth:, height:, front_height:, slope:, thickness:) ⇒ Profile

Returns a new instance of Profile.

Parameters:

  • depth (Numeric) —

    D, the inside depth of the box

  • height (Numeric) —

    H, the inside height at the back

  • front_height (Numeric) —

    Hf, the inside height at the front

  • slope (Numeric) —

    the angle of the tilted panel, in degrees

  • thickness (Numeric) —

    of the material

Raises:



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/laser/cutter/sloped/profile.rb', line 44

def initialize(depth:, height:, front_height:, slope:, thickness:)
  @depth = depth.to_f
  @height = height.to_f
  @front_height = front_height.to_f
  @thickness = thickness.to_f
  @slope = slope.to_f
  validate!
  @angle = @slope * Math::PI / 180
  compute_lengths!
  freeze
end

Instance Attribute Details

#angle ⇒ Float (readonly)

Returns the angle of the tilted panel above horizontal, in radians.

Returns:

  • (Float) —

    the angle of the tilted panel above horizontal, in radians



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

def angle
  @angle
end

#depth ⇒ Float (readonly)

Returns depth, height, front height, and the thickness of the material.

Returns:

  • (Float) —

    depth, height, front height, and the thickness of the material



33
34
35
# File 'lib/laser/cutter/sloped/profile.rb', line 33

def depth
  @depth
end

#front_height ⇒ Float (readonly)

Returns depth, height, front height, and the thickness of the material.

Returns:

  • (Float) —

    depth, height, front height, and the thickness of the material



33
34
35
# File 'lib/laser/cutter/sloped/profile.rb', line 33

def front_height
  @front_height
end

#height ⇒ Float (readonly)

Returns depth, height, front height, and the thickness of the material.

Returns:

  • (Float) —

    depth, height, front height, and the thickness of the material



33
34
35
# File 'lib/laser/cutter/sloped/profile.rb', line 33

def height
  @height
end

#slope_length ⇒ Float (readonly)

Returns S, the inside length of the slope, corner to corner.

Returns:

  • (Float) —

    S, the inside length of the slope, corner to corner



60
61
62
# File 'lib/laser/cutter/sloped/profile.rb', line 60

def slope_length
  @slope_length
end

#thickness ⇒ Float (readonly)

Returns depth, height, front height, and the thickness of the material.

Returns:

  • (Float) —

    depth, height, front height, and the thickness of the material



33
34
35
# File 'lib/laser/cutter/sloped/profile.rb', line 33

def thickness
  @thickness
end

#top_depth ⇒ Float (readonly)

Returns Dt, the inside depth of the top strip.

Returns:

  • (Float) —

    Dt, the inside depth of the top strip



57
58
59
# File 'lib/laser/cutter/sloped/profile.rb', line 57

def top_depth
  @top_depth
end

Instance Method Details

#front_strip? ⇒ Boolean

Returns:

  • (Boolean)


64
# File 'lib/laser/cutter/sloped/profile.rb', line 64

def front_strip? = front_height.positive?

#front_strip_length ⇒ Float

Returns the height of the front strip; 0 when it is dropped.

Returns:

  • (Float) —

    the height of the front strip; 0 when it is dropped



103
# File 'lib/laser/cutter/sloped/profile.rb', line 103

def front_strip_length = front_strip? ? front_height + (thickness / Math.cos(angle)) : 0.0

#tilted_length ⇒ Float

Returns the length of the tilted panel, end to end.

Returns:

  • (Float) —

    the length of the tilted panel, end to end



97
# File 'lib/laser/cutter/sloped/profile.rb', line 97

def tilted_length = slope_length - front_cut - top_cut

#tilted_outside ⇒ Geometry::Line

The outside face of the tilted panel, one thickness out from its span.

Returns:



90
91
92
93
94
# File 'lib/laser/cutter/sloped/profile.rb', line 90

def tilted_outside
  out = Vector[-Math.sin(angle), Math.cos(angle)] * thickness
  span = tilted_span
  Geometry::Line.new(span.p1.plus(out), span.p2.plus(out))
end

#tilted_span ⇒ Geometry::Line

The part of the slope the tilted panel covers, and so the part of a side wall's sloped edge that is notched.

Returns:



81
82
83
84
85
# File 'lib/laser/cutter/sloped/profile.rb', line 81

def tilted_span
  low = slope_low.plus(direction * front_cut)
  high = slope_high.plus(direction * -top_cut)
  Geometry::Line.new(low, high)
end

#top_strip? ⇒ Boolean

Whether the box has a top strip, and a front strip.

Returns:

  • (Boolean)


63
# File 'lib/laser/cutter/sloped/profile.rb', line 63

def top_strip? = top_depth.positive?

#top_strip_length ⇒ Float

Returns the length of the top strip, front to back; 0 when it is dropped.

Returns:

  • (Float) —

    the length of the top strip, front to back; 0 when it is dropped



100
# File 'lib/laser/cutter/sloped/profile.rb', line 100

def top_strip_length = top_strip? ? top_depth + (thickness / Math.sin(angle)) : 0.0

#vertices ⇒ Array<Geometry::Point>

The inside outline, counter-clockwise from the front of the bottom.

Returns:

  • (Array<Geometry::Point>) —

    five corners; four when one strip is dropped, and three, a wedge, when both are



70
71
72
73
74
75
# File 'lib/laser/cutter/sloped/profile.rb', line 70

def vertices
  points = [[0, 0], [depth, 0], [depth, height]]
  points << [depth - top_depth, height] if top_strip?
  points << [0, front_height] if front_strip?
  points.map { |x, y| Geometry::Point[x, y] }
end