Loading...
Searching...
No Matches
meshkit::Point2 Class Reference

Point or displacement vector in the horizontal (XY) plane. More...

#include <meshkit/geometry.hpp>

Collaboration diagram for meshkit::Point2:

Public Member Functions

constexpr Point2 ()=default
 Construct the origin (0, 0).
 
constexpr Point2 (double x, double y)
 Construct a point from its coordinates.
 
constexpr double x () const noexcept
 X coordinate in XY plane units.
 
constexpr double y () const noexcept
 Y coordinate in XY plane units.
 
double * data () noexcept
 Pointer to the two contiguous coordinates {x, y}.
 
const double * data () const noexcept
 Read-only pointer to the two contiguous coordinates {x, y}.
 
constexpr bool isNull () const
 True when both coordinates compare equal to 0 (-0.0 counts, NaN does not).
 
Point2 & operator*= (double s)
 Multiply both coordinates by s in place.
 
Point2 & operator/= (double s)
 Divide both coordinates by s in place.
 
Point2 & operator+= (Point2 p)
 Add p component-wise in place.
 
Point2 & operator-= (Point2 p)
 Subtract p component-wise in place.
 

Static Public Member Functions

static constexpr double dotProduct (Point2 a, Point2 b)
 Dot product a.x * b.x + a.y * b.y.
 

Friends

constexpr Point2 operator+ (Point2 a, Point2 b)
 Component-wise sum.
 
constexpr Point2 operator- (Point2 a, Point2 b)
 Component-wise difference, the displacement from b to a.
 
constexpr Point2 operator* (Point2 a, double s)
 Scale a point by a factor.
 
constexpr Point2 operator* (double s, Point2 a)
 Scale a point by a factor, factor first; same result as a * s.
 
constexpr Point2 operator/ (Point2 a, double s)
 Divide a point by a divisor.
 
constexpr bool operator== (Point2 a, Point2 b)
 Exact component-wise equality, with no tolerance.
 
constexpr bool operator!= (Point2 a, Point2 b)
 Negation of operator==.
 

Detailed Description

Point or displacement vector in the horizontal (XY) plane.

Coordinates are doubles in the caller's XY plane units; no CRS or unit conversion is applied and no finiteness checks are made, so arithmetic follows plain IEEE rules. The type is a standard-layout pair of doubles {x, y} (checked by a static_assert at the end of this header), so a contiguous array of Point2 can be read as interleaved x, y values; the Python bindings expose point arrays that way. It is the point type of detail::StandardStorage, standing in for QPointF.

Constructor & Destructor Documentation

◆ Point2() [1/2]

meshkit::Point2::Point2 ( )
constexprdefault

Construct the origin (0, 0).

Here is the caller graph for this function:

◆ Point2() [2/2]

meshkit::Point2::Point2 ( double x,
double y )
inlineconstexpr

Construct a point from its coordinates.

Parameters
[in]xX coordinate in XY plane units.
[in]yY coordinate in XY plane units.
Here is the call graph for this function:

Member Function Documentation

◆ data() [1/2]

const double * meshkit::Point2::data ( ) const
inlinenoexcept

Read-only pointer to the two contiguous coordinates {x, y}.

Returns
Pointer into this object, valid while this Point2 lives.

◆ data() [2/2]

double * meshkit::Point2::data ( )
inlinenoexcept

Pointer to the two contiguous coordinates {x, y}.

Returns
Pointer into this object; writing through it changes the point. Valid while this Point2 lives.

◆ dotProduct()

static constexpr double meshkit::Point2::dotProduct ( Point2 a,
Point2 b )
inlinestaticconstexpr

Dot product a.x * b.x + a.y * b.y.

Parameters
[in]aFirst vector.
[in]bSecond vector.
Returns
Dot product, in squared XY plane units for two displacement vectors.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNull()

bool meshkit::Point2::isNull ( ) const
inlineconstexpr

True when both coordinates compare equal to 0 (-0.0 counts, NaN does not).

Here is the call graph for this function:

◆ operator*=()

Point2 & meshkit::Point2::operator*= ( double s)
inline

Multiply both coordinates by s in place.

Parameters
[in]sScale factor.
Returns
Reference to this point.
Here is the call graph for this function:

◆ operator+=()

Point2 & meshkit::Point2::operator+= ( Point2 p)
inline

Add p component-wise in place.

Parameters
[in]pDisplacement to add.
Returns
Reference to this point.
Here is the call graph for this function:

◆ operator-=()

Point2 & meshkit::Point2::operator-= ( Point2 p)
inline

Subtract p component-wise in place.

Parameters
[in]pDisplacement to subtract.
Returns
Reference to this point.
Here is the call graph for this function:

◆ operator/=()

Point2 & meshkit::Point2::operator/= ( double s)
inline

Divide both coordinates by s in place.

Parameters
[in]sDivisor; 0 gives IEEE infinities or NaN, not an error.
Returns
Reference to this point.
Here is the call graph for this function:

◆ x()

double meshkit::Point2::x ( ) const
inlineconstexprnoexcept

X coordinate in XY plane units.

Here is the caller graph for this function:

◆ y()

double meshkit::Point2::y ( ) const
inlineconstexprnoexcept

Y coordinate in XY plane units.

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( Point2 a,
Point2 b )
friend

Negation of operator==.

Parameters
[in]aFirst point.
[in]bSecond point.
Returns
True when either coordinate differs or is NaN.

◆ operator* [1/2]

Point2 operator* ( double s,
Point2 a )
friend

Scale a point by a factor, factor first; same result as a * s.

Parameters
[in]sScale factor.
[in]aPoint or vector to scale.
Returns
(a.x * s, a.y * s).

◆ operator* [2/2]

Point2 operator* ( Point2 a,
double s )
friend

Scale a point by a factor.

Parameters
[in]aPoint or vector to scale.
[in]sScale factor.
Returns
(a.x * s, a.y * s).

◆ operator+

Point2 operator+ ( Point2 a,
Point2 b )
friend

Component-wise sum.

Parameters
[in]aFirst operand.
[in]bSecond operand.
Returns
(a.x + b.x, a.y + b.y).

◆ operator-

Point2 operator- ( Point2 a,
Point2 b )
friend

Component-wise difference, the displacement from b to a.

Parameters
[in]aMinuend.
[in]bSubtrahend.
Returns
(a.x - b.x, a.y - b.y).

◆ operator/

Point2 operator/ ( Point2 a,
double s )
friend

Divide a point by a divisor.

Parameters
[in]aPoint or vector to divide.
[in]sDivisor; 0 gives IEEE infinities or NaN, not an error.
Returns
(a.x / s, a.y / s).

◆ operator==

bool operator== ( Point2 a,
Point2 b )
friend

Exact component-wise equality, with no tolerance.

Parameters
[in]aFirst point.
[in]bSecond point.
Returns
True when both coordinates compare equal; +0.0 equals -0.0 and a NaN coordinate is never equal.

The documentation for this class was generated from the following file: