-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfpoint_t.h
More file actions
62 lines (45 loc) · 1.77 KB
/
fpoint_t.h
File metadata and controls
62 lines (45 loc) · 1.77 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef FPOINT_T_H
#define FPOINT_T_H
#include "cnc_param.h"
#include <string>
#include <QPointF>
struct RotateMatrix {
double mx[2][2] {{1,0}, {0,1}};
RotateMatrix(double phi);
void set(double phi);
};
struct fpoint_t {
constexpr static const double CMP_PRECISION = CncParam::PRECISION; // 0.5 um
double x{0}, y{0};
explicit fpoint_t(double x = 0, double y = 0);
fpoint_t(const fpoint_t& other);
fpoint_t& operator=(const fpoint_t& other);
bool operator==(const fpoint_t& other) const;
bool operator!=(const fpoint_t& other) const;
fpoint_t operator-() const;
fpoint_t operator+(const fpoint_t& other) const;
fpoint_t operator-(const fpoint_t& other) const;
void shift(const fpoint_t& offset);
void shift(double dx, double dy);
void rotate(const RotateMatrix& mx);
void flipX(double x);
void flipY(double y);
void scale(double pct);
std::string toString() const;
operator QPointF() { return QPointF(x, y); }
void swap();
};
struct fpoint_valid_t : public fpoint_t {
bool valid {false};
fpoint_valid_t(double _x = 0, double _y = 0, bool valid = true) : fpoint_t(_x, _y), valid(valid) {}
fpoint_valid_t(const fpoint_t& point, bool valid = true) : fpoint_t(point), valid(valid) {}
explicit fpoint_valid_t(bool valid) : fpoint_t(fpoint_t()), valid(valid) {}
fpoint_valid_t(const fpoint_valid_t& other) : fpoint_t(other.x, other.y), valid(other.valid) {}
static fpoint_valid_t null() { return fpoint_valid_t(0,0,false); }
fpoint_valid_t& operator=(const fpoint_valid_t& other);
bool operator==(const fpoint_valid_t& other) const;
bool operator!=(const fpoint_valid_t& other) const;
// fpoint_valid_t operator-() const;
std::string toString() const;
};
#endif // FPOINT_T_H