# Best Ruby Geometry lib?

**URL:** <https://www.ruby-forum.com/t/best-ruby-geometry-lib/177232>\
**Category:** Ruby\
**Created:** [October 13, 2009, 10:31pm UTC](https://www.ruby-forum.com/t/best-ruby-geometry-lib/177232 "2009-10-13T22:31:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [October 13, 2009, 10:31pm UTC](https://www.ruby-forum.com/t/best-ruby-geometry-lib/177232/1 "2009-10-13T22:31:45Z")

</div>

I am looking for a basic geometry library with classes like Point, Line,  
Rect, etc. And with operations like

Rect.new(Point, Point, Point, Point)

or

Line#angle

or

Line#rotate

or

Line#intersect(line)

and so on. Basic, abstract, dealing with points, lines, and other 2d  
constructs. I know it’s everyone’s favorite oo example but is there a  
well worked out, tested library so I don’t have to write me another one?

Thanks!

Pitp

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [October 13, 2009, 11:15pm UTC](https://www.ruby-forum.com/t/best-ruby-geometry-lib/177232/2 "2009-10-13T23:15:24Z")

</div>

Dear Pito,

> I am looking for a basic geometry library with classes like Point, Line,  
> Rect, etc. And with operations like

not exactly a Ruby library, but quite large and fast (written in C++) is  
CGAL:

[http://www.cgal.org/](http://www.cgal.org/)

It already has Python bindings …

Maybe you can use it also via ffi ?

[http://wiki.github.com/ffi/ffi](http://wiki.github.com/ffi/ffi)

Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [October 17, 2010, 7:00am UTC](https://www.ruby-forum.com/t/best-ruby-geometry-lib/177232/3 "2010-10-17T07:00:10Z")

</div>

Pito S. wrote in post #859299:

> I am looking for a basic geometry library with classes like Point, Line,  
> Rect, etc. And with operations like
> 
> Rect.new(Point, Point, Point, Point)
> 
> or
> 
> Line#angle
> 
> or
> 
> Line#rotate
> 
> or
> 
> Line#intersect(line)
> 
> and so on. Basic, abstract, dealing with points, lines, and other 2d  
> constructs. I know it’s everyone’s favorite oo example but is there a  
> well worked out, tested library so I don’t have to write me another one?
> 
> Thanks!
> 
> Pitp

Try [GitHub - DanielVartanov/ruby-geometry: Simple geometry classes and algorithms in Ruby](http://github.com/DanielVartanov/ruby-geometry), or my fork of it, in  
which I just added a line class. It doesn’t have Rect’s yet, but you  
could easily add 'em

-mason
