Advertisement
Guest User

Matrix2.h

a guest
Mar 5th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. // Matrix2.h by Vasillen M. Chizhov
  2.  
  3. #pragma once
  4. #include "util.h"
  5. namespace myGameMathLib
  6. {
  7.     class Matrix2
  8.     {
  9.     public:
  10.         FP _11, _12;
  11.         FP _21, _22;
  12.  
  13.     public:
  14.         //ctors
  15.  
  16.         Matrix2();
  17.  
  18.         Matrix2(FP value);
  19.  
  20.         Matrix2(FP _11, FP _12, FP _21, FP _22);
  21.  
  22.         Matrix2(const Matrix2& another);
  23.  
  24.     public:
  25.  
  26.         Matrix2& operator=(const Matrix2& another);
  27.  
  28.         Matrix2& operator+=(const Matrix2& another);
  29.  
  30.         Matrix2& operator-=(const Matrix2& another);
  31.  
  32.         Matrix2& operator*=(const Matrix2& another);
  33.  
  34.         Matrix2& operator*=(FP scalar);
  35.  
  36.         Matrix2& operator/=(FP scalar);
  37.  
  38.         Matrix2 operator+();
  39.  
  40.         Matrix2 operator-();
  41.  
  42.     public:
  43.  
  44.         FP det() const;
  45.  
  46.         FP trace() const;
  47.  
  48.         Matrix2 transpose() const;
  49.  
  50.         Matrix2 inverse() const;
  51.  
  52.     public:
  53.         static Matrix2 rotation(FP angle);
  54.  
  55.         static Matrix2 shearX(FP shearX);
  56.  
  57.         static Matrix2 shearY(FP shearY);
  58.  
  59.         static Matrix2 scaling(FP sx, FP sy);
  60.  
  61.     public:
  62.  
  63.         static Matrix2 Identity;
  64.         static Matrix2 Zero;
  65.  
  66.     };
  67.  
  68.     bool operator==(const Matrix2& mat1, const Matrix2& mat2);
  69.  
  70.     bool operator!=(const Matrix2& mat1, const Matrix2& mat2);
  71.  
  72.     Matrix2 operator+(const Matrix2& mat1, const Matrix2& mat2);
  73.  
  74.     Matrix2 operator-(const Matrix2& mat1, const Matrix2& mat2);
  75.  
  76.     Matrix2 operator*(const Matrix2& mat1, const Matrix2& mat2);
  77.  
  78.     Matrix2 operator*(const Matrix2& mat, FP scalar);
  79.  
  80.     Matrix2 operator*(FP scalar, const Matrix2& mat);
  81.  
  82.     Matrix2 operator/(const Matrix2& mat, FP scalar);
  83.  
  84.     Matrix2 operator/(FP scalar, const Matrix2& mat);
  85.  
  86.     FP det(const Matrix2& mat);
  87.  
  88.     FP trace(const Matrix2& mat);
  89.  
  90.     Matrix2 transpose(const Matrix2& mat);
  91.  
  92.     void transpose(Matrix2& mat);
  93.  
  94.     Matrix2 inverse(const Matrix2& mat);
  95.  
  96.     void inverse(Matrix2& mat);
  97.  
  98.     std::ostream& operator<<(std::ostream& os, const Matrix2& mat);
  99.  
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement