World Builder  1.1.0-pre
A geodynamic initial conditions generator
natural_coordinate.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018-2024 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_OBJECTS_NATURAL_COORDINATE_H
21 #define WORLD_BUILDER_OBJECTS_NATURAL_COORDINATE_H
22 
23 #include <array>
24 #include "world_builder/point.h"
26 
27 namespace WorldBuilder
28 {
29  namespace Objects
30  {
31  /*
32  * A class that represents a point in a chosen coordinate system.
33  */
35  {
36  public:
40  NaturalCoordinate(const std::array<double,3> &position,
41  const ::WorldBuilder::CoordinateSystems::Interface &coordinate_system);
42 
46  NaturalCoordinate(const Point<3> &position,
47  const ::WorldBuilder::CoordinateSystems::Interface &coordinate_system);
48 
53  const std::array<double,3> &get_coordinates() const;
54 
59  std::array<double,2> get_surface_coordinates() const;
60 
66 
71  double get_depth_coordinate() const;
72 
77  double &get_ref_depth_coordinate();
78 
83 
84  private:
90 
94  std::array<double,3> coordinates;
95  };
96 
97 
98  inline
99  double
101  {
102  switch (coordinate_system)
103  {
105  {
106  return coordinates[2];
107  break;
108  }
109 
111  {
112  return coordinates[0];
113  break;
114  }
115 
116  default:
117  WBAssertThrow (false, "Coordinate system not implemented.");
118  }
119 
120  return 0;
121  }
122  }
123 }
124 
125 #endif
std::array< double, 2 > get_surface_coordinates() const
CoordinateSystem get_coordinate_system() const
#define WBAssertThrow(condition, message)
Definition: assert.h:40
NaturalCoordinate(const std::array< double, 3 > &position, const ::WorldBuilder::CoordinateSystems::Interface &coordinate_system)
const std::array< double, 3 > & get_coordinates() const