← comparison
tgen
Loading...
Searching...
No Matches

Point on the plane. More...

Public Member Functions

 point (T x=0, T y=0)
 Constructs a point.
x () const
 x coordinate.
y () const
 y coordinate.
bool operator< (const point &p) const
 Lexicographic order.
bool operator== (const point &p) const
 Coordinate-wise equality.
point operator+ (const point &p) const
 Vector addition.
point operator- (const point &p) const
 Vector subtraction.
point operator* (T c) const
 Scalar multiplication.
product_t operator* (const point &p) const
 Dot product.
product_t operator^ (const point &p) const
 Cross product.

Friends

std::ostream & operator<< (std::ostream &out, const point &p)
 Prints the coordinates separated by a space.

Detailed Description

template<typename T>
struct tgen::geometry::point< T >

Point on the plane.

Template Parameters
TArithmetic coordinate type (int, double, ...).

Dot and cross products return product_t, widened to avoid overflow: __int128 when T is long long, long long for other integral T, and T for floating-point T.

For floating-point T, operator== and lexicographic operator< compare coordinates with tolerance 1e-9.

Definition at line 6393 of file tgen.h.

Constructor & Destructor Documentation

◆ point()

template<typename T>
tgen::geometry::point< T >::point ( T x = 0,
T y = 0 )
inline

Constructs a point.

Parameters
xx-coordinate.
yy-coordinate.

Definition at line 6407 of file tgen.h.

Member Function Documentation

◆ operator*() [1/2]

template<typename T>
product_t tgen::geometry::point< T >::operator* ( const point< T > & p) const
inline

Dot product.

Returns
The dot product as product_t (__int128 for point<long long>, long long for other integral T, T for floating-point).

Definition at line 6451 of file tgen.h.

◆ operator*() [2/2]

template<typename T>
point tgen::geometry::point< T >::operator* ( T c) const
inline

Scalar multiplication.

Parameters
cScalar.

Definition at line 6448 of file tgen.h.

◆ operator+()

template<typename T>
point tgen::geometry::point< T >::operator+ ( const point< T > & p) const
inline

Vector addition.

Returns
The sum of the vectors.

Examples

tgen::geometry::point<int> a(1, 2), b(3, 4);
std::cout << a + b << std::endl;
Point on the plane.
Definition tgen.h:6393

Definition at line 6438 of file tgen.h.

◆ operator-()

template<typename T>
point tgen::geometry::point< T >::operator- ( const point< T > & p) const
inline

Vector subtraction.

Returns
The subtraction of the vectors.

Examples

tgen::geometry::point<int> a(1, 2), b(3, 4);
std::cout << a - b << std::endl;

Definition at line 6443 of file tgen.h.

◆ operator<()

template<typename T>
bool tgen::geometry::point< T >::operator< ( const point< T > & p) const
inline

Lexicographic order.

For floating-point coordinates, x_ values within 1e-9 are treated as equal before comparing y_.

Definition at line 6426 of file tgen.h.

◆ operator==()

template<typename T>
bool tgen::geometry::point< T >::operator== ( const point< T > & p) const
inline

Coordinate-wise equality.

For floating-point coordinates, two values are equal when their difference is at most 1e-9 in absolute value.

Definition at line 6433 of file tgen.h.

◆ operator^()

template<typename T>
product_t tgen::geometry::point< T >::operator^ ( const point< T > & p) const
inline

Cross product.

Returns
The signed magnitude of the cross product as product_t (__int128 for point<long long>, long long for other integral T, T for floating-point).

Definition at line 6458 of file tgen.h.

◆ x()

template<typename T>
T tgen::geometry::point< T >::x ( ) const
inline

x coordinate.

Examples

std::cout << p.x() << std::endl; // Prints "3".

Definition at line 6410 of file tgen.h.

◆ y()

template<typename T>
T tgen::geometry::point< T >::y ( ) const
inline

y coordinate.

Examples

std::cout << p.y() << std::endl; // Prints "4".

Definition at line 6413 of file tgen.h.

◆ operator<<

template<typename T>
std::ostream & operator<< ( std::ostream & out,
const point< T > & p )
friend

Prints the coordinates separated by a space.

Examples

std::cout << p << std::endl; // Prints "3 4".

Definition at line 6465 of file tgen.h.


The documentation for this struct was generated from the following files:
  • /home/runner/work/tgen_vs_jngen/tgen_vs_jngen/vendor/tgen/single_include/tgen.h
  • geometry.dox