module Geom2D

Geom2D - Objects and Algorithms for 2D Geometry in Ruby

This library implements objects for 2D geometry, like points, line segments, arcs, curves and so on, as well as algorithms for these objects, like line-line intersections and arc approximation by Bezier curves.

Constants

VERSION

The version of Geom2D

Public Class Methods

Point(x, y = nil) click to toggle source

Creates a new Point object from the given coordinates.

See: Point.new

# File lib/geom2d.rb, line 31
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) click to toggle source

Creates a new Polygon object from the given vertices.

See: Polygon.new

# File lib/geom2d.rb, line 58
def self.Polygon(*vertices)
  Polygon.new(vertices)
end
PolygonSet(*polygons) click to toggle source

Creates a PolygonSet from the given array of Polygon instances.

See: PolygonSet.new

# File lib/geom2d.rb, line 65
def self.PolygonSet(*polygons)
  PolygonSet.new(polygons)
end
Segment(start_point, end_point = nil, vector: nil) click to toggle source

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

# File lib/geom2d.rb, line 45
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