World Builder  0.1.0-pre
A geodyanmic initial conditions generator
point.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018 by the authors of the World Builder code.
3 
4  This file is part of the World Builder.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef _world_builder_point_h
21 #define _world_builder_point_h
22 
23 #include <array>
24 #include <cmath>
25 
27 
28 namespace WorldBuilder
29 {
36  template<int dim>
37  class Point
38  {
39  public:
44  Point();
45 
50  Point(const std::array<double,dim> &location, CoordinateSystem coordinate_system = CoordinateSystem::cartesian);
51 
56  Point(const Point<dim> &point, CoordinateSystem coordinate_system = CoordinateSystem::cartesian);
57 
62  Point(const double x, const double y, CoordinateSystem coordinate_system = CoordinateSystem::cartesian);
63 
68  Point(const double x, const double y, const double z, CoordinateSystem coordinate_system = CoordinateSystem::cartesian);
69 
73  ~Point();
74 
75  Point<dim> &operator=(const Point<dim> &point);
76 
80  double operator*(const Point<dim> &point) const;
81 
82 
86  Point<dim> operator*(const double scalar) const;
87 
91  Point<dim> operator+(const Point<dim> &point) const;
92 
93 
97  Point<dim> operator-(const Point<dim> &point) const;
98 
99 
100 
104  Point<dim> &operator*=(const double scalar);
105 
109  Point<dim> &operator+=(const Point<dim> &point);
110 
111 
115  Point<dim> &operator-=(const Point<dim> &point);
116 
120  const double &operator[](const unsigned int index) const;
121 
122 
126  double &operator[](const unsigned int index);
127 
128 
132  const std::array<double,dim> &get_array() const;
133 
134 
139 
140 
144  double norm() const;
145 
146 
151  double norm_square() const;
152 
153 
154  private:
155  std::array<double,dim> point;
156  CoordinateSystem coordinate_system;
157 
158  };
159 
160  template<int dim>
161  Point<dim> operator*(const double scalar, const Point<dim> &point);
162 }
163 #endif
const double & operator[](const unsigned int index) const
Definition: point.cc:180
Point< dim > & operator+=(const Point< dim > &point)
Definition: point.cc:157
double norm_square() const
Point< dim > & operator=(const Point< dim > &point)
Definition: point.cc:97
CoordinateSystem get_coordinate_system() const
Definition: point.cc:209
Point< dim > operator+(const Point< dim > &point) const
Definition: point.cc:127
const std::array< double, dim > & get_array() const
Definition: point.cc:201
double norm() const
Definition: point.cc:217
double operator*(const Point< dim > &point) const
Definition: point.cc:105
Point< dim > & operator*=(const double scalar)
Definition: point.cc:148
Point< dim > operator-(const Point< dim > &point) const
Definition: point.cc:137
Point< dim > & operator-=(const Point< dim > &point)
Definition: point.cc:167