-
Notifications
You must be signed in to change notification settings - Fork 1
/
affine.h
33 lines (27 loc) · 991 Bytes
/
affine.h
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
#ifndef AFFINE_H
#define AFFINE_H
#include <vector>
#include <cmath>
#include <QPoint>
using std::vector;
class Affine
{
public:
explicit Affine();
QPoint translate(const QPoint &point, int dx, int dy);
QPoint rotate(const QPoint &point, int x, int y, int angle);
QPoint scale(const QPoint &point, float sX, float sY);
QPoint scale(const QPoint &point, float sX, float sY, int x, int y);
QPoint reflect(const QPoint &point, int x, int y);
private:
vector<vector<double>> getMatFromPoint(const QPoint &point) const;
QPoint getPointFromMat(const vector<vector<double>> &mat) const;
void setTranslate(int dx, int dy);
void setScale(float sx, float sy);
void setRotate(int angle);
void setReflect(int x, int y);
vector<vector<double>> mul(const vector<vector<double>> &point,
const vector<vector<double>> &mat) const;
vector<vector<double>> rotateMat, scaleMat, transMat, refMat;
};
#endif // AFFINE_H