Debian Codegraph @

include/deal.II/base/geometric_utilities.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2016 - 2023 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_geometric_utilities_h
16 #define dealii_geometric_utilities_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/point.h>
21
22 #include <array>
23
24
25 DEAL_II_NAMESPACE_OPEN
26
27
28 /**
29 * A namespace for geometric utility functions that are not particularly
30 * specific to finite element computing or numerical programs, but nevertheless
31 * are needed in various contexts when writing applications.
32 *
33 * @ingroup utilities
34 */
35 namespace GeometricUtilities
36 {
37 /**
38 * A namespace for coordinate transformations.
39 */
40 namespace Coordinates
41 {
42 /**
43 * Return spherical coordinates of a Cartesian point @p point.
44 * The returned array is filled with radius, azimuth angle $\in [0,2 \pi)$
45 * and polar/inclination angle $ \in [0,\pi]$ (omitted in 2d).
46 *
47 * In 3d the transformation is given by
48 * @f{align*}{
49 * r &= \sqrt{x^2+y^2+z^2} \\
50 * \theta &= {\rm atan}(y/x) \\
51 * \phi &= {\rm acos} (z/r)
52 * @f}
53 *
54 * The use of this function is demonstrated in step-75.
55 */
56 template <int dim>
57 std::array<double, dim>
58 to_spherical(const Point<dim> &point);
59
60 /**
61 * Return the Cartesian coordinates of a spherical point defined by @p scoord
62 * which is filled with radius $r \in [0,\infty)$, azimuth angle
63 * $\theta \in [0,2 \pi)$ and polar/inclination angle $\phi \in [0,\pi]$
64 * (omitted in 2d).
65 *
66 * In 3d the transformation is given by
67 * @f{align*}{
68 * x &= r\, \cos(\theta) \, \sin(\phi) \\
69 * y &= r\, \sin(\theta) \, \sin(\phi) \\
70 * z &= r\, \cos(\phi)
71 * @f}
72 */
73 template <std::size_t dim>
74 Point<dim>
75 from_spherical(const std::array<double, dim> &scoord);
76
77 } // namespace Coordinates
78 } // namespace GeometricUtilities
79
80 DEAL_II_NAMESPACE_CLOSE
81
82 #endif