T2DMath.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Helper classes for 2D linear mathematics
  3. * Copyright (c) 2010 Nokia Corporation.
  4. *
  5. */
  6. #ifndef __T2DMATH__
  7. #define __T2DMATH__
  8. #include "TMath.h"
  9. class CT2DVector {
  10. public:
  11. CT2DVector();
  12. ~CT2DVector();
  13. inline CT2DVector& set( const int x, const int y ) { m_x=x; m_y=y; return *this; }
  14. inline CT2DVector& set( const CT2DVector &s ) { set( s.m_x, s.m_y ); return *this; }
  15. void add( const CT2DVector &add );
  16. void sub( const CT2DVector &sub );
  17. void createBetweenVectors( const CT2DVector &start, const CT2DVector &end );
  18. int dotProduct( const CT2DVector &v ) const;
  19. int project( const CT2DVector &v );
  20. void fixedMul( const int mul, const int bits = FP_BITS );
  21. void normalize();
  22. int length();
  23. int setLength( const int l );
  24. int m_x;
  25. int m_y;
  26. };
  27. class CT2DMatrix {
  28. public:
  29. CT2DMatrix();
  30. ~CT2DMatrix();
  31. void setIdentity();
  32. void transform( const CT2DVector *source, CT2DVector *target, int count );
  33. int m[2][2];
  34. };
  35. #endif