-
Notifications
You must be signed in to change notification settings - Fork 0
/
DgHexC1Grid2D.h
71 lines (53 loc) · 2.26 KB
/
DgHexC1Grid2D.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
////////////////////////////////////////////////////////////////////////////////
//
// DgHexC1Grid2D.h: DgHexC1Grid2D class definitions
//
// Version 6.1 - Kevin Sahr, 5/23/13
//
////////////////////////////////////////////////////////////////////////////////
#ifndef DGHEXC1GRID2D_H
#define DGHEXC1GRID2D_H
#include <cmath>
#include <cstdint>
#include "DgDiscRF2D.h"
#include "DgDVec2D.h"
#include "DgIVec2D.h"
class DgPolygon;
////////////////////////////////////////////////////////////////////////////////
class DgHexC1Grid2D : public DgDiscRF2D {
public:
DgHexC1Grid2D (DgRFNetwork& networkIn,
const DgRF<DgDVec2D, long double>& ccFrameIn,
const string& nameIn = "HexC12D")
: DgDiscRF2D (networkIn, ccFrameIn, nameIn, 1.0 / sqrt(3.0),
1.0 / sqrt(3.0), sqrt(3.0) / 2.0, 1.0)
{ area_ = c(); }
DgHexC1Grid2D (const DgHexC1Grid2D& grd) : DgDiscRF2D (grd) {}
DgHexC1Grid2D& operator= (const DgHexC1Grid2D& grd)
{ DgDiscRF2D::operator=(grd); return *this; }
virtual std::int64_t dist (const DgIVec2D& add1, const DgIVec2D& add2) const
{ DgIVec2D diff = add2 - add1;
if ((diff.i() >= 0 && diff.j() <= 0) ||
(diff.i() <= 0 && diff.j() >= 0)) /* different signs */
{
return abs(diff.i()) + abs(diff.j());
}
else /* same signs */
{
diff.setI(abs(diff.i()));
diff.setJ(abs(diff.j()));
return (diff.i() > diff.j()) ? diff.i() : diff.j();
}}
protected:
static const long double sin60_;
virtual void setAddVertices (const DgIVec2D& add, DgPolygon& vec) const;
virtual void setAddNeighbors
(const DgIVec2D& add, DgLocVector& vec) const;
virtual DgIVec2D quantify (const DgDVec2D& point) const;
virtual DgDVec2D invQuantify (const DgIVec2D& add) const
{ return DgDVec2D(add.i() - 0.5 * add.j(),
add.j() * 1.5 * r()); }
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#endif