Class: Laser::Cutter::Sloped::Profile
- Inherits:
-
Object
- Object
- Laser::Cutter::Sloped::Profile
- 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
-
#angle ⇒ Float
readonly
The angle of the tilted panel above horizontal, in radians.
-
#depth ⇒ Float
readonly
Depth, height, front height, and the thickness of the material.
-
#front_height ⇒ Float
readonly
Depth, height, front height, and the thickness of the material.
-
#height ⇒ Float
readonly
Depth, height, front height, and the thickness of the material.
-
#slope_length ⇒ Float
readonly
S, the inside length of the slope, corner to corner.
-
#thickness ⇒ Float
readonly
Depth, height, front height, and the thickness of the material.
-
#top_depth ⇒ Float
readonly
Dt, the inside depth of the top strip.
Instance Method Summary collapse
- #front_strip? ⇒ Boolean
-
#front_strip_length ⇒ Float
The height of the front strip; 0 when it is dropped.
-
#initialize(depth:, height:, front_height:, slope:, thickness:) ⇒ Profile
constructor
A new instance of Profile.
-
#tilted_length ⇒ Float
The length of the tilted panel, end to end.
-
#tilted_outside ⇒ Geometry::Line
The outside face of the tilted panel, one thickness out from its span.
-
#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.
-
#top_strip? ⇒ Boolean
Whether the box has a top strip, and a front strip.
-
#top_strip_length ⇒ Float
The length of the top strip, front to back; 0 when it is dropped.
-
#vertices ⇒ Array<Geometry::Point>
The inside outline, counter-clockwise from the front of the bottom.
Constructor Details
#initialize(depth:, height:, front_height:, slope:, thickness:) ⇒ Profile
Returns a new instance of Profile.
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.
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.
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.
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.
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.
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.
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.
57 58 59 |
# File 'lib/laser/cutter/sloped/profile.rb', line 57 def top_depth @top_depth end |
Instance Method Details
#front_strip? ⇒ 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.
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.
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.
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.
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.
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.
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.
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 |