wxmatrix.h Source File

Main Page Class Hierarchy Compound List File List Compound Members

# wxmatrix.h

    00001
    00002 // Name:        matrix.h
    00003 // Purpose:     wxTransformMatrix class. NOT YET USED
    00005 // Modified by:  Klaas Holwerda
    00006 // Created:     01/02/97
    00007 // RCS-ID:      $Id: wxmatrix.h,v 1.7 2000/11/20 09:14:14 protools Exp $
    00008 // Copyright:   (c) Julian Smart and Markus Holzem
    00009 // Licence:     wxWindows licence
    00011
    00012 #ifndef _WX_MATRIXH__
    00013 #define _WX_MATRIXH__
    00014
    00015 #ifdef __GNUG__
    00016 #pragma interface "matrix.h"
    00017 #endif
    00018
    00019 #include "wx/object.h"
    00020
    00021
    00023
    00033 class WXDLLEXPORT wxTransformMatrix: public wxObject
    00034 {
    00035 public:
    00036         wxTransformMatrix(void);
    00037         wxTransformMatrix(const wxTransformMatrix& mat);
    00038
    00042         double GetValue(int col, int row) const;
    00043
    00047         void SetValue(int col, int row, double value);
    00048
    00049         void operator = (const wxTransformMatrix& mat);
    00050         bool operator == (const wxTransformMatrix& mat);
    00051         bool operator != (const wxTransformMatrix& mat);
    00052
    00054     wxTransformMatrix&                  operator*=(const double& t);
    00056     wxTransformMatrix&                  operator/=(const double& t);
    00058     wxTransformMatrix&                  operator+=(const wxTransformMatrix& m);
    00060     wxTransformMatrix&                  operator-=(const wxTransformMatrix& m);
    00062     wxTransformMatrix&                  operator*=(const wxTransformMatrix& m);
    00063
    00065
    00067     wxTransformMatrix                   operator*(const double& t) const;
    00069     wxTransformMatrix                   operator/(const double& t) const;
    00071     wxTransformMatrix                   operator+(const wxTransformMatrix& m) const;
    00073     wxTransformMatrix                   operator-(const wxTransformMatrix& m) const;
    00075     wxTransformMatrix                   operator*(const wxTransformMatrix& m) const;
    00076     wxTransformMatrix                   operator-() const;
    00077
    00080         double& operator()(int col, int row);
    00081
    00084         double operator()(int col, int row) const;
    00085
    00087         bool Invert(void);
    00088
    00090         bool Identity(void);
    00091
    00095         inline bool IsIdentity(void) const { return m_isIdentity; };
    00096
    00098         inline bool IsIdentity1(void) const ;
    00099
    00101
    00108         bool Scale(double scale);
    00109
    00112
    00119         wxTransformMatrix&      Scale(const double &xs, const double &ys,const double &xc, const double &yc);
    00120
    00122
    00130         wxTransformMatrix&      Mirror(bool x=true, bool y=false);
    00131
    00133
    00141         bool Translate(double x, double y);
    00142
    00144
    00151         bool Rotate(double angle);
    00152
    00155
    00163         wxTransformMatrix&      Rotate(const double &r, const double &x, const double &y);
    00164
    00166         inline double TransformX(double x) const;
    00167
    00169         inline double TransformY(double y) const;
    00170
    00172         bool TransformPoint(double x, double y, double& tx, double& ty) const;
    00173
    00175
    00189         bool InverseTransformPoint(double x, double y, double& tx, double& ty) const;
    00190
    00191         double Get_scaleX();
    00192         double Get_scaleY();
    00193     double GetRotation();
    00194     void   SetRotation(double rotation);
    00195
    00196
    00197 public:
    00198     double      m_matrix[3][3];
    00199         bool    m_isIdentity;
    00200 };
    00201
    00202
    00203 /*
    00204 Chris Breeze reported, that
    00205 some functions of wxTransformMatrix cannot work because it is not
    00206 known if he matrix has been inverted. Be careful when using it.
    00207 */
    00208
    00215 inline double wxTransformMatrix::TransformX(double x) const
    00216 {
    00220         return (m_isIdentity ? x : (x * m_matrix[0][0] +  m_matrix[2][0]));
    00221 }
    00222
    00229 inline double wxTransformMatrix::TransformY(double y) const
    00230 {
    00234         return (m_isIdentity ? y : (y * m_matrix[1][1] + m_matrix[2][1]));
    00235 }
    00236
    00237
    00240 inline bool wxTransformMatrix::IsIdentity1(void) const
    00241 {
    00242         return
    00243          (m_matrix[0][0] == 1.0 &&
    00244           m_matrix[1][1] == 1.0 &&
    00245           m_matrix[2][2] == 1.0 &&
    00246           m_matrix[1][0] == 0.0 &&
    00247           m_matrix[2][0] == 0.0 &&
    00248           m_matrix[0][1] == 0.0 &&
    00249           m_matrix[2][1] == 0.0 &&
    00250           m_matrix[0][2] == 0.0 &&
    00251           m_matrix[1][2] == 0.0) ;
    00252 }
    00253
    00255 inline double wxCalculateDet(double a11, double a21, double a12, double a22)
    00256 {
    00257         return a11 * a22 - a12 * a21;
    00258 }
    00259
    00260 #endif
    00261

wxmatrix.h Source File -- Thu Nov 28 21:24:56 2002 -- 28 Nov 2002 -- 1.2.18 -- -- . -- Main Page