Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.
/ geom2d Public archive
forked from gettalong/geom2d

Objects and Algorithms for 2D Geometry in Ruby

License

Notifications You must be signed in to change notification settings

bugcrowd/geom2d

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geom2D - Objects and Algorithms for 2D Geometry in Ruby

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

License

Copyright (C) 2018 Thomas Leitner t_leitner@gmx.at, licensed under the MIT - see the LICENSE file.

Features

  • Objects
    • Point
    • Segment
    • Polygon
    • PolygonSet
    • Polyline (TODO)
    • Rectangle (TODO)
    • QuadraticCurve (TODO)
    • QubicCurve (TODO)
    • Arc (TODO)
    • Circle (TODO)
    • Path (TODO)
  • Algorithms
    • Segment-Segment Intersection
    • Boolean Operations on PolygonSets

Usage

require 'geom2d'

# Point, can also be interpreted as vector
point1 = Geom2D::Point(2, 2)
point2 = Geom2D::Point([2, 2])   # arrays are fine but not as efficient
point3 = Geom2D::Point(point2)   # copy constructor

# Segment defined by two points or a point and a vector
line1 = Geom2D::Segment(point1, point2)
line2 = Geom2D::Segment(point1, vector: point2)
line3 = Geom2D::Segment([3, 4], [9, 6])   # arrays are also possible

# Segment intersection
line1.intersect(line3)  # => intersection_point

About

Objects and Algorithms for 2D Geometry in Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%