Mozilla2:GFXMatrix: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Matrix Class ===
== gfxMatrix Class ==
Since we'll be doing scaling, translations and rotates, we need some sort of matrix class.  This class is really just an affine transform and might should be renamed to indicate that.
Since we'll be doing scaling, translations and rotates, we need some sort of matrix class.  This class is really just an affine transform and might should be renamed to indicate that.


=== The API ===
=== The API ===
class Matrix {
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxMatrix.h gfxMatrix.h]
public:
    Matrix() { reset(); }
    Matrix(const Matrix& m);
    Matrix(double a, double b, double c, double d, double tx, double ty);
    const Matrix& operator *= (const Matrix& m) { return multiply(m); }
    Matrix operator * (const Matrix& m) { return Matrix(*this).multiply(m); }
    const Matrix& reset();
    const Matrix& scale(double x, double y);
    const Matrix& translate(double x, double y);
    const Matrix& rotate(double radians);
    const Matrix& multiply(const Matrix& m);
    void transformDistance(double *dx, double *dy) const;
    void transformPoint(double *x, double *y) const;
};


=== Notes ===
=== Notes ===
We may just want to implement this using cairo_matrix objects instead, although there is more overhead to doing that.
Cairo currently uses row vectors to transform points, which is less optimal than if we used column vectors.
Cairo currently uses row vectors to transform points, which is less optimal than if we used column vectors.

Latest revision as of 03:50, 11 April 2005

gfxMatrix Class

Since we'll be doing scaling, translations and rotates, we need some sort of matrix class. This class is really just an affine transform and might should be renamed to indicate that.

The API

gfxMatrix.h

Notes

We may just want to implement this using cairo_matrix objects instead, although there is more overhead to doing that.

Cairo currently uses row vectors to transform points, which is less optimal than if we used column vectors.