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 =
IsEqual(
x, missingValue) ||
133 double dot(
const Point& p1,
const Point& p2);
138 double dot(
const Point& p,
const Vector& v);
143 double dot(
const Vector& v,
const Point& p);
148 double cross(
const Point& p1,
const Point& p2);
158 Point
operator+(
const Point& p1,
const Point& p2);
163 Point
operator+(
const Point& pnt,
const Vector& vec);
168 Point
operator+(
const Point& p,
const double x);
173 Point
operator+(
const double x,
const Point& p);
178 Point
operator-(
const Point& p1,
const Point& p2);
183 Point
operator-(
const Point& pnt,
const Vector& vec);
188 Point
operator-(
const Point& p,
const double x);
193 Point
operator-(
const double x,
const Point& p);
199 Point
operator*(
const Point& p1,
const Point& p2);
203 Point
operator*(
const double x,
const Point& p);
207 Point
operator*(
const Point& p,
const double x);
214 Point
operator/(
const Point& p1,
const Point& p2);
219 Point
operator/(
const Point& p,
const double x);
223 bool operator==(
const Point& p1,
const Point& p2);
227 bool operator!=(
const Point& p1,
const Point& p2);
234 bool IsEqual(
const Point& p1,
const Point& p2,
const double epsilon);
239 Point
PointAlongLine(
const Point& startPoint,
const Point& endPoint,
const double lambda);
246 static Point Rotate(
const Point& point,
const double angle,
const Point& reference)
248 const auto translatedPoint = point - reference;
250 const auto angleInRad = angle * constants::conversion::degToRad;
251 const auto cosineAngle = std::cos(angleInRad);
252 const auto sinAngle = std::sin(angleInRad);
253 Point result(translatedPoint.x * cosineAngle - translatedPoint.y * sinAngle,
254 translatedPoint.x * sinAngle + translatedPoint.y * cosineAngle);
256 return result + reference;
272 x = constants::missing::doubleValue;
273 y = constants::missing::doubleValue;
348 return p.
x * p.
x + p.
y * p.
y;
353 return p1.
x * p2.
x + p1.
y * p2.
y;
358 return p.
x * v.
x() + p.
y * v.
y();
368 return p1.
x * p2.
y - p1.
y * p2.
x;
383 return Point(pnt.
x + vec.
x(), pnt.
y + vec.
y());
388 return Point(p.
x + x, p.
y + x);
393 return Point(p.
x + x, p.
y + x);
403 return Point(pnt.
x - vec.
x(), pnt.
y - vec.
y());
408 return Point(p.
x - x, p.
y - x);
413 return Point(x - p.
x, x - p.
y);
423 return Point(x * p.
x, x * p.
y);
428 return Point(x * p.
x, x * p.
y);
438 return Point(p.
x / x, p.
y / x);
473 return (1.0 - lambda) * startPoint + lambda * endPoint;
Point & operator+=(const Point &p)
Inplace add point to point.
Definition: Point.hpp:276
bool operator!=(const Point &p1, const Point &p2)
Test points for equality using a default tolerance.
Definition: Point.hpp:446
Point & operator/=(const Point &p)
Inplace divide point by point.
Definition: Point.hpp:304
bool IsEqual(const Point &p1, const Point &p2, const double epsilon)
Test points for equality upto a tolerance.
Definition: Point.hpp:451
Cartesian3DPoint operator/(const Cartesian3DPoint &p, const double value)
Divide Cartesian point p by a scalar value.
Definition: Operations.hpp:634
Point()
Constructor initializing with missing values.
Definition: Point.hpp:47
Point operator*(int const &rhs) const
Overloads multiplication with a integer.
Definition: Point.hpp:102
A struct describing a point in a two-dimensional space.
Definition: Point.hpp:40
bool operator==(const Point &p1, const Point &p2)
Test points for equality using a default tolerance.
Definition: Point.hpp:441
double x
X-coordinate.
Definition: Point.hpp:43
A class defining a vector.
Definition: Vector.hpp:38
Cartesian3DPoint operator-(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Subtract Cartesian point p2 from p1.
Definition: Operations.hpp:629
Cartesian3DPoint operator*(const Cartesian3DPoint &p, const double value)
Multiply Cartesian point p by a scalar value.
Definition: Operations.hpp:644
double y
Y-coordinate.
Definition: Point.hpp:44
double GetDeltaXCartesian(const Point &p1, const Point &p2)
Get the delta-x in Cartesian coordinate system.
Definition: Point.hpp:456
double GetDeltaYCartesian(const Point &p1, const Point &p2)
Get the delta-y in Cartesian coordinate system.
Definition: Point.hpp:461
double cross(const Point &p1, const Point &p2)
Compute the cross product of two points (as vectors).
Definition: Point.hpp:366
Contains the logic of the C++ static library.
Definition: AveragingInterpolation.hpp:36
void TransformSphericalToCartesian(double referenceLatitude)
Transforms spherical coordinates to cartesian.
Definition: Point.hpp:105
bool IsValid(const double missingValue=constants::missing::doubleValue) const
Determines if one of the point coordinates equals to missingValue.
Definition: Point.hpp:116
double y() const
Gets the y coordinate of the vector.
Definition: Vector.hpp:66
Cartesian3DPoint operator+(const Cartesian3DPoint &p1, const Cartesian3DPoint &p2)
Add Cartesian point p2 to p1.
Definition: Operations.hpp:624
double lengthSquared(const Point &p1)
Compute the dot product of a point with itself.
Definition: Point.hpp:346
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:471
Point & operator*=(const Point &p)
Inplace multiply point by point.
Definition: Point.hpp:311
Point(double x, double y)
Constructor initializing with given coordinates.
Definition: Point.hpp:56
double x() const
Gets the x coordinate of the vector.
Definition: Vector.hpp:52
double dot(const Point &p1, const Point &p2)
Compute the dot product of two points.
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:466
Point & operator-=(const Point &p)
Inplace subtract point from point.
Definition: Point.hpp:283
void SetInvalid()
Set the point to be invalid.
Definition: Point.hpp:270