https://github.com/gettalong/geom2d
Objects and Algorithms for 2D Geometry in Ruby
https://github.com/gettalong/geom2d
geometry polygon-boolean polygon-clipping-algorithm ruby
Last synced: 2 months ago
JSON representation
Objects and Algorithms for 2D Geometry in Ruby
- Host: GitHub
- URL: https://github.com/gettalong/geom2d
- Owner: gettalong
- License: other
- Created: 2018-03-28T07:30:30.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-31T20:46:44.000Z (almost 2 years ago)
- Last Synced: 2025-02-28T18:39:48.236Z (3 months ago)
- Topics: geometry, polygon-boolean, polygon-clipping-algorithm, ruby
- Language: Ruby
- Size: 47.9 KB
- Stars: 12
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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-2023 Thomas Leitner , licensed under the MIT - see the
**LICENSE** file.## Features
* Objects
* Point
* Segment
* Polygon
* PolygonSet
* Rectangle
* Polyline (TODO)
* Rectangle (TODO)
* QuadraticCurve (TODO)
* QubicCurve (TODO)
* Arc (TODO)
* Circle (TODO)
* Path (TODO)
* Algorithms
* Segment-Segment Intersection
* Boolean Operations on PolygonSets## Usage
~~~ ruby
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
~~~