-
Notifications
You must be signed in to change notification settings - Fork 5
/
point.h
163 lines (154 loc) · 4.87 KB
/
point.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/******************************************************/
/* */
/* point.h - classes for points */
/* */
/******************************************************/
/* Copyright 2019,2020,2022 Pierre Abbat.
* This file is part of PerfectTIN.
*
* PerfectTIN is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* PerfectTIN 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 and Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and Lesser General Public License along with PerfectTIN. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef POINT_H
#define POINT_H
#include <string>
#include <fstream>
#include <vector>
#include <cmath>
class xyz;
class latlong;
#include "quaternion.h"
class xy
{
public:
xy(double e,double n);
xy(xyz point);
xy();
double east() const;
double north() const;
double getx() const;
double gety() const;
double length() const;
bool isfinite() const;
bool isnan() const;
double dirbound(int angle);
void _roscat(xy tfrom,int ro,double sca,xy cis,xy tto);
void roscat(xy tfrom,int ro,double sca,xy tto); // rotate, scale, translate
friend xy operator+(const xy &l,const xy &r);
friend xy operator+=(xy &l,const xy &r);
friend xy operator-=(xy &l,const xy &r);
friend xy operator-(const xy &l,const xy &r);
friend xy operator-(const xy &r);
friend xy operator*(const xy &l,double r);
friend xy operator*(double l,const xy &r);
friend xy operator/(const xy &l,double r);
friend xy operator/=(xy &l,double r);
friend bool operator!=(const xy &l,const xy &r);
friend bool operator==(const xy &l,const xy &r);
friend xy turn90(xy a);
friend xy turn(xy a,int angle);
friend double dist(xy a,xy b);
friend int dir(xy a,xy b);
friend double dot(xy a,xy b);
friend double area3(xy a,xy b,xy c);
friend class triangle;
friend class point;
friend class xyz;
friend class qindex;
protected:
double x,y;
};
extern const xy nanxy;
class xyz
{
public:
xyz(double e,double n,double h);
xyz();
xyz(xy en,double h);
double east() const;
double north() const;
double elev() const;
double getx() const;
double gety() const;
double getz() const;
bool isfinite() const;
bool isnan() const;
double length();
void normalize();
void raise(double height);
void _roscat(xy tfrom,int ro,double sca,xy cis,xy tto);
void _roscat(xyz tfrom,int ro,double sca,xy cis,xyz tto);
void roscat(xy tfrom,int ro,double sca,xy tto);
void roscat(xyz tfrom,int ro,double sca,xyz tto);
void setelev(double h)
{
z=h;
}
friend class xy;
friend class point;
friend class triangle;
friend class Quaternion;
friend double dist(xyz a,xyz b);
friend double dot(xyz a,xyz b);
friend xyz cross(xyz a,xyz b);
friend bool operator==(const xyz &l,const xyz &r);
friend bool operator!=(const xyz &l,const xyz &r);
friend xyz operator/(const xyz &l,const double r);
friend xyz operator*=(xyz &l,double r);
friend xyz operator/=(xyz &l,double r);
friend xyz operator+=(xyz &l,const xyz &r);
friend xyz operator-=(xyz &l,const xyz &r);
friend xyz operator*(const xyz &l,const double r);
friend xyz operator*(const double l,const xyz &r);
friend xyz operator*(const xyz &l,const xyz &r); // cross product
friend xyz operator+(const xyz &l,const xyz &r);
friend xyz operator-(const xyz &l,const xyz &r);
friend xyz operator-(const xyz &r);
friend Quaternion versor(xyz vec);
friend Quaternion versor(xyz vec,int angle);
friend Quaternion versor(xyz vec,double angle);
protected:
double x,y,z;
};
extern const xyz nanxyz;
class edge;
class triangle;
class pointlist;
class point: public xyz
{
public:
//xy pagepos; //used when dumping a lozenge in PostScript
point();
point(double e,double n,double h);
point(xy pnt,double h);
point(xyz pnt);
point(const point &rhs);
//~point();
point& operator=(const point &rhs);
friend class edge;
friend void rotate(pointlist &pl,int n);
friend void movesideways(pointlist &pl,double sw);
friend void moveup(pointlist &pl,double sw);
friend void enlarge(pointlist &pl,double sw);
edge *line; // a line incident on this point in the TIN. Used to arrange the lines in order around their endpoints.
edge *edg(triangle *tri);
// tri.a->edg(tri) is the side opposite tri.b
int valence();
std::vector<edge *> incidentEdges();
edge *isNeighbor(point *pnt);
void insertEdge(edge *edg);
void removeEdge(edge *edg);
};
#endif