views:

187

answers:

2

I'm looking for a C++ library which allows for easy integration of Coordinate Transformation Matrices (CTM) in my application. You might know CTMs from PDF or PostScript.

For one project we are using C++/Qt4 as a framework, which offers a QTransform class, which provides methods like .translate(double x, double y) or .rotate(double degrees).

After doing some transformations, it would allow me to get all 6 CTM values, which I could feed into a PDF library or use a transformation matrix in export files. Qt's API also allows for arbitrary mapping of polygons (QPolygon), rectangles (QRect) and other primitive data structures into transformed coordinate systems.

So basically I'm looking for something similar to what Qt provides, but without the need of using Qt.

I know I could do the matrix multiplications myself, but I'm not really interested in doing so, as I'm very sure that someone already solved this problem, so please no links to books or other guides on how to multiply matrices.

Thanks!

+1  A: 

Why not just use Qt? It does what you want, is open source (LGPL I think) and you should be able to link just against the QTransform class.

Amos
Yes, unfortunately the QTransform class is not part of QtCore (which I would be fine with), but instead part of QtGui. This would be a ton of overhead, not to mention the depencies on X11, etc.This would add some 15 MB of additional libraries just to use a single feature of that library.
BastiBense
Can you take out the QTransform class, make .h and .cpp files for just that class, and include them in the same way you would your own classes (maybe ream out the class to remove any extra member functions you don't want). Or roll your own transform class based around the code from the Qt version.
Amos
@Amos: Sounds like a reasonable way of doing that, unfortunately that would bind me to the Qt licensing terms -- which would result in putting that code into a library that must be dynamically linked.
BastiBense
A: 

Have you considered OpenGL? It can not only do the types of transforms you're looking for (linear transformations up to 4x4), but it can typically offload that work to your graphics card which will perform the computations on hardware specifically designed for such things (i.e. it's fast).

andand