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)
107 static double constexpr m_trans_factor =
108 constants::conversion::degToRad *
109 constants::geometric::earth_radius;
111 x =
x * m_trans_factor * std::cos(constants::conversion::degToRad * referenceLatitude);
112 y =
y * m_trans_factor;
116 [[nodiscard]]
bool IsValid(
const double missingValue = constants::missing::doubleValue)
const
118 bool isInvalid = (
x == missingValue ||
y == missingValue);
116 [[nodiscard]]
bool IsValid(
const double missingValue = constants::missing::doubleValue)
const {
…}
132 double dot(
const Point& p1,
const Point& p2);
137 double dot(
const Point& p,
const Vector& v);
142 double dot(
const Vector& v,
const Point& p);
147 double cross(
const Point& p1,
const Point& p2);
157 Point
operator+(
const Point& p1,
const Point& p2);
162 Point
operator+(
const Point& pnt,
const Vector& vec);
167 Point
operator+(
const Point& p,
const double x);
172 Point
operator+(
const double x,
const Point& p);
177 Point
operator-(
const Point& p1,
const Point& p2);
182 Point
operator-(
const Point& pnt,
const Vector& vec);
187 Point
operator-(
const Point& p,
const double x);
192 Point
operator-(
const double x,
const Point& p);
198 Point
operator*(
const Point& p1,
const Point& p2);
202 Point
operator*(
const double x,
const Point& p);
206 Point
operator*(
const Point& p,
const double x);
213 Point
operator/(
const Point& p1,
const Point& p2);
218 Point
operator/(
const Point& p,
const double x);
222 bool operator==(
const Point& p1,
const Point& p2);
226 bool operator!=(
const Point& p1,
const Point& p2);
233 bool IsEqual(
const Point& p1,
const Point& p2,
const double epsilon);
238 Point
PointAlongLine(
const Point& startPoint,
const Point& endPoint,
const double lambda);
245 static Point Rotate(
const Point& point,
const double angle,
const Point& reference)
247 const auto translatedPoint = point - reference;
249 const auto angleInRad = angle * constants::conversion::degToRad;
250 const auto cosineAngle = std::cos(angleInRad);
251 const auto sinAngle = std::sin(angleInRad);
252 Point result(translatedPoint.x * cosineAngle - translatedPoint.y * sinAngle,
253 translatedPoint.x * sinAngle + translatedPoint.y * cosineAngle);
255 return result + reference;
271 x = constants::missing::doubleValue;
272 y = constants::missing::doubleValue;
347 return p.
x * p.
x + p.
y * p.
y;
352 return p1.
x * p2.
x + p1.
y * p2.
y;
357 return p.
x * v.
x() + p.
y * v.
y();
367 return p1.
x * p2.
y - p1.
y * p2.
x;
382 return Point(pnt.
x + vec.
x(), pnt.
y + vec.
y());
387 return Point(p.
x + x, p.
y + x);
392 return Point(p.
x + x, p.
y + x);
402 return Point(pnt.
x - vec.
x(), pnt.
y - vec.
y());
407 return Point(p.
x - x, p.
y - x);
412 return Point(x - p.
x, x - p.
y);
422 return Point(x * p.
x, x * p.
y);
427 return Point(x * p.
x, x * p.
y);
437 return Point(p.
x / x, p.
y / x);
472 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:269
Point & operator+=(const Point &p)
Inplace add point to point.
Definition Point.hpp:275
Point & operator*=(const Point &p)
Inplace multiply point by point.
Definition Point.hpp:310
bool IsValid(const double missingValue=constants::missing::doubleValue) const
Determines if one of the point coordinates equals to missingValue.
Definition Point.hpp:116
Point & operator/=(const Point &p)
Inplace divide point by point.
Definition Point.hpp:303
Point & operator-=(const Point &p)
Inplace subtract point from point.
Definition Point.hpp:282
void TransformSphericalToCartesian(double referenceLatitude)
Transforms spherical coordinates to cartesian.
Definition Point.hpp:105
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:445
double cross(const Point &p1, const Point &p2)
Compute the cross product of two points (as vectors).
Definition Point.hpp:365
bool operator==(const Point &p1, const Point &p2)
Test points for equality using a default tolerance.
Definition Point.hpp:440
bool IsEqual(const Point &p1, const Point &p2, const double epsilon)
Test points for equality upto a tolerance.
Definition Point.hpp:450
double GetDeltaXCartesian(const Point &p1, const Point &p2)
Get the delta-x in Cartesian coordinate system.
Definition Point.hpp:455
double dot(const Point &p1, const Point &p2)
Compute the dot product of two points.
Definition Point.hpp:350
Cartesian3DPoint operator+(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Add Cartesian point p2 to p1.
Definition Cartesian3DPoint.hpp:83
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:470
double lengthSquared(const Point &p1)
Compute the dot product of a point with itself.
Definition Point.hpp:345
Vector GetDeltaCartesian(const Point &p1, const Point &p2)
Get the delta-x and -y in Cartesian coordinate system.
Definition Point.hpp:465
Cartesian3DPoint operator-(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Subtract Cartesian point p2 from p1.
Definition Cartesian3DPoint.hpp:88
Cartesian3DPoint operator/(const Cartesian3DPoint &p, const double value)
Divide Cartesian point p by a scalar value.
Definition Cartesian3DPoint.hpp:93
double GetDeltaYCartesian(const Point &p1, const Point &p2)
Get the delta-y in Cartesian coordinate system.
Definition Point.hpp:460
Cartesian3DPoint operator*(const Cartesian3DPoint &p, const double value)
Multiply Cartesian point p by a scalar value.
Definition Cartesian3DPoint.hpp:103