-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.h
More file actions
83 lines (80 loc) · 2.02 KB
/
Point.h
File metadata and controls
83 lines (80 loc) · 2.02 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef POINT_H
#define POINT_H
#include <vector>
#include <string>
#include <stdlib.h>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <cmath>
#include "cereal/types/unordered_map.hpp"
#include "cereal/types/memory.hpp"
#include "cereal/archives/binary.hpp"
#include "cereal/types/vector.hpp"
#define MAXSTRINGLEN 8
typedef double PointEle;
static const int MaxEles = 3;
#define distanceEuclidean(A,B) (sqrt( \
((A).point_arr[0] - (B).point_arr[0]) \
* ((A).point_arr[0] - (B).point_arr[0]) \
+ \
((A).point_arr[1] - (B).point_arr[1]) \
* ((A).point_arr[1] - (B).point_arr[1]) \
+ \
((A).point_arr[2] - (B).point_arr[2]) \
* ((A).point_arr[2] - (B).point_arr[2]) \
))
class Point
{
//private:
public:
PointEle point_arr[MaxEles];
int NumEles;
//public:
Point()
{
NumEles = 0;
}
template <class Archive>
void serialize(Archive &ar)
{
ar(CEREAL_NVP(point_arr),NumEles);
}
int GetSize();
int Size();
int InitializePoint();
int InitializePoint(double val);
PointEle GetPointEleAtIndex(int index);
//double GetEleAtIndex(int index);
inline double GetEleAtIndex(int index)
{
if(index >= 0 && index < NumEles)
return this->point_arr[index];
throw std::out_of_range("\n**index out of bounds**\n");
}
//double euclidDist(Point &p);
void InsertPointEleAt(PointEle &pe, int index);
void InsertInteger(int val);
void InsertBoolean(bool val);
void InsertString(std::string val);
void InsertFloat(double val);
void SetIntegerAt(int index, int val);
void SetBooleanAt(int index, bool val);
void SetStringAt(int index, std::string val);
void SetFloatAt(int index, double val);
void SetDoubleAt(int index, double val);
PointEle operator[] (int pos);
Point& operator+= (Point &p);
Point operator+ (Point &p);
Point operator- (Point p);
Point& operator-= (Point &p);
Point operator/ (int p);
Point operator* (double val);
Point operator/ (double val);
bool operator== (Point p);
};
std::ostream& operator<< (std::ostream& out, Point p);
#endif