Module: Geom2D
- Defined in:
- lib/geom2d.rb,
lib/geom2d/point.rb,
lib/geom2d/utils.rb,
lib/geom2d/polygon.rb,
lib/geom2d/segment.rb,
lib/geom2d/version.rb,
lib/geom2d/algorithms.rb,
lib/geom2d/polygon_set.rb,
lib/geom2d/bounding_box.rb,
lib/geom2d/utils/sorted_list.rb,
lib/geom2d/algorithms/polygon_operation.rb
Overview
– geom2d - 2D Geometric Objects and Algorithms Copyright © 2018 Thomas Leitner <[email protected]>
This software may be modified and distributed under the terms of the MIT license. See the LICENSE file for details. ++
Defined Under Namespace
Modules: Algorithms, Utils Classes: BoundingBox, Point, Polygon, PolygonSet, Segment
Constant Summary collapse
- VERSION =
The version of Geom2D
'0.2.0'
Class Method Summary collapse
-
.Point(x, y = nil) ⇒ Object
Creates a new Point object from the given coordinates.
-
.Polygon(*vertices) ⇒ Object
Creates a new Polygon object from the given vertices.
-
.PolygonSet(*polygons) ⇒ Object
Creates a PolygonSet from the given array of Polygon instances.
-
.Segment(start_point, end_point = nil, vector: nil) ⇒ Object
Creates a new Segment from
start_pointtoend_pointor, ifvectoris given, fromstart_pointtostart_point+vector.
Class Method Details
.Point(x, y = nil) ⇒ Object
Creates a new Point object from the given coordinates.
See: Point.new
32 33 34 35 36 37 38 39 40 |
# File 'lib/geom2d.rb', line 32 def self.Point(x, y = nil) if x.kind_of?(Point) x elsif y Point.new(x, y) else Point.new(*x) end end |
.Polygon(*vertices) ⇒ Object
Creates a new Polygon object from the given vertices.
See: Polygon.new
59 60 61 |
# File 'lib/geom2d.rb', line 59 def self.Polygon(*vertices) Polygon.new(vertices) end |
.PolygonSet(*polygons) ⇒ Object
Creates a PolygonSet from the given array of Polygon instances.
See: PolygonSet.new
66 67 68 |
# File 'lib/geom2d.rb', line 66 def self.PolygonSet(*polygons) PolygonSet.new(polygons) end |
.Segment(start_point, end_point = nil, vector: nil) ⇒ Object
Creates a new Segment from start_point to end_point or, if vector is given, from start_point to start_point + vector.
See: Segment.new
46 47 48 49 50 51 52 53 54 |
# File 'lib/geom2d.rb', line 46 def self.Segment(start_point, end_point = nil, vector: nil) if end_point Segment.new(start_point, end_point) elsif vector Segment.new(start_point, start_point + vector) else raise ArgumentError, "Either end_point or a vector must be given" end end |