Class: Laser::Cutter::Sloped::Placement
- Inherits:
-
Object
- Object
- Laser::Cutter::Sloped::Placement
- Defined in:
- lib/laser/cutter/sloped/placement.rb
Overview
Where a panel goes on the sheet: its own origin moved to a point, and the panel turned over within its own size when asked. Flipping x draws the mirror image, which the second side wall is; flipping both turns the panel half way round.
Instance Attribute Summary collapse
-
#origin ⇒ Geometry::Point
readonly
Where the origin of the panel lands.
Instance Method Summary collapse
-
#apply(point) ⇒ Geometry::Point
On the sheet.
-
#initialize(origin, size:, flip_x: false, flip_y: false) ⇒ Placement
constructor
A new instance of Placement.
Constructor Details
#initialize(origin, size:, flip_x: false, flip_y: false) ⇒ Placement
Returns a new instance of Placement.
18 19 20 21 22 23 24 |
# File 'lib/laser/cutter/sloped/placement.rb', line 18 def initialize(origin, size:, flip_x: false, flip_y: false) @origin = origin.clone @size = size.map(&:to_f).freeze @flip_x = flip_x @flip_y = flip_y freeze end |
Instance Attribute Details
#origin ⇒ Geometry::Point (readonly)
Returns where the origin of the panel lands.
12 13 14 |
# File 'lib/laser/cutter/sloped/placement.rb', line 12 def origin @origin end |
Instance Method Details
#apply(point) ⇒ Geometry::Point
Returns on the sheet.
28 29 30 31 32 |
# File 'lib/laser/cutter/sloped/placement.rb', line 28 def apply(point) x = @flip_x ? @size[0] - point.x : point.x y = @flip_y ? @size[1] - point.y : point.y Geometry::Point[@origin.x + x, @origin.y + y] end |