File: Matrix.hpp

package info (click to toggle)
openlayer 2.1-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,368 kB
  • ctags: 2,295
  • sloc: ansic: 10,432; cpp: 9,890; xml: 109; makefile: 89; sh: 36
file content (49 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef OL_MATRIX_HPP
#define OL_MATRIX_HPP


#include "Vec2D.hpp"
#include "Declspec.hpp"


namespace ol {


class OL_LIB_DECLSPEC Matrix2D {
public:
   
   enum {
      SIDE_LENGTH = 2,
      NUM_VALUES = SIDE_LENGTH * SIDE_LENGTH
   };
   
   
   inline float Get( int x, int y ) const {
      return values[SIDE_LENGTH * y + x];
   }
   
   
   inline void Set( int x, int y, float val ) {
      values[SIDE_LENGTH * y + x] = val;
   }
   
   
   inline Vec2D Transform( const Vec2D &vec ) {
      return Vec2D( Get( 0, 0 ) * vec.x + Get( 1, 0 ) * vec.y,
                    Get( 0, 1 ) * vec.x + Get( 1, 1 ) * vec.y );
   }
   
   
   float values[NUM_VALUES];
};



Matrix2D operator*( const Matrix2D &first, const Matrix2D &second );



}


#endif // OL_MATRIX_HPP