GLAMERDOC++
Gravitational Lensing Code Library
Loading...
Searching...
No Matches
veronoi.h
1//
2// veronoi.h
3// GLAMER
4//
5// Created by Ben Metcalf on 27/02/15.
6//
7//
8
9#ifndef GLAMER_veronoi_h
10#define GLAMER_veronoi_h
11
12#include "point.h"
13
14class Point_Nd{
15
16 Point_Nd(int Nin){
17 dim = Nin;
18 x.resize(Nin);
19 }
20 ~Point_Nd(){x.clear();};
21
22 Point_Nd(const Point_Nd &p){
23 for(int i=0;i<dim;++i) x[i]=p.x[i];
24 }
25 Point_Nd & operator=(const Point_Nd &p){
26 if(this == &p) return *this;
27 for(int i=0;i<dim;++i) x[i]=p.x[i];
28 return *this;
29 }
30 Point_Nd & operator=(const Point &p){
31 for(int i=0;i<dim;++i) x[i]=p.x[i];
32 return *this;
33 }
34
35 Point_Nd & operator+=(const Point &p){
36 for(int i=0;i<dim;++i) x[i]+=p.x[i];
37 return *this;
38 }
39 Point_Nd operator+(const Point_Nd &p) const{
40 Point_Nd tmp(p.dim);
41 for(int i=0;i<dim;++i) tmp.x[i] = x[i] + p.x[i];
42 return tmp;
43 }
44 Point_Nd operator-(const Point_Nd &p) const{
45 Point_Nd tmp(p.dim);
46 for(int i=0;i<dim;++i) tmp.x[i] = x[i] - p.x[i];
47 return tmp;
48 }
49 Point_Nd & operator+=(const Point_Nd &p){
50 for(int i=0;i<dim;++i) x[i]+=p.x[i];
51 return *this;
52 }
53 Point_Nd & operator/=(PosType value){
54 for(int i=0;i<dim;++i) x[i]/=value;
55 return *this;
56 }
57 Point_Nd & operator/(PosType value){
58 for(int i=0;i<dim;++i) x[i]/=value;
59 return *this;
60 }
61 Point_Nd & operator*=(PosType value){
62 for(int i=0;i<dim;++i) x[i]*=value;
63 return *this;
64 }
66 PosType operator*(const Point_Nd &p){
67 PosType sum =0;
68 for(int i=0;i<dim;++i) sum += x[i]*p.x[i];
69 return 0.0;
70 }
72 //PosType operator^(const Point_Nd &p){
73 // return x[0]*p.x[1] - x[1]*p.x[0];
74 //}
75
77 PosType length(){
78 return sqrt((*this)*(*this));
79 }
80
81 PosType & operator[](size_t i){return x[i];}
82private:
83 std::vector<PosType> x;
84 int dim;
85};
86
87
88class Simplex_Nd{
89 Simplex_Nd(int D,Point_Nd *points){
90 vecs.resize(D+1);
91 for(int i=0;i<D+1;++i) vecs[i] = &points[i];
92 }
93
94 Point_Nd & RandomPointWithin();
95 double Volume(){return volume;}
96private:
97 std::vector<Point_Nd *> vecs;
98 PosType volume;
99 void CalcVolume();
100};
101
102#endif
A point on the source or image plane that contains a position and the lensing quantities.
Definition point.h:414