-
Notifications
You must be signed in to change notification settings - Fork 17
/
mymath.h
62 lines (51 loc) · 1.91 KB
/
mymath.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
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
/*
C-PCB
Copyright (C) 2015 Chris Hinsley
chris (dot) hinsley (at) gmail (dot) com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MYMATH_H
#define MYMATH_H
#include <vector>
#include <tuple>
//public math structures
struct point_2d
{
point_2d() : m_x(0.0), m_y(0.0) {}
point_2d(double x, double y) : m_x(x), m_y(y) {}
bool operator==(const point_2d &p) const {
return std::tie(m_x, m_y) == std::tie(p.m_x, p.m_y); }
bool operator!=(const point_2d &p) const {
return std::tie(m_x, m_y) != std::tie(p.m_x, p.m_y); }
bool operator<(const point_2d &p) const {
return std::tie(m_x, m_y) < std::tie(p.m_x, p.m_y); }
double m_x;
double m_y;
};
typedef std::vector<point_2d> points_2d;
struct point_3d
{
point_3d() : m_x(0.0), m_y(0.0), m_z(0.0) {}
point_3d(double x, double y, double z) : m_x(x), m_y(y), m_z(z) {}
bool operator==(const point_3d &p) const {
return std::tie(m_x, m_y, m_z) == std::tie(p.m_x, p.m_y, p.m_z); }
bool operator!=(const point_3d &p) const {
return std::tie(m_x, m_y, m_z) != std::tie(p.m_x, p.m_y, p.m_z); }
bool operator<(const point_3d &p) const {
return std::tie(m_x, m_y, m_z) < std::tie(p.m_x, p.m_y, p.m_z); }
double m_x;
double m_y;
double m_z;
};
typedef std::vector<point_3d> points_3d;
#endif