Method: Geometry::Obround#initialize
- Defined in:
- lib/geometry/obround.rb
#initialize(point0, point1) ⇒ Obround
Create a Geometry::Obround using the given Points
@param [Point0] point0 The bottom-left corner (closest to the origin)
@param [Point1] point1 The top-right corner (farthest from the origin)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/geometry/obround.rb', line 64 def initialize(point0, point1) point0, point1 = Point[point0], Point[point1] raise(ArgumentError, "Point sizes must match") unless point0.size == point1.size # Reorder the points to get lower-left and upper-right if (point0.x > point1.x) && (point0.y > point1.y) point0, point1 = point1, point0 else p0x, p1x = [point0.x, point1.x].minmax p0y, p1y = [point0.y, point1.y].minmax point0 = Point[p0x, p0y] point1 = Point[p1x, p1y] end @points = [point0, point1] end |