homog2d library
Namespaces | Classes | Functions
h2d::priv Namespace Reference

Holds private stuff. More...

Namespaces

 chull
 Holds convex hull code.
 
 runion
 Common stuff for FRect_ union, see FRect_::unionArea()
 

Classes

class  ClosestPoints
 Used in getClosestPoints() More...
 
struct  F_MAX
 
struct  F_MIN
 used in findPoint() More...
 
struct  PolylineAttribs
 Holds attribute of a Polyline, allows storage of last computed value through the use of ValueFlag. More...
 
class  ValueFlag
 A POD value that needs some computing, associated with its flag. Used to be able to retain a value needing complex calculation. More...
 

Functions

template<typename Cont , typename std::enable_if< trait::IsArray< Cont >::value, Cont >::type * = nullptr>
Cont alloc (std::size_t)
 Allocation for std::array container. More...
 
template<typename T >
void drawSvgSeg (img::Image< img::SvgImage > &im, const Point2d_< T > &pt1, const Point2d_< T > &pt2, std::string color, int thickness, std::string attribs=std::string())
 Helper function to draw SVG segment. More...
 
template<typename T >
void drawSvgSeg (img::Image< img::SvgImage > &im, const std::pair< Point2d_< T >, Point2d_< T >> &ppts, std::string color, int thickness, std::string attribs=std::string())
 
template<typename FPT , typename CONT , typename S_WHAT >
size_t findPoint (const Point2d_< FPT > &qpt, const CONT &cont, const S_WHAT &)
 Private. Common function for searching nearest of farthest point. More...
 
template<typename FPT >
void fix_order (Point2d_< FPT > &ptA, Point2d_< FPT > &ptB)
 Private free function, swap the points so that ptA.x <= ptB.x, and if equal, sorts on y. More...
 
template<typename FPT >
std::array< PointPair_< double >, 3 > getArrowSegments (const base::SegVec< typ::IsOSeg, FPT > &vec)
 
template<typename FPT >
auto getBB_CommonType (const std::vector< CommonType_< FPT >> &v_var)
 Get Bounding Box for a container holding variant objects. More...
 
template<typename FPT >
auto getBB_FRect (const std::vector< FRect_< FPT >> &v_rects)
 get BB for a set of FRect_ objects More...
 
template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
PointPair_< typename T::value_type::FType > getBB_Points (const T &vpts)
 Returns the bounding box of points in vector/list/array of points vpts (free function) More...
 
template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
FRect_< typename T::value_type::FType > getBB_Segments (const T &vsegs)
 Returns the bounding box of segments in vector/list/array of points vsegs. More...
 
template<typename T >
auto getBmPoint_helper (const T &t)
 Return iterator on Bottom-most point of container holding points. More...
 
template<typename PT >
std::array< PT, 3 > getLargestDistancePoints (PT pt1, PT pt2, PT pt3)
 Helper function, used to check for colinearity of three points. More...
 
template<typename T1 , typename T2 >
Line2d_< T1 > getOrthogonalLine_B2 (const Point2d_< T2 > &pt, const Line2d_< T1 > &li)
 Helper function for impl_getOrthogonalLine_A() and impl_getOrthogonalLine_B(), Compute orthogonal line to li at point pt (that must lie on the line) More...
 
template<typename FPT , typename FPT2 , typename FPT3 >
auto getPoints_B2 (const Point2d_< FPT > &pt, FPT2 dist, const Line2d_< FPT3 > &li)
 Helper function, factorized here for the two impl_getPoints_A() implementations. More...
 
template<typename IMG , typename FPT >
void impl_drawIndexes (img::Image< IMG > &img, size_t c, const img::DrawParams &dp, const Point2d_< FPT > &pt)
 Draw indexes for points. More...
 
template<typename IMG , typename FPT >
void impl_drawIndexes (img::Image< IMG > &img, size_t c, const img::DrawParams &dp, const Segment_< FPT > &seg)
 Draw indexes for segment. More...
 
template<typename IMG , typename DUMMY >
void impl_drawIndexes (img::Image< IMG > &, size_t, const img::DrawParams &, const DUMMY &)
 Default signature, will be instanciated if no other fits (and does nothing) More...
 
template<typename T >
std::pair< int, int > impl_dsize (const detail::DataFpType< T > &)
 Implementation of dsize(), returns nb of bits of mantissa and exponent (default implementation) More...
 
template<long unsigned int M, long unsigned int E>
std::pair< int, int > impl_dsize (const detail::DataFpType< ttmath::Big< M, E >> &)
 Implementation for ttmath types. More...
 
Dtype impl_dtype (const detail::DataFpType< float > &)
 
Dtype impl_dtype (const detail::DataFpType< double > &)
 
Dtype impl_dtype (const detail::DataFpType< long double > &)
 
template<typename T >
Dtype impl_dtype (const detail::DataFpType< T > &)
 
template<long unsigned int M, long unsigned int E>
Dtype impl_dtype (const detail::DataFpType< ttmath::Big< M, E >> &)
 Implementation for ttmath types. More...
 
template<typename FPT1 , typename PT >
bool is_valid_circle (const Circle_< FPT1 > &circ, const std::vector< PT > &pts)
 Free Function to check whether a circle encloses the given points. More...
 
template<typename ST , typename PLT , typename FPT >
std::vector< ST > p_getSegs (const base::PolylineBase< PLT, FPT > &pl, const ST &)
 Private helper function for base::PolylineBase::getSegs() and base::PolylineBase::getOSegs() More...
 
template<typename T >
int sign (T val)
 Get sign of value. More...
 
template<typename FPT1 , typename FPT2 >
HOMOG2D_INUMTYPE sqDist (const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
 Free function, squared distance between points (sqrt not needed for comparisons, and can save some time) More...
 

Detailed Description

Holds private stuff.

Helper function used by the draw(OSegment) function, returns the 3 segment corresponding to the "arrows" as 3 pairs of points.

Used both in the SVG and the Opencv backends

   /|\
    |
    |
    |
   ---

Function Documentation

◆ alloc()

template<typename Cont , typename std::enable_if< trait::IsArray< Cont >::value, Cont >::type * = nullptr>
Cont h2d::priv::alloc ( std::size_t  nb)

Allocation for std::array container.

Allocation for std::vector and std::list container.

See also
operator * ( const Hmatrix_&, const Cont& );
9778 {
9779  return Cont();
9780 }

◆ drawSvgSeg() [1/2]

template<typename T >
void h2d::priv::drawSvgSeg ( img::Image< img::SvgImage > &  im,
const Point2d_< T > &  pt1,
const Point2d_< T > &  pt2,
std::string  color,
int  thickness,
std::string  attribs = std::string() 
)

Helper function to draw SVG segment.

12145 {
12146  im.getReal()._svgString << "<line x1=\""
12147  << pt1.getX()
12148  << "\" y1=\""
12149  << pt1.getY()
12150  << "\" x2=\""
12151  << pt2.getX()
12152  << "\" y2=\""
12153  << pt2.getY()
12154  << "\" stroke=\"" << color
12155  << "\" stroke-width=\"" << thickness << "\" "
12156  << attribs << "/>\n";
12157 }
img::Image< img::SvgImage > im(300, 400)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawSvgSeg() [2/2]

template<typename T >
void h2d::priv::drawSvgSeg ( img::Image< img::SvgImage > &  im,
const std::pair< Point2d_< T >, Point2d_< T >> &  ppts,
std::string  color,
int  thickness,
std::string  attribs = std::string() 
)
12167 {
12168  drawSvgSeg( im, ppts.first, ppts.second, color, thickness, attribs );
12169 }
void drawSvgSeg(img::Image< img::SvgImage > &im, const std::pair< Point2d_< T >, Point2d_< T >> &ppts, std::string color, int thickness, std::string attribs=std::string())
Definition: homog2d.hpp:12160
img::Image< img::SvgImage > im(300, 400)

◆ findPoint()

template<typename FPT , typename CONT , typename S_WHAT >
size_t h2d::priv::findPoint ( const Point2d_< FPT > &  qpt,
const CONT &  cont,
const S_WHAT &   
)

Private. Common function for searching nearest of farthest point.

Parameters
qptquery point
contcontainer
11090 {
11091  if( cont.size() < 2 )
11092  HOMOG2D_THROW_ERROR_1( "container holds " << cont.size() \
11093  << " points, minimum is 2" );
11094 
11095  decltype( priv::sqDist( qpt, qpt ) ) resDist;
11096  size_t startIdx = 1;
11097  size_t resIdx = 0;
11098 
11099 // if point is the first one of the container, then
11100 // initialize with the second one
11101  if( cont[0] == qpt )
11102  {
11103  startIdx++;
11104  resIdx++;
11105  resDist = priv::sqDist( qpt, cont[1] );
11106  }
11107  else // initialize with first point
11108  {
11109  resDist = priv::sqDist( qpt, cont[0] );
11110  }
11111 
11112  for( size_t i=startIdx; i<cont.size(); i++ )
11113  {
11114  if( qpt != cont[i] )
11115  {
11116  auto currentDist = priv::sqDist( qpt, cont[i] );
11117  if constexpr( std::is_same_v<S_WHAT, F_MIN> )
11118  {
11119  if( currentDist < resDist )
11120  {
11121  resIdx = i;
11122  resDist = currentDist;
11123  }
11124  }
11125  else
11126  {
11127  if( currentDist > resDist )
11128  {
11129  resIdx = i;
11130  resDist = currentDist;
11131  }
11132  }
11133  }
11134  }
11135  return resIdx;
11136 }
HOMOG2D_INUMTYPE sqDist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, squared distance between points (sqrt not needed for comparisons, and can save some ti...
Definition: homog2d.hpp:3539
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fix_order()

template<typename FPT >
void h2d::priv::fix_order ( Point2d_< FPT > &  ptA,
Point2d_< FPT > &  ptB 
)

Private free function, swap the points so that ptA.x <= ptB.x, and if equal, sorts on y.

3521 {
3522  if( !(ptA < ptB) )
3523  std::swap( ptA, ptB );
3524 }
Here is the caller graph for this function:

◆ getArrowSegments()

template<typename FPT >
std::array<PointPair_<double>,3> h2d::priv::getArrowSegments ( const base::SegVec< typ::IsOSeg, FPT > &  vec)
11808 {
11809  std::array<std::pair<Point2d_<double>,Point2d_<double>>,3> out;
11810  auto ppts = vec.getPts();
11811  auto pt1 = ppts.first;
11812  auto pt2 = ppts.second;
11813 
11814  const int arSize = 8;
11815 
11816  Line2d_<double> liA = vec.getLine().getOrthogLine( pt1 );
11817  out[0] = liA.getPoints( pt1, arSize );
11818 
11819  auto ppts_B = vec.getLine().getPoints( pt2, arSize );
11820 
11821  Point2d_<double> p0 = ppts_B.first;
11822  if( dist( pt1, ppts_B.first) > dist(pt1, ppts_B.second) )
11823  p0 = ppts_B.second;
11824 
11825  Line2d_<double> liB = vec.getLine().getOrthogLine( p0 );
11826  auto ppts_C = liB.getPoints( p0, arSize );
11827 
11828  out[1] = std::make_pair(ppts_C.first, pt2);
11829  out[2] = std::make_pair(ppts_C.second, pt2);
11830 
11831  return out;
11832 }
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBB_CommonType()

template<typename FPT >
auto h2d::priv::getBB_CommonType ( const std::vector< CommonType_< FPT >> &  v_var)

Get Bounding Box for a container holding variant objects.

Note
Here, we DO NOT preallocate the vector, because if the container holds lines, then no point pair will be added for these elements. If we would have preallocate with 2 x size of input vector, then some default-constructed points could sneak in, and introduce an error.
Todo:
20240513: At present, this is only implemented for std::vector. Let it handle std::list and std::array.
10277 {
10278  HOMOG2D_START;
10279  HOMOG2D_DEBUG_ASSERT( v_var.size(), "cannot compute bounding box of empty set of variant" );
10280 
10281  std::vector<Point2d_<FPT>> vpts;
10282  vpts.reserve( v_var.size()*2 );
10283  PointPair_<FPT> ppair;
10284  for( const auto& elem: v_var )
10285  {
10286  try
10287  {
10288  ppair = std::visit( fct::PtPairFunct{}, elem );
10289  }
10290  catch( const std::exception& err )
10291  {
10292  HOMOG2D_LOG_WARNING( "unable to compute point pair\n -msg=" << err.what() );
10293  }
10294  vpts.push_back( ppair.first );
10295  vpts.push_back( ppair.second );
10296  }
10297  return FRect_<FPT>( getBB_Points( vpts ) );
10298 }
PointPair_< typename T::value_type::FType > getBB_Points(const T &vpts)
Returns the bounding box of points in vector/list/array of points vpts (free function) ...
Definition: homog2d.hpp:5903
#define HOMOG2D_START
Definition: homog2d.hpp:106
#define HOMOG2D_LOG_WARNING(a)
Definition: homog2d.hpp:151
#define HOMOG2D_DEBUG_ASSERT(a, b)
Assert debug macro, used internally if HOMOG2D_DEBUGMODE is defined.
Definition: homog2d.hpp:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBB_FRect()

template<typename FPT >
auto h2d::priv::getBB_FRect ( const std::vector< FRect_< FPT >> &  v_rects)

get BB for a set of FRect_ objects

Todo:
same as getBB_Segments() ???
5978 {
5979  HOMOG2D_START;
5980  HOMOG2D_DEBUG_ASSERT( v_rects.size(), "cannot compute bounding box of empty set of rectangles" );
5981 
5982  std::vector<Point2d_<FPT>> vpts( v_rects.size()*2 );
5983  auto it = vpts.begin();
5984  for( const auto& seg: v_rects )
5985  {
5986  auto ppts = seg.getPts();
5987  *it++ = ppts.first;
5988  *it++ = ppts.second;
5989  }
5990  return FRect_<FPT>( getBB_Points( vpts ) );
5991 }
PointPair_< typename T::value_type::FType > getBB_Points(const T &vpts)
Returns the bounding box of points in vector/list/array of points vpts (free function) ...
Definition: homog2d.hpp:5903
Segment seg
Definition: homog2d_test.cpp:4033
#define HOMOG2D_START
Definition: homog2d.hpp:106
#define HOMOG2D_DEBUG_ASSERT(a, b)
Assert debug macro, used internally if HOMOG2D_DEBUGMODE is defined.
Definition: homog2d.hpp:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBB_Points()

template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
PointPair_<typename T::value_type::FType> h2d::priv::getBB_Points ( const T &  vpts)

Returns the bounding box of points in vector/list/array of points vpts (free function)

Todo:
This loops twice on the points. Maybe some improvement here.
5904 {
5905  HOMOG2D_START;
5906  using FPT = typename T::value_type::FType;
5907  HOMOG2D_DEBUG_ASSERT( static_cast<bool>(vpts.size()), "cannot run with no points" );
5908 
5909  auto mm_x = std::minmax_element(
5910  std::begin( vpts ),
5911  std::end( vpts ),
5912  [] // lambda
5913  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
5914  {
5915  return pt1.getX() < pt2.getX();
5916  }
5917  );
5918  auto mm_y = std::minmax_element(
5919  std::begin( vpts ),
5920  std::end( vpts ),
5921  [] // lambda
5922  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
5923  {
5924  return pt1.getY() < pt2.getY();
5925  }
5926  );
5927 
5928  auto p1 = Point2d_<HOMOG2D_INUMTYPE>( mm_x.first->getX(), mm_y.first->getY() );
5929  auto p2 = Point2d_<HOMOG2D_INUMTYPE>( mm_x.second->getX(), mm_y.second->getY() );
5930 
5931 #ifndef HOMOG2D_NOCHECKS
5932  if( p1.distTo( p2 ) < thr::nullDistance() )
5934  "unable to compute bounding box of set, identical points:\n -p1:"<< p1 << "\n -p2:" << p2
5935  );
5936  if( shareCommonCoord( p1, p2 ) )
5938  "unable to compute bounding box of set, points share common coordinate:\n -p1:"
5939  << p1 << "\n -p2:" << p2
5940  );
5941 #endif // HOMOG2D_NOCHECKS
5942 
5943  return std::make_pair( p1, p2 );
5944 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1195
#define HOMOG2D_START
Definition: homog2d.hpp:106
#define HOMOG2D_DEBUG_ASSERT(a, b)
Assert debug macro, used internally if HOMOG2D_DEBUGMODE is defined.
Definition: homog2d.hpp:126
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
bool shareCommonCoord(const std::pair< Point2d_< FPT1 >, Point2d_< FPT2 >> &ppts)
Returns true if one of the points share a common coordinate (thus making them unable to define a boun...
Definition: homog2d.hpp:1302
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBB_Segments()

template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
FRect_<typename T::value_type::FType> h2d::priv::getBB_Segments ( const T &  vsegs)

Returns the bounding box of segments in vector/list/array of points vsegs.

5957 {
5958  HOMOG2D_START;
5959  using FPT = typename T::value_type::FType;
5960 
5961  HOMOG2D_DEBUG_ASSERT( vsegs.size(), "cannot compute bounding box of empty set of segments" );
5962  std::vector<Point2d_<FPT>> vpts( vsegs.size()*2 );
5963  auto it = vpts.begin();
5964  for( const auto& seg: vsegs )
5965  {
5966  auto ppts = seg.getPts();
5967  *it++ = ppts.first;
5968  *it++ = ppts.second;
5969  }
5970  return FRect_<typename T::value_type::FType>( getBB_Points( vpts ) );
5971 }
PointPair_< typename T::value_type::FType > getBB_Points(const T &vpts)
Returns the bounding box of points in vector/list/array of points vpts (free function) ...
Definition: homog2d.hpp:5903
Segment seg
Definition: homog2d_test.cpp:4033
#define HOMOG2D_START
Definition: homog2d.hpp:106
#define HOMOG2D_DEBUG_ASSERT(a, b)
Assert debug macro, used internally if HOMOG2D_DEBUGMODE is defined.
Definition: homog2d.hpp:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBmPoint_helper()

template<typename T >
auto h2d::priv::getBmPoint_helper ( const T &  t)

Return iterator on Bottom-most point of container holding points.

Used by

6879 {
6880  using FPT = typename T::value_type::FType;
6881 #ifndef HOMOG2D_NOCHECKS
6882  if( t.size() == 0 )
6883  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6884 #endif
6885 
6886  return std::min_element(
6887  std::begin(t),
6888  std::end(t),
6889  [] // lambda
6890  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
6891  {
6892  if( pt1.getY() < pt2.getY() )
6893  return true;
6894  if( pt1.getY() > pt2.getY() )
6895  return false;
6896  return( pt1.getX() < pt2.getX() );
6897  }
6898  );
6899 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLargestDistancePoints()

template<typename PT >
std::array<PT,3> h2d::priv::getLargestDistancePoints ( PT  pt1,
PT  pt2,
PT  pt3 
)

Helper function, used to check for colinearity of three points.

This will return the same points as given in input but ordered as:

  • the pair that has the largest distance in [0] and [1]
  • the third point in [2]
  • the point closest to the third point in [1], the farthest in [0]
See also
bool areCollinear()
Todo:
20220520: needs some optimization, once it has been extensively tested

We have theses 6 situations described on below diagrams A through F, with the desired output order:

 1 +                       1 +
   |    A => 3,1,2           |     B => 2,1,3
   |                         |
 2 +---------------+ 3     3 +---------------+ 2

 2 +                       2 +
   |    C => 3,2,1           |     D => 1,2,3
   |                         |
 1 +---------------+ 3     3 +---------------+ 1

 3 +                       3 +
   |    E => 2,3,1           |     F => 1,3,2
   |                         |
 1 +---------------+ 2     2 +---------------+ 1
3579 {
3580  auto d12 = sqDist( pt1, pt2 );
3581  auto d13 = sqDist( pt1, pt3 );
3582  auto d23 = sqDist( pt2, pt3 );
3583 
3584  PT* pA = 0;
3585  PT* pB = 0;
3586  PT* pM = 0;
3587 
3588  if( d12 > d13 ) // case B, D, E
3589  {
3590  pA = &pt2;
3591  if( d12 > d23 ) // case B, D
3592  {
3593  pB = &pt1;
3594  pM = &pt3;
3595  if( d13 > d23 )
3596  std::swap( *pA, *pB );
3597  }
3598  else // case E
3599  {
3600  pB = &pt3;
3601  pM = &pt1;
3602  }
3603  }
3604  else // case A, C, F
3605  {
3606  pA = &pt3;
3607  if( d13 > d23 ) // A, F
3608  {
3609  pB = &pt1;
3610  pM = &pt2;
3611  if( d12 > d23 )
3612  std::swap( *pA, *pB );
3613  }
3614  else // case C
3615  {
3616  pB = &pt2;
3617  pM = &pt1;
3618  }
3619  }
3620 
3621  return std::array<PT,3>{ *pA, *pB, *pM };
3622 }
HOMOG2D_INUMTYPE sqDist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, squared distance between points (sqrt not needed for comparisons, and can save some ti...
Definition: homog2d.hpp:3539
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrthogonalLine_B2()

template<typename T1 , typename T2 >
Line2d_<T1> h2d::priv::getOrthogonalLine_B2 ( const Point2d_< T2 > &  pt,
const Line2d_< T1 > &  li 
)

Helper function for impl_getOrthogonalLine_A() and impl_getOrthogonalLine_B(), Compute orthogonal line to li at point pt (that must lie on the line)

3703 {
3704  auto arr = li.get(); // get array of 3 values
3705  Line2d_<T1> out(
3706  -arr[1],
3707  arr[0],
3708  arr[1] * pt.getX() - arr[0] * pt.getY()
3709  );
3710  out.p_normalizePL();
3711  return out;
3712 }
Line2d li
Definition: homog2d_test.cpp:4035
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPoints_B2()

template<typename FPT , typename FPT2 , typename FPT3 >
auto h2d::priv::getPoints_B2 ( const Point2d_< FPT > &  pt,
FPT2  dist,
const Line2d_< FPT3 > &  li 
)

Helper function, factorized here for the two impl_getPoints_A() implementations.

3680 {
3681  auto arr = li.get();
3682  const HOMOG2D_INUMTYPE a = static_cast<HOMOG2D_INUMTYPE>(arr[0]);
3683  const HOMOG2D_INUMTYPE b = static_cast<HOMOG2D_INUMTYPE>(arr[1]);
3684  auto coeff = static_cast<HOMOG2D_INUMTYPE>(dist) / homog2d_sqrt( a*a + b*b );
3685 
3686  Point2d_<FPT> pt1(
3687  pt.getX() - b * coeff,
3688  pt.getY() + a * coeff
3689  );
3690  Point2d_<FPT> pt2(
3691  pt.getX() + b * coeff,
3692  pt.getY() - a * coeff
3693  );
3694  fix_order( pt1, pt2 );
3695  return std::make_pair( pt1, pt2 );
3696 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
void fix_order(Point2d_< FPT > &ptA, Point2d_< FPT > &ptB)
Private free function, swap the points so that ptA.x <= ptB.x, and if equal, sorts on y...
Definition: homog2d.hpp:3520
#define homog2d_sqrt
Definition: homog2d.hpp:75
Line2d li
Definition: homog2d_test.cpp:4035
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ impl_drawIndexes() [1/3]

template<typename IMG , typename FPT >
void h2d::priv::impl_drawIndexes ( img::Image< IMG > &  img,
size_t  c,
const img::DrawParams dp,
const Point2d_< FPT > &  pt 
)

Draw indexes for points.

11271 {
11272  if( dp._dpValues._showIndex )
11273  drawText( img, std::to_string(c), pt, dp );
11274 }
void drawText(img::Image< U > &im, std::string str, Point2d_< FPT > pt, img::DrawParams dp=img::DrawParams())
Free function, draws text str at position pt.
Definition: homog2d.hpp:11260
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ impl_drawIndexes() [2/3]

template<typename IMG , typename FPT >
void h2d::priv::impl_drawIndexes ( img::Image< IMG > &  img,
size_t  c,
const img::DrawParams dp,
const Segment_< FPT > &  seg 
)

Draw indexes for segment.

11280 {
11281  if( dp._dpValues._showIndex )
11282  drawText( img, std::to_string(c), seg.getCenter(), dp );
11283 }
void drawText(img::Image< U > &im, std::string str, Point2d_< FPT > pt, img::DrawParams dp=img::DrawParams())
Free function, draws text str at position pt.
Definition: homog2d.hpp:11260
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ impl_drawIndexes() [3/3]

template<typename IMG , typename DUMMY >
void h2d::priv::impl_drawIndexes ( img::Image< IMG > &  ,
size_t  ,
const img::DrawParams ,
const DUMMY &   
)

Default signature, will be instanciated if no other fits (and does nothing)

11289 {}

◆ impl_dsize() [1/2]

template<typename T >
std::pair<int,int> h2d::priv::impl_dsize ( const detail::DataFpType< T > &  )
inline

Implementation of dsize(), returns nb of bits of mantissa and exponent (default implementation)

1143  {
1144  return std::make_pair(
1145  std::numeric_limits<T>::digits,
1146  sizeof(T)*8-std::numeric_limits<T>::digits-1
1147  );
1148  }
Here is the caller graph for this function:

◆ impl_dsize() [2/2]

template<long unsigned int M, long unsigned int E>
std::pair<int,int> h2d::priv::impl_dsize ( const detail::DataFpType< ttmath::Big< M, E >> &  )
inline

Implementation for ttmath types.

1183  {
1184  return std::make_pair( M*sizeof(size_t)*8, E*sizeof(size_t)*8 );
1185  }

◆ impl_dtype() [1/5]

Dtype h2d::priv::impl_dtype ( const detail::DataFpType< float > &  )
inline
1152  {
1153  return Dtype::Float;
1154  }
Here is the caller graph for this function:

◆ impl_dtype() [2/5]

Dtype h2d::priv::impl_dtype ( const detail::DataFpType< double > &  )
inline
1157  {
1158  return Dtype::Double;
1159  }

◆ impl_dtype() [3/5]

Dtype h2d::priv::impl_dtype ( const detail::DataFpType< long double > &  )
inline
1162  {
1163  return Dtype::LongDouble;
1164  }

◆ impl_dtype() [4/5]

template<typename T >
Dtype h2d::priv::impl_dtype ( const detail::DataFpType< T > &  )
inline
1168  {
1169  return Dtype::Other;
1170  }

◆ impl_dtype() [5/5]

template<long unsigned int M, long unsigned int E>
Dtype h2d::priv::impl_dtype ( const detail::DataFpType< ttmath::Big< M, E >> &  )
inline

Implementation for ttmath types.

1176  {
1177  return Dtype::Ttmath;
1178  }

◆ is_valid_circle()

template<typename FPT1 , typename PT >
bool h2d::priv::is_valid_circle ( const Circle_< FPT1 > &  circ,
const std::vector< PT > &  pts 
)

Free Function to check whether a circle encloses the given points.

5634 {
5635  for( const auto& pt: pts )
5636  if( !pt.isInside( circ ) )
5637  return false;
5638  return true;
5639 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:

◆ p_getSegs()

template<typename ST , typename PLT , typename FPT >
std::vector<ST> h2d::priv::p_getSegs ( const base::PolylineBase< PLT, FPT > &  pl,
const ST &   
)

Private helper function for base::PolylineBase::getSegs() and base::PolylineBase::getOSegs()

5997 {
5998  auto siz = pl.size();
5999  if( siz < 2 ) // nothing to return
6000  return std::vector<ST>();
6001 
6002  std::vector<ST> out;
6003  out.reserve( siz );
6004  for( size_t i=0; i<siz-1; i++ )
6005  {
6006  const auto& pt1 = pl.getPoint(i);
6007  const auto& pt2 = pl.getPoint(i+1);
6008  out.emplace_back( ST(pt1,pt2) );
6009  }
6010  if constexpr( std::is_same_v<PLT,typ::IsClosed> )
6011  out.push_back( ST(pl.getPoint(siz-1), pl.getPoint(0) ) );
6012  return out;
6013 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign()

template<typename T >
int h2d::priv::sign ( val)

Get sign of value.

source: https://stackoverflow.com/a/4609795/

3529  {
3530  return (T(0) < val) - (val < T(0));
3531 }
Here is the caller graph for this function:

◆ sqDist()

template<typename FPT1 , typename FPT2 >
HOMOG2D_INUMTYPE h2d::priv::sqDist ( const Point2d_< FPT1 > &  pt1,
const Point2d_< FPT2 > &  pt2 
)

Free function, squared distance between points (sqrt not needed for comparisons, and can save some time)

See also
Point2d_::distTo()
dist( const Point2d_&, const Point2d_& )
3540 {
3541  auto dx = (HOMOG2D_INUMTYPE)pt1.getX() - pt2.getX();
3542  auto dy = (HOMOG2D_INUMTYPE)pt1.getY() - pt2.getY();
3543  return dx*dx + dy*dy;
3544 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
Here is the call graph for this function:
Here is the caller graph for this function: