32#include "MeshKernel/Constants.hpp"
33#include "MeshKernel/Utilities/NumericFunctions.hpp"
34#include "MeshKernel/Vector.hpp"
48 :
x(constants::missing::doubleValue),
49 y(constants::missing::doubleValue)
113 static double constexpr m_trans_factor =
114 constants::conversion::degToRad *
115 constants::geometric::earth_radius;
117 x =
x * m_trans_factor * std::cos(constants::conversion::degToRad * referenceLatitude);
118 y =
y * m_trans_factor;
122 [[nodiscard]]
bool IsValid(
const double missingValue = constants::missing::doubleValue)
const
124 bool isInvalid = (
x == missingValue ||
y == missingValue);
138 double dot(
const Point& p1,
const Point& p2);
143 double dot(
const Point& p,
const Vector& v);
148 double dot(
const Vector& v,
const Point& p);
153 double cross(
const Point& p1,
const Point& p2);
163 Point
operator+(
const Point& p1,
const Point& p2);
168 Point
operator+(
const Point& pnt,
const Vector& vec);
173 Point
operator+(
const Point& p,
const double x);
178 Point
operator+(
const double x,
const Point& p);
183 Point
operator-(
const Point& p1,
const Point& p2);
188 Point
operator-(
const Point& pnt,
const Vector& vec);
193 Point
operator-(
const Point& p,
const double x);
198 Point
operator-(
const double x,
const Point& p);
204 Point
operator*(
const Point& p1,
const Point& p2);
208 Point
operator*(
const double x,
const Point& p);
212 Point
operator*(
const Point& p,
const double x);
219 Point
operator/(
const Point& p1,
const Point& p2);
224 Point
operator/(
const Point& p,
const double x);
228 bool operator==(
const Point& p1,
const Point& p2);
232 bool operator!=(
const Point& p1,
const Point& p2);
239 bool IsEqual(
const Point& p1,
const Point& p2,
const double epsilon);
244 Point
PointAlongLine(
const Point& startPoint,
const Point& endPoint,
const double lambda);
251 static Point Rotate(
const Point& point,
const double angle,
const Point& reference)
253 const auto translatedPoint = point - reference;
255 const auto angleInRad = angle * constants::conversion::degToRad;
256 const auto cosineAngle = std::cos(angleInRad);
257 const auto sinAngle = std::sin(angleInRad);
258 Point result(translatedPoint.x * cosineAngle - translatedPoint.y * sinAngle,
259 translatedPoint.x * sinAngle + translatedPoint.y * cosineAngle);
261 return result + reference;
277 x = constants::missing::doubleValue;
278 y = constants::missing::doubleValue;
353 return p.
x * p.
x + p.
y * p.
y;
358 return p1.
x * p2.
x + p1.
y * p2.
y;
363 return p.
x * v.
x() + p.
y * v.
y();
373 return p1.
x * p2.
y - p1.
y * p2.
x;
388 return Point(pnt.
x + vec.
x(), pnt.
y + vec.
y());
393 return Point(p.
x + x, p.
y + x);
398 return Point(p.
x + x, p.
y + x);
408 return Point(pnt.
x - vec.
x(), pnt.
y - vec.
y());
413 return Point(p.
x - x, p.
y - x);
418 return Point(x - p.
x, x - p.
y);
428 return Point(x * p.
x, x * p.
y);
433 return Point(x * p.
x, x * p.
y);
443 return Point(p.
x / x, p.
y / x);
478 return (1.0 - lambda) * startPoint + lambda * endPoint;
A struct describing a point in a two-dimensional space.
Definition Point.hpp:41
Point()
Constructor initializing with missing values.
Definition Point.hpp:47
void SetInvalid()
Set the point to be invalid.
Definition Point.hpp:275
Point & operator+=(const Point &p)
Inplace add point to point.
Definition Point.hpp:281
Point & operator*=(const Point &p)
Inplace multiply point by point.
Definition Point.hpp:316
bool IsValid(const double missingValue=constants::missing::doubleValue) const
Determines if one of the point coordinates equals to missingValue.
Definition Point.hpp:122
Point & operator/=(const Point &p)
Inplace divide point by point.
Definition Point.hpp:309
Point & operator-=(const Point &p)
Inplace subtract point from point.
Definition Point.hpp:288
void TransformSphericalToCartesian(double referenceLatitude)
Transforms spherical coordinates to cartesian.
Definition Point.hpp:111
Point operator*(int const &rhs) const
Overloads multiplication with a integer.
Definition Point.hpp:102
double x
X-coordinate.
Definition Point.hpp:43
double y
Y-coordinate.
Definition Point.hpp:44
Point(double x, double y)
Constructor initializing with given coordinates.
Definition Point.hpp:56
A class defining a vector.
Definition Vector.hpp:39
double y() const
Gets the y coordinate of the vector.
Definition Vector.hpp:66
double x() const
Gets the x coordinate of the vector.
Definition Vector.hpp:52
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
bool operator!=(const Point &p1, const Point &p2)
Test points for equality using a default tolerance.
Definition Point.hpp:451
double cross(const Point &p1, const Point &p2)
Compute the cross product of two points (as vectors).
Definition Point.hpp:371
bool operator==(const Point &p1, const Point &p2)
Test points for equality using a default tolerance.
Definition Point.hpp:446
bool IsEqual(const Point &p1, const Point &p2, const double epsilon)
Test points for equality upto a tolerance.
Definition Point.hpp:456
double GetDeltaXCartesian(const Point &p1, const Point &p2)
Get the delta-x in Cartesian coordinate system.
Definition Point.hpp:461
double dot(const Point &p1, const Point &p2)
Compute the dot product of two points.
Definition Point.hpp:356
Cartesian3DPoint operator+(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Add Cartesian point p2 to p1.
Definition Cartesian3DPoint.hpp:93
Point PointAlongLine(const Point &startPoint, const Point &endPoint, const double lambda)
Compute the point at some position along the line connecting start- and end-point.
Definition Point.hpp:476
double lengthSquared(const Point &p1)
Compute the dot product of a point with itself.
Definition Point.hpp:351
Vector GetDeltaCartesian(const Point &p1, const Point &p2)
Get the delta-x and -y in Cartesian coordinate system.
Definition Point.hpp:471
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 GetDeltaYCartesian(const Point &p1, const Point &p2)
Get the delta-y in Cartesian coordinate system.
Definition Point.hpp:466
Cartesian3DPoint operator*(const Cartesian3DPoint &p, const double value)
Multiply Cartesian point p by a scalar value.
Definition Cartesian3DPoint.hpp:113