views:

462

answers:

3

What are the best tools/libraries (in any language) for working with 2D constructive area geometry?

That is, a library working with more or less arbitrary two dimensional shapes and supplying union, intersection, difference and XOR.

My baseline is the java.awt.geom.Area class, and that's serviceable if slow. What's out there that's better? My particular interests are Java, ActionScript/Flex, and C libraries, but I'm open to any comers.

A: 

The Computational Geometry Algorithms Library is quite extensive. It had a commercial and an open source license last time I checked.

codelogic
+1  A: 

Two options come in mind

  1. Cairo Graphics for C
  2. Antigrain for C++

I propose Cairo. It is

  • Mature
  • Tested (used internally in GTK+ and Mozilla)
  • supported (great community mailing list, irc, web e.t.c)
  • Open Source

Cairo has already the operators you mention (union, intersection, difference e.t.c) and using paths you can draw any shape you can imagine.

kazanaki
A: 

If you are in the windows world you may consider using MFC which has CRgn and other ops that you can use to compute those differences- most notably it is easy to create splines that clip regions- and then you can easily work with those clipped regions (areas, intersections, etc).

I assume since the MFC operations are encapsulating GDI- you could use GDI directly to do the same ops, but of course if you have and don't mind MFC then it is worth checking out.

Klathzazt