DxLibEx
dxle::point3d_c< T, > Class Template Referencefinal

Template class for 3D points specified by its coordinates x and y. More...

#include <point3d.hpp>

Public Types

typedef T value_type
 

Public Member Functions

DXLE_CONSTEXPR point3d_c () DXLE_NOEXCEPT_IF(std
 
DXLE_CONSTEXPR point3d_c (const value_type &x_, const value_type &y_, const value_type &z_) DXLE_NOEXCEPT_IF((std
 
DXLE_CONSTEXPR point3d_c (value_type &&x_, value_type &&y_, value_type &&z_) DXLE_NOEXCEPT_OR_NOTHROW
 
DXLE_CONSTEXPR point3d_c (const point3d_c< value_type > &o) DXLE_NOEXCEPT_IF((std
 
DXLE_CONSTEXPR point3d_c (point3d_c< value_type > &&o) DXLE_NOEXCEPT_OR_NOTHROW
 
point3d_coperator= (const point3d_c< value_type > &r) DXLE_NOEXCEPT_IF((std
 
point3d_coperator= (point3d_c< value_type > &&r) DXLE_NOEXCEPT_OR_NOTHROW
 
DXLE_CONSTEXPR operator bool () const DXLE_NOEXCEPT_IF_EXPR((dxle
 
template<typename Tp2_ >
DXLE_CONSTEXPR operator point3d_c< Tp2_ > () const DXLE_NOEXCEPT_OR_NOTHROW
 
template<typename Tp2_ >
 operator std::tuple< Tp2_, Tp2_, Tp2_ > () const DXLE_NOEXCEPT_IF_EXPR(static_cast< Tp2_ >(std
 

Public Attributes

value_type x
 
value_type y
 
value_type z
 

Related Functions

(Note that these are not member functions.)

template<typename T >
point3d_c< T > make_point3d_c (const std::tuple< T, T, T > &p) DXLE_NOEXCEPT_IF(std
 conversion from std::tuple More...
 
template<typename T >
point3d_c< T > make_point3d_c (std::tuple< T, T, T > &&p) DXLE_NOEXCEPT_OR_NOTHROW
 conversion from std::tuple More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const point3d_c< T > &p)
 ostream operator More...
 
template<typename T >
std::wostream & operator<< (std::wostream &os, const point3d_c< T > &p)
 ostream operator More...
 
template<typename T >
std::istream & operator>> (std::istream &is, point3d_c< T > &p)
 istream operator More...
 
template<typename T >
std::wistream & operator>> (std::wistream &is, point3d_c< T > &p)
 istream operator More...
 
template<typename T >
DXLE_CONSTEXPR point3d_c< T > operator- (const point3d_c< T > &r) DXLE_NOEXCEPT_IF_EXPR(-std
 Overload of unary operator -. More...
 
template<typename T >
DXLE_CONSTEXPR const point3d_c< T > & operator+ (const point3d_c< T > &r) DXLE_NOEXCEPT_IF(std
 Overload of unary operator +. More...
 
template<typename T >
DXLE_CONSTEXPR point3d_c< T > && operator+ (point3d_c< T > &&r) DXLE_NOEXCEPT_OR_NOTHROW
 Overload of unary operator +. More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point3d_c< T1 > & operator+= (point3d_c< T1 > &l, const point3d_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x+
 Overload of binary operator +=. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator- (const point3d_c< T1 > &l, const point3d_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x - r.x) -> point3d_c< decltype(std::declval< std::remove_cv_t< T1 >>() - std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator -. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* (const point3d_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x *r) -> point3d_c< decltype(std::declval< std::remove_cv_t< T1 >>() *std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator *. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* (T1 l, const point3d_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l+r.x) -> point3d_c< decltype(std::declval< std::remove_cv_t< T1 >>() *std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator *. More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point3d_c< T1 > & operator*= (point3d_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x *
 Overload of binary operator *=. More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point3d_c< T1 > & operator/= (point3d_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x/
 Overload of binary operator /=. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto cross (const point3d_c< T1 > &p1, const point3d_c< T2 > &p2) DXLE_NOEXCEPT_IF_EXPR(std
 Computes a cross-product of two point3d_c value as vectors. More...
 
template<typename T1 , typename T2 >
distance_result_type_t< T1, T2distance (const point3d_c< T1 > &p1, const point3d_c< T2 > &p2) DXLE_NOEXCEPT_IF_EXPR(hypot(safe_dist(std
 Calculate the distance of the two point3d_c class object based on the Pythagorean theorem(std::hypot) More...
 

Detailed Description

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
class dxle::point3d_c< T, >

Template class for 3D points specified by its coordinates x and y.

An instance of the claess is interchangeable with std::tuple. There is also a cast operator to convert point3d coordinates to the specified type (using static_cast). Commonly, the conversion uses this operation for each of the coordinates. Besides the class members listed in the declaration above, the following operations on points are implemented:

pt1 = pt2 + pt3;
pt1 = pt2 - pt3;
pt1 = pt2 * a;
pt1 = a * pt2;
pt1 = pt2 / a;
pt1 += pt2;
pt1 -= pt2;
pt1 *= a;
pt1 /= a;
pt1 == pt2;
pt1 != pt2;

For your convenience, the following type aliases are defined:

typedef point3d_c<int> point3di;
typedef point3d_c<std::uint8_t> point3du8i;
typedef point3d_c<std::int8_t> point3d8i;
typedef point3d_c<double> point3dd;
typedef point3d_c<float> point3df;

Example:

dxle::point3df a(0.3f, 0.f), b(0.f, 0.4f);
dxle::point3di pt = (a + b)*10.f;
std::cout << pt << std::endl;
Template Parameters
TT is the type of the elements. T must meet the requirements of NothrowMoveAssignable and NothrowConstructable. T is expected the following conditions to use all features.

Definition at line 98 of file point3d.hpp.

Member Typedef Documentation

§ value_type

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
typedef T dxle::point3d_c< T, >::value_type

Definition at line 101 of file point3d.hpp.

Constructor & Destructor Documentation

§ point3d_c() [1/5]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point3d_c< T, >::point3d_c ( )
inline

Definition at line 103 of file point3d.hpp.

§ point3d_c() [2/5]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point3d_c< T, >::point3d_c ( const value_type x_,
const value_type y_,
const value_type z_ 
)
inline

Definition at line 104 of file point3d.hpp.

§ point3d_c() [3/5]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point3d_c< T, >::point3d_c ( value_type &&  x_,
value_type &&  y_,
value_type &&  z_ 
)
inline

Definition at line 105 of file point3d.hpp.

§ point3d_c() [4/5]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point3d_c< T, >::point3d_c ( const point3d_c< value_type > &  o)
inline

Definition at line 108 of file point3d.hpp.

§ point3d_c() [5/5]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point3d_c< T, >::point3d_c ( point3d_c< value_type > &&  o)
inline

Definition at line 110 of file point3d.hpp.

Member Function Documentation

§ operator bool()

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point3d_c< T, >::operator bool ( ) const
inlineexplicit

operator bool

  1. operator bool
  2. operator != (nullptr)
  3. default constector + operator !=

Definition at line 131 of file point3d.hpp.

§ operator point3d_c< Tp2_ >()

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
DXLE_CONSTEXPR dxle::point3d_c< T, >::operator point3d_c< Tp2_ > ( ) const
inlineexplicit

conversion to another data type

Definition at line 138 of file point3d.hpp.

§ operator std::tuple< Tp2_, Tp2_, Tp2_ >()

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
dxle::point3d_c< T, >::operator std::tuple< Tp2_, Tp2_, Tp2_ > ( ) const
inlineexplicit

conversion to std::tuple

Definition at line 144 of file point3d.hpp.

§ operator=() [1/2]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
point3d_c& dxle::point3d_c< T, >::operator= ( const point3d_c< value_type > &  r)
inline

Definition at line 112 of file point3d.hpp.

§ operator=() [2/2]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
point3d_c& dxle::point3d_c< T, >::operator= ( point3d_c< value_type > &&  r)
inline

Definition at line 120 of file point3d.hpp.

Friends And Related Function Documentation

§ cross()

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto cross ( const point3d_c< T1 > &  p1,
const point3d_c< T2 > &  p2 
)
related

Computes a cross-product of two point3d_c value as vectors.

Parameters
p1point3d_c value
p2point3d_c value
Returns
Computed result.

Definition at line 625 of file point3d.hpp.

§ distance()

template<typename T1 , typename T2 >
distance_result_type_t< T1, T2 > distance ( const point3d_c< T1 > &  p1,
const point3d_c< T2 > &  p2 
)
related

Calculate the distance of the two point3d_c class object based on the Pythagorean theorem(std::hypot)

Parameters
p1point3d_c value
p2point3d_c value
Returns
Computed result.

Definition at line 644 of file point3d.hpp.

§ make_point3d_c() [1/2]

template<typename T >
point3d_c< T > make_point3d_c ( const std::tuple< T, T, T > &  p)
related

conversion from std::tuple

Parameters
pconst-lvalue reference to std::tuple
Returns
point3d_c value

Definition at line 160 of file point3d.hpp.

§ make_point3d_c() [2/2]

template<typename T >
point3d_c< T > make_point3d_c ( std::tuple< T, T, T > &&  p)
related

conversion from std::tuple

Parameters
prvalue reference to std::tuple
Returns
point3d_c value

Definition at line 173 of file point3d.hpp.

§ operator*() [1/2]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* ( const point3d_c< T1 > &  l,
T2  r 
) -> point3d_c<decltype(std::declval<std::remove_cv_t<T1>>() * std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator *.

Parameters
lconst-lvalue reference to point3d_c value
rarithmetic value
Returns
Memberwise multiplication by 2nd argument

Definition at line 390 of file point3d.hpp.

§ operator*() [2/2]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* ( T1  l,
const point3d_c< T2 > &  r 
) -> point3d_c<decltype(std::declval<std::remove_cv_t<T1>>() * std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator *.

Parameters
larithmetic value
rconst-lvalue reference to point3d_c value
Returns
Memberwise multiplication by 1st argument

Definition at line 408 of file point3d.hpp.

§ operator*=()

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point3d_c< T1 > & operator*= ( point3d_c< T1 > &  l,
T2  r 
)
related

Overload of binary operator *=.

Parameters
lconst-lvalue reference to point3d_c value
rarithmetic value
Returns
lvalue reference to 1st argument

§ operator+() [1/2]

template<typename T >
DXLE_CONSTEXPR const point3d_c< T > & operator+ ( const point3d_c< T > &  r)
related

Overload of unary operator +.

Parameters
rconst-lvalue reference to point3d_c value
Returns
const-lvalue reference to first argument

Definition at line 288 of file point3d.hpp.

§ operator+() [2/2]

template<typename T >
DXLE_CONSTEXPR point3d_c< T > && operator+ ( point3d_c< T > &&  r)
related

Overload of unary operator +.

Parameters
rrvalue reference to point3d_c value
Returns
rvalue reference to first argument

Definition at line 300 of file point3d.hpp.

§ operator+=()

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point3d_c< T1 > & operator+= ( point3d_c< T1 > &  l,
const point3d_c< T2 > &  r 
)
related

Overload of binary operator +=.

Parameters
llvalue reference to point3d_c value
rconst-lvalue reference to point3d_c value
Returns
lvalue reference to first argument

§ operator-() [1/2]

template<typename T >
DXLE_CONSTEXPR point3d_c< T > operator- ( const point3d_c< T > &  r)
related

Overload of unary operator -.

Parameters
rpoint3d_c value to negate
Returns
Memberwise opposite of the point3d_c value

Definition at line 273 of file point3d.hpp.

§ operator-() [2/2]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator- ( const point3d_c< T1 > &  l,
const point3d_c< T2 > &  r 
) -> point3d_c<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator -.

Parameters
lconst-lvalue reference to point3d_c value
rconst-lvalue reference to point3d_c value
Returns
Memberwise subtraction of both point3d_c value

Definition at line 372 of file point3d.hpp.

§ operator/=()

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point3d_c< T1 > & operator/= ( point3d_c< T1 > &  l,
T2  r 
)
related

Overload of binary operator /=.

Parameters
lconst-lvalue reference to point3d_c value
rarithmetic value
Returns
lvalue reference to 1st argument

§ operator<<() [1/2]

template<typename T >
std::ostream & operator<< ( std::ostream &  os,
const point3d_c< T > &  p 
)
related

ostream operator

Parameters
oslvalue reference to ostream
pconst-lvalue reference to point3d_c
Returns
lvalue reference to ostream whitch is specified at first argument

Definition at line 209 of file point3d.hpp.

§ operator<<() [2/2]

template<typename T >
std::wostream & operator<< ( std::wostream &  os,
const point3d_c< T > &  p 
)
related

ostream operator

Parameters
oslvalue reference to ostream
pconst-lvalue reference to point3d_c
Returns
lvalue reference to ostream whitch is specified at first argument

Definition at line 225 of file point3d.hpp.

§ operator>>() [1/2]

template<typename T >
std::istream & operator>> ( std::istream &  is,
point3d_c< T > &  p 
)
related

istream operator

Parameters
islvalue reference to istream
pconst-lvalue reference to point3d_c
Returns
lvalue reference to istream whitch is specified at first argument

Definition at line 241 of file point3d.hpp.

§ operator>>() [2/2]

template<typename T >
std::wistream & operator>> ( std::wistream &  is,
point3d_c< T > &  p 
)
related

istream operator

Parameters
islvalue reference to istream
pconst-lvalue reference to point3d_c
Returns
lvalue reference to istream whitch is specified at first argument

Definition at line 257 of file point3d.hpp.

Member Data Documentation

§ x

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
value_type dxle::point3d_c< T, >::x

Definition at line 102 of file point3d.hpp.

§ y

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
value_type dxle::point3d_c< T, >::y

Definition at line 102 of file point3d.hpp.

§ z

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
value_type dxle::point3d_c< T, >::z

Definition at line 102 of file point3d.hpp.


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