Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
Cartesian3DPoint.hpp
1//---- GPL ---------------------------------------------------------------------
2//
3// Copyright (C) Stichting Deltares, 2011-2025.
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation version 3.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17// contact: delft3d.support@deltares.nl
18// Stichting Deltares
19// P.O. Box 177
20// 2600 MH Delft, The Netherlands
21//
22// All indications and logos of, and references to, "Delft3D" and "Deltares"
23// are registered trademarks of Stichting Deltares, and remain the property of
24// Stichting Deltares. All rights reserved.
25//
26//------------------------------------------------------------------------------
27
28#pragma once
29
30#include <cmath>
31
32#include "MeshKernel/Point.hpp"
33
34namespace meshkernel
35{
36
39 {
40 double x;
41 double y;
42 double z;
43 };
44
46 double separationDistance(const Cartesian3DPoint& p1, const Cartesian3DPoint& p2);
47
51 std::tuple<double, double, double> ComputeSphericalCoordinatesFromLatitudeAndLongitude(const Point& point);
52
58
63 [[nodiscard]] double InnerProduct(const Cartesian3DPoint& a, const Cartesian3DPoint& b);
64
66 Cartesian3DPoint operator*(const Cartesian3DPoint& p, const double value);
67
69 Cartesian3DPoint operator*(const double value, const Cartesian3DPoint& p);
70
72 Cartesian3DPoint operator/(const Cartesian3DPoint& p, const double value);
73
76
79
83 [[nodiscard]] Cartesian3DPoint SphericalToCartesian3D(const Point& sphericalPoint);
84
89 [[nodiscard]] Point Cartesian3DToSpherical(const Cartesian3DPoint& cartesianPoint, double referenceLongitude);
90
91} // end namespace meshkernel
92
94{
95 return {p1.x + p2.x, p1.y + p2.y, p1.z + p2.z};
96}
97
99{
100 return {p1.x - p2.x, p1.y - p2.y, p1.z - p2.z};
101}
102
104{
105 return {p.x / value, p.y / value, p.z / value};
106}
107
109{
110 return {value * p.x, value * p.y, value * p.z};
111}
112
114{
115 return value * p;
116}
117
119{
120 return a.x * b.x + a.y * b.y + a.z * b.z;
121}
122
124{
125 double dx = p1.x - p2.x;
126 double dy = p1.y - p2.y;
127 double dz = p1.z - p2.z;
128 return std::sqrt(dx * dx + dy * dy + dz * dz);
129}
A struct describing a point in a two-dimensional space.
Definition Point.hpp:41
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
double separationDistance(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Compute the separation distance of two points in 3D Cartesian coordinate system,.
Definition Cartesian3DPoint.hpp:123
Cartesian3DPoint VectorProduct(const Cartesian3DPoint &a, const Cartesian3DPoint &b)
Defines vector product for cartesian 3D-space.
Cartesian3DPoint operator+(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Add Cartesian point p2 to p1.
Definition Cartesian3DPoint.hpp:93
Cartesian3DPoint SphericalToCartesian3D(const Point &sphericalPoint)
Transforms 2D point in spherical coordinates to 3D cartesian coordinates.
Point Cartesian3DToSpherical(const Cartesian3DPoint &cartesianPoint, double referenceLongitude)
Transforms 3D cartesian coordinates to 2D point in spherical coordinates.
std::tuple< double, double, double > ComputeSphericalCoordinatesFromLatitudeAndLongitude(const Point &point)
Converts geographic coordinates (latitude and longitude) to 3D spherical Cartesian coordinates.
Cartesian3DPoint operator-(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Subtract Cartesian point p2 from p1.
Definition Cartesian3DPoint.hpp:98
Cartesian3DPoint operator/(const Cartesian3DPoint &p, const double value)
Divide Cartesian point p by a scalar value.
Definition Cartesian3DPoint.hpp:103
double InnerProduct(const Cartesian3DPoint &a, const Cartesian3DPoint &b)
Defines inner product in cartesian 3D-space.
Definition Cartesian3DPoint.hpp:118
Cartesian3DPoint operator*(const Cartesian3DPoint &p, const double value)
Multiply Cartesian point p by a scalar value.
Definition Cartesian3DPoint.hpp:113
A struct describing the three coordinates in a cartesian projection.
Definition Cartesian3DPoint.hpp:39
double y
Y-coordinate.
Definition Cartesian3DPoint.hpp:41
double z
Z-coordinate.
Definition Cartesian3DPoint.hpp:42
double x
X-coordinate.
Definition Cartesian3DPoint.hpp:40