homog2d library
Public Types | Public Member Functions | Friends | List of all members
h2d::base::LPBase< LP, FPT > Class Template Reference

Base class, will be instanciated as Point2d_ or Line2d_. More...

#include <homog2d.hpp>

Inheritance diagram for h2d::base::LPBase< LP, FPT >:
Inheritance graph
[legend]
Collaboration diagram for h2d::base::LPBase< LP, FPT >:
Collaboration graph
[legend]

Public Types

using FType = FPT
 
using SType = LP
 

Public Member Functions

constexpr HOMOG2D_INUMTYPE area () const
 Neither lines nor points have an area. More...
 
template<typename FPT2 >
HOMOG2D_INUMTYPE distTo (const Point2d_< FPT2 > &pt) const
 overload for line to point distance More...
 
template<typename FPT2 >
HOMOG2D_INUMTYPE distTo (const Line2d_< FPT2 > &) const
 
template<typename FPT2 >
HOMOG2D_INUMTYPE distTo (const Segment_< FPT2 > &) const
 
void draw (img::Image< img::SvgImage > &im, img::DrawParams dp=img::DrawParams()) const
 SVG draw function. More...
 
void draw (img::Image< cv::Mat > &im, img::DrawParams dp=img::DrawParams()) const
 Opencv draw function. More...
 
std::array< FPT, 3 > get () const
 
template<typename T , typename FPT2 >
HOMOG2D_INUMTYPE getAngle (const LPBase< T, FPT2 > &other) const
 
template<typename T , typename FPT2 >
HOMOG2D_INUMTYPE getAngle (const base::SegVec< T, FPT2 > &seg) const
 Returns angle in rad. between line and segment seg. More...
 
template<typename LP2 , typename FPT2 >
HOMOG2D_INUMTYPE getAngle (const LPBase< LP2, FPT2 > &li) const
 Returns the angle (in rad.) between the line and the other one. More...
 
FRect_< HOMOG2D_INUMTYPEgetBB () const
 Needed so the function getBB(T1,T2) builds, whatever the types and because of variant (. More...
 
template<typename FPT2 >
HOMOG2D_INUMTYPE getCoord (GivenCoord gc, FPT2 other) const
 
cv::Point2i getCvPtd () const
 
cv::Point2i getCvPtf () const
 
cv::Point2i getCvPti () const
 
template<typename FPT2 >
Line2d_< FPT > getOrthogLine (GivenCoord gc, FPT2 other) const
 Returns an orthogonal line to the one it is called on, at a point on the line defined by one of its coordinates. More...
 
template<typename FPT2 >
Line2d_< FPT > getOrthogLine (const Point2d_< FPT2 > &pt) const
 Returns an orthogonal line to the one it is called on, at point pt. More...
 
template<typename FPT2 >
OSegment_< FPT > getOrthogSegment (const Point2d_< FPT2 > &pt) const
 Returns the segment from the point (not on line) to the line, shortest path. More...
 
template<typename FPT2 >
Line2d_< FPT > getParallelLine (const Point2d_< FPT2 > &) const
 Returns an parallel line to the one it is called on, with pt lying on it. More...
 
template<typename T >
std::pair< Line2d_< FPT >, Line2d_< FPT > > getParallelLines (T dist) const
 Returns the pair of parallel lines at a distance dist from line. More...
 
template<typename FPT2 >
Point2d_< FPT > getPoint (GivenCoord gc, FPT2 other) const
 
template<typename FPT2 , typename FPT3 >
PointPair_< FPT > getPoints (GivenCoord gc, FPT2 coord, FPT3 dist) const
 Returns a pair of points that are lying on line at distance dist from a point defined by one of its coordinates. More...
 
template<typename FPT2 , typename FPT3 >
PointPair_< FPT > getPoints (const Point2d_< FPT2 > &pt, FPT3 dist) const
 Returns a pair of points that are lying on line at distance dist from point pt, assuming that one is lying on the line. More...
 
template<typename ANY >
ANY getPt () const
 Generic transformation into any other point type, as long as it provides a 2-args constructor (is the case for Opencv and Boost Geometry). More...
 
template<typename FPT2 , typename T >
Line2d_< FPT > getRotatedLine (const Point2d_< FPT2 > &pt, T theta) const
 Returns a line rotated at point pt with angle theta. More...
 
HOMOG2D_INUMTYPE getX () const
 
HOMOG2D_INUMTYPE getY () const
 
template<typename FPT2 >
detail::Intersect< detail::Inters_1, FPT > intersects (const Line2d_< FPT2 > &other) const
 Line/Line intersection. More...
 
template<typename FPT2 >
detail::IntersectM< FPT > intersects (const Point2d_< FPT2 > &pt1, const Point2d_< FPT2 > &pt2) const
 Line/FRect intersection (rectangle defined by pt1 and pt2) More...
 
template<typename FPT2 >
detail::IntersectM< FPT > intersects (const FRect_< FPT2 > &rect) const
 Line/FRect intersection. More...
 
template<typename SV , typename FPT2 >
detail::Intersect< detail::Inters_1, FPT > intersects (const SegVec< SV, FPT2 > &seg) const
 Line/Segment intersection. More...
 
template<typename T , typename std::enable_if<(std::is_arithmetic< T >::value &&!std::is_same< T, bool >::value), T >::type * = nullptr>
detail::Intersect< detail::Inters_2, FPT > intersects (const Point2d_< FPT > &pt0, T radius) const
 Line/Circle intersection. More...
 
template<typename T >
detail::Intersect< detail::Inters_2, FPT > intersects (const Circle_< T > &cir) const
 Line/Circle intersection. More...
 
template<typename PLT , typename FPT2 >
detail::IntersectM< FPT > intersects (const base::PolylineBase< PLT, FPT2 > &pl) const
 Line/Polyline intersection. More...
 
bool isInf () const
 Returns true if point is at infinity (third value less than thr::nullDenom() ) More...
 
template<typename T1 , typename T2 >
bool isInside (const Point2d_< T1 > &pt1, const Point2d_< T2 > &pt2) const
 Point is inside flat rectangle. More...
 
template<typename FPT2 >
bool isInside (const FRect_< FPT2 > &rect) const
 Point is inside FRect. More...
 
template<typename T , typename std::enable_if< !std::is_same_v< T, Point2d_< FPT >>, T >::type * = nullptr>
bool isInside (const Point2d_< FPT > &center, T radius) const
 Point is inside circle defined by center and radius. More...
 
template<typename T >
bool isInside (const Circle_< T > &cir) const
 Point is inside Circle. More...
 
template<typename FPT2 >
bool isInside (const Ellipse_< FPT2 > &ell) const
 Point is inside Ellipse. More...
 
template<typename FPT2 , typename PTYPE >
bool isInside (const base::PolylineBase< PTYPE, FPT2 > &poly) const
 
template<typename FPT2 >
bool isParallelTo (const Line2d_< FPT2 > &) const
 
template<typename T >
bool isParallelTo (const Segment_< T > &seg) const
 
HOMOG2D_INUMTYPE length () const
 A point has a null length, a line has an infinite length. More...
 
template<typename FPT2 >
 LPBase (const Line2d_< FPT2 > &v1, const Line2d_< FPT2 > &v2)
 Constructor: build a point from two lines. More...
 
template<typename FPT2 >
 LPBase (const Point2d_< FPT2 > &v1, const Point2d_< FPT2 > &v2)
 Constructor: build a line from two points. More...
 
template<typename T >
 LPBase (const Line2d_< T > &li)
 Constructor: copy-constructor for lines. More...
 
template<typename T >
 LPBase (const Point2d_< T > &pt)
 Constructor with single arg of type "Point". More...
 
template<typename T1 , typename T2 >
 LPBase (const T1 &v1, const T2 &v2)
 Constructor: build from two numerical values, depends on the type. More...
 
template<typename T0 , typename T1 , typename T2 >
 LPBase (T0 v0, T1 v1, T2 v2)
 Constructor of line/point from 3 values. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
 LPBase (T1 x1, T2 y1, T3 x2, T4 y2)
 Constructor of line from 4 values x1,y1,x2,y2. More...
 
template<typename T , typename std::enable_if< std::is_same< T, std::array< FPT, 3 >>::value, T >::type * = nullptr>
 LPBase (const T &arr)
 Constructor from an array holding 3 values of same type (a direct copy can be done) More...
 
template<typename T >
 LPBase (const T &arr)
 Constructor from an array/vector holding 3 values of different type. More...
 
 LPBase ()
 Default constructor, depends on the type. More...
 
template<typename T >
 LPBase (LineDir orient, T value)
 Constructor of horizontal/vertical line. More...
 
template<typename BFPT >
 LPBase (const boost::geometry::model::point< BFPT, 2, boost::geometry::cs::cartesian > &pt)
 Constructor from boost::geometry point type. More...
 
template<typename BFPT >
 LPBase (const boost::geometry::model::d2::point_xy< BFPT > &pt)
 Constructor from boost::geometry second point type. More...
 
template<typename T >
 LPBase (cv::Point_< T > pt)
 Constructor: build point or line from a single OpenCv point. More...
 
template<typename T1 >
void moveTo (const Point2d_< T1 > &pt)
 Move point to other location (same as set(), but this one will be virtual). Does nothing for lines => NO, FAILS TO BUILD ! More...
 
bool operator!= (const base::LPBase< LP, FPT > &other) const
 
bool operator< (const base::LPBase< LP, FPT > &other) const
 Sorting operator, for points (illegal for lines) More...
 
bool operator== (const base::LPBase< LP, FPT > &other) const
 
template<typename T0 , typename T1 , typename T2 >
void set (T0 v0, T1 v1, T2 v2)
 Assign homogeneous values. More...
 
template<typename BFPT >
void set (const boost::geometry::model::point< BFPT, 2, boost::geometry::cs::cartesian > &pt)
 Set from boost::geometry point type. More...
 
template<typename T1 , typename T2 >
void set (T1 x, T2 y)
 Set point from 2 euclidean values. More...
 
size_t size () const
 
template<typename T1 , typename T2 >
void translate (T1 dx, T2 dy)
 Translate Point2d, does nothing for Line2d. More...
 
template<typename T1 , typename T2 >
void translate (const std::pair< T1, T2 > &pa)
 Translate Point2d, does nothing for Line2d. More...
 
Type type () const
 
- Public Member Functions inherited from h2d::detail::Common< FPT >
std::pair< int, int > dsize () const
 Get data size expressed as number of bits for, respectively, mantissa and exponent. More...
 
Dtype dtype () const
 Get numerical data type as a Dtype value, can be stringified with h2d::getString(Dtype) More...
 
template<typename T >
constexpr bool isInside (const Common< T > &) const
 This function is a fallback for all sub-classes that do not provide such a method. More...
 
size_t size () const
 
- Public Member Functions inherited from h2d::rtp::Root
virtual ~Root ()
 

Friends

template<typename T1 , typename T2 , typename FPT1 , typename FPT2 >
base::LPBase< T1, FPT1 > detail::crossProduct (const base::LPBase< T2, FPT1 > &, const base::LPBase< T2, FPT2 > &)
 
template<typename T1 , typename T2 , typename FPT1 , typename FPT2 >
void detail::product (base::LPBase< T1, FPT1 > &, const detail::Matrix_< FPT2 > &, const base::LPBase< T2, FPT1 > &)
 
template<typename FPT1 , typename FPT2 >
Point2d_< FPT1 > h2d::operator* (const h2d::Line2d_< FPT1 > &, const h2d::Line2d_< FPT2 > &)
 
template<typename FPT1 , typename FPT2 >
auto h2d::operator* (const h2d::Point2d_< FPT1 > &, const h2d::Point2d_< FPT2 > &) -> h2d::Line2d_< FPT1 >
 
template<typename T , typename U >
auto h2d::operator* (const h2d::Homogr_< U > &, const h2d::Line2d_< T > &) -> h2d::Line2d_< T >
 
template<typename U , typename V >
class Hmatrix_
 
template<typename U , typename V >
class LPBase
 
template<typename U , typename V >
auto operator<< (std::ostream &, const h2d::base::LPBase< U, V > &) -> std::ostream &
 
template<typename T1 , typename T2 >
Line2d_< T1 > priv::getOrthogonalLine_B2 (const Point2d_< T2 > &, const Line2d_< T1 > &)
 

Detailed Description

template<typename LP, typename FPT>
class h2d::base::LPBase< LP, FPT >

Base class, will be instanciated as Point2d_ or Line2d_.

Type parameters:

Member Typedef Documentation

◆ FType

template<typename LP, typename FPT>
using h2d::base::LPBase< LP, FPT >::FType = FPT

◆ SType

template<typename LP, typename FPT>
using h2d::base::LPBase< LP, FPT >::SType = LP

Constructor & Destructor Documentation

◆ LPBase() [1/14]

template<typename LP, typename FPT>
template<typename FPT2 >
h2d::base::LPBase< LP, FPT >::LPBase ( const Line2d_< FPT2 > &  v1,
const Line2d_< FPT2 > &  v2 
)
inline

Constructor: build a point from two lines.

3828  {
3829 #ifndef HOMOG2D_NOCHECKS
3830  if( v1.isParallelTo(v2) )
3831  HOMOG2D_THROW_ERROR_1( "unable to build point from these two lines, are parallel" );
3832 #endif
3833  *this = detail::crossProduct<typ::IsPoint>( v1, v2 );
3834  p_normalizePL();
3835  }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181

◆ LPBase() [2/14]

template<typename LP, typename FPT>
template<typename FPT2 >
h2d::base::LPBase< LP, FPT >::LPBase ( const Point2d_< FPT2 > &  v1,
const Point2d_< FPT2 > &  v2 
)
inline

Constructor: build a line from two points.

3840  {
3841 #ifndef HOMOG2D_NOCHECKS
3842  if( v1 == v2 )
3843  HOMOG2D_THROW_ERROR_1( "unable to build line from these two points, are the same: " << v1 );
3844 #endif
3845  *this = detail::crossProduct<typ::IsLine>( v1, v2 );
3846  p_normalizePL();
3847  }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181

◆ LPBase() [3/14]

template<typename LP, typename FPT>
template<typename T >
h2d::base::LPBase< LP, FPT >::LPBase ( const Line2d_< T > &  li)
inline

Constructor: copy-constructor for lines.

Todo:
We should be able to declare this "explicit". This fails at present when attempting to convert a line (or point) from double to float, but I don't get why...
3857  {
3858  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot build a point from a line" );
3859  p_copyFrom( li );
3860  }
Line2d li
Definition: homog2d_test.cpp:4053

◆ LPBase() [4/14]

template<typename LP, typename FPT>
template<typename T >
h2d::base::LPBase< LP, FPT >::LPBase ( const Point2d_< T > &  pt)
inline

Constructor with single arg of type "Point".

This will call one of the two overloads of impl_init_1_Point(), depending on type of object:

  • if type is a point, then it can be seen as a copy-constructor
  • if type is a line, this will build a line from (0,0] to pt
3870  {
3871  impl_init_1_Point<T>( pt );
3872  }
Point2d pt
Definition: homog2d_test.cpp:4052

◆ LPBase() [5/14]

template<typename LP, typename FPT>
template<typename T1 , typename T2 >
h2d::base::LPBase< LP, FPT >::LPBase ( const T1 &  v1,
const T2 &  v2 
)
inline

Constructor: build from two numerical values, depends on the type.

3877  {
3880  p_init_2( v1, v2 );
3881  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144

◆ LPBase() [6/14]

template<typename LP, typename FPT>
template<typename T0 , typename T1 , typename T2 >
h2d::base::LPBase< LP, FPT >::LPBase ( T0  v0,
T1  v1,
T2  v2 
)
inline

Constructor of line/point from 3 values.

3886  {
3887  set( v0, v1, v2 );
3888  }

◆ LPBase() [7/14]

template<typename LP, typename FPT>
template<typename T1 , typename T2 , typename T3 , typename T4 >
h2d::base::LPBase< LP, FPT >::LPBase ( T1  x1,
T2  y1,
T3  x2,
T4  y2 
)
inline

Constructor of line from 4 values x1,y1,x2,y2.

3906  {
3911  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot build a point from 4 values" );
3912  *this = Point2d_<HOMOG2D_INUMTYPE>(x1, y1) * Point2d_<HOMOG2D_INUMTYPE>(x2, y2);
3913  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144

◆ LPBase() [8/14]

template<typename LP, typename FPT>
template<typename T , typename std::enable_if< std::is_same< T, std::array< FPT, 3 >>::value, T >::type * = nullptr>
h2d::base::LPBase< LP, FPT >::LPBase ( const T &  arr)
inline

Constructor from an array holding 3 values of same type (a direct copy can be done)

3939  {
3940  _v = arr;
3941  p_normalizePL();
3942  }

◆ LPBase() [9/14]

template<typename LP, typename FPT>
template<typename T >
h2d::base::LPBase< LP, FPT >::LPBase ( const T &  arr)
inline

Constructor from an array/vector holding 3 values of different type.

3959  {
3960  _v[0] = static_cast<FPT>(arr[0]);
3961  _v[1] = static_cast<FPT>(arr[1]);
3962  _v[2] = static_cast<FPT>(arr[2]);
3963  p_normalizePL();
3964  }

◆ LPBase() [10/14]

template<typename LP, typename FPT>
h2d::base::LPBase< LP, FPT >::LPBase ( )
inline

Default constructor, depends on the type.

3968  {
3969  if constexpr( std::is_same_v<LP,typ::IsLine> )
3970  {
3971  _v[0] = 1.;
3972  _v[1] = 0.;
3973  _v[2] = 0.;
3974  }
3975  else
3976  {
3977  _v[0] = 0.;
3978  _v[1] = 0.;
3979  _v[2] = 1.;
3980  }
3981  }

◆ LPBase() [11/14]

template<typename LP, typename FPT>
template<typename T >
h2d::base::LPBase< LP, FPT >::LPBase ( LineDir  orient,
value 
)
inline

Constructor of horizontal/vertical line.

3986  {
3987  impl_init_or( orient, value );
3988  }

◆ LPBase() [12/14]

template<typename LP, typename FPT>
template<typename BFPT >
h2d::base::LPBase< LP, FPT >::LPBase ( const boost::geometry::model::point< BFPT, 2, boost::geometry::cs::cartesian > &  pt)
inline

Constructor from boost::geometry point type.

Note
Although this one should work also for the other point type (bg::model::d2::point_xy), as that latter one is inherited from the first one), it does not, because there is another truely generic single-arg constructor, and the compiler will select that one first, leading to a build error. Thus, we need the second one.
4004  {
4005  init_BoostGeomPoint( pt );
4006  }
Point2d pt
Definition: homog2d_test.cpp:4052

◆ LPBase() [13/14]

template<typename LP, typename FPT>
template<typename BFPT >
h2d::base::LPBase< LP, FPT >::LPBase ( const boost::geometry::model::d2::point_xy< BFPT > &  pt)
inline

Constructor from boost::geometry second point type.

4011  {
4012  init_BoostGeomPoint( pt );
4013  }
Point2d pt
Definition: homog2d_test.cpp:4052

◆ LPBase() [14/14]

template<typename LP, typename FPT>
template<typename T >
h2d::base::LPBase< LP, FPT >::LPBase ( cv::Point_< T >  pt)
inline

Constructor: build point or line from a single OpenCv point.

4445  {
4446  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4447  {
4448  p_init_2( pt.x, pt.y );
4449  }
4450  else
4451  {
4452  Point2d_<FPT> p(pt);
4453  impl_init_1_Point<FPT>( p );
4454  }
4455  }
Point2d pt
Definition: homog2d_test.cpp:4052

Member Function Documentation

◆ area()

template<typename LP, typename FPT>
constexpr HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::area ( ) const
inlinevirtual

Neither lines nor points have an area.

Implements h2d::rtp::Root.

4278  { return 0.; }
Here is the caller graph for this function:

◆ distTo() [1/3]

template<typename LP , typename FPT >
template<typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::distTo ( const Point2d_< FPT2 > &  pt) const
inline

overload for line to point distance

4228  {
4229  return impl_distToPoint( pt, detail::BaseHelper<LP>() );
4230  }
Point2d pt
Definition: homog2d_test.cpp:4052
Here is the caller graph for this function:

◆ distTo() [2/3]

template<typename LP, typename FPT>
template<typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::distTo ( const Line2d_< FPT2 > &  ) const

◆ distTo() [3/3]

template<typename LP , typename FPT >
template<typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::distTo ( const Segment_< FPT2 > &  seg) const
9195 {
9196  static_assert( !std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot compute distance between a line and a segment" );
9197  return seg.distTo( *this );
9198 }
Segment seg
Definition: homog2d_test.cpp:4051

◆ draw() [1/2]

template<typename LP, typename FPT>
void h2d::base::LPBase< LP, FPT >::draw ( img::Image< img::SvgImage > &  im,
img::DrawParams  dp = img::DrawParams() 
) const
inlinevirtual

SVG draw function.

Implements h2d::rtp::Root.

4419  {
4420  impl_draw_LP( im, dp, detail::BaseHelper<LP>() );
4421  }
img::Image< img::SvgImage > im(300, 400)
Here is the caller graph for this function:

◆ draw() [2/2]

template<typename LP, typename FPT>
void h2d::base::LPBase< LP, FPT >::draw ( img::Image< cv::Mat > &  im,
img::DrawParams  dp = img::DrawParams() 
) const
inlinevirtual

Opencv draw function.

Implements h2d::rtp::Root.

4434  {
4435  impl_draw_LP( im, dp, detail::BaseHelper<LP>() );
4436  }
img::Image< img::SvgImage > im(300, 400)

◆ get()

template<typename LP, typename FPT>
std::array<FPT,3> h2d::base::LPBase< LP, FPT >::get ( ) const
inline
4208  {
4209  return std::array<FPT,3> { _v[0], _v[1], _v[2] };
4210  }
Here is the caller graph for this function:

◆ getAngle() [1/3]

template<typename LP, typename FPT>
template<typename T , typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getAngle ( const LPBase< T, FPT2 > &  other) const
Here is the caller graph for this function:

◆ getAngle() [2/3]

template<typename LP, typename FPT>
template<typename T , typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getAngle ( const base::SegVec< T, FPT2 > &  seg) const
inline

Returns angle in rad. between line and segment seg.

See also
h2d::getAngle()
4252  {
4253  return getAngle( seg.getLine() );
4254  }
Segment seg
Definition: homog2d_test.cpp:4051
HOMOG2D_INUMTYPE getAngle(const LPBase< T, FPT2 > &other) const

◆ getAngle() [3/3]

template<typename LP, typename FPT>
template<typename LP2 , typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getAngle ( const LPBase< LP2, FPT2 > &  li) const

Returns the angle (in rad.) between the line and the other one.

  • The returned value will be in the range [0, M_PI/2]

If the lines \( (a_0,a_1,a_2) \) and \( (b_0,b_1,b_2) \) are correctly normalized (should be, but...) then the angle between them is \( \alpha = acos( a_0*b_0 + a_1*b_1) \).
However, in "some situations", even if the lines have been previously normalized (which is the case here) we can encounter numerical issues, so here we "reinforce the normalization and compute:

\[ \alpha = acos \left( \frac{a_0*b_0 + a_1*b_1} { \sqrt{ a_0^2 + a_1^2 } * \sqrt{ b_0^2 + b_1^2 } } \right) \]

In some situations, the value inside the parenthesis "may" be equal to \( 1+\epsilon \) (typically, something like "1.0000000000123"). This is out of bounds for the \( acos() \) function, that will then return "nan" (thus induce some failure further on).
To avoid this, a checking is done, and any value higher than 1 will be truncated. This is logged on std::cerr so that the user may take that into consideration.

Todo:
more investigation needed ! : what are the exact situation that will lead to this event?
9268 {
9269  static_assert( !std::is_same_v<LP,typ::IsPoint>, "cannot get angle of a point" );
9270 
9271  HOMOG2D_INUMTYPE l1_a = _v[0];
9272  HOMOG2D_INUMTYPE l1_b = _v[1];
9273  HOMOG2D_INUMTYPE l2_a = li._v[0];
9274  HOMOG2D_INUMTYPE l2_b = li._v[1];
9275  HOMOG2D_INUMTYPE res = l1_a * l2_a + l1_b * l2_b;
9276 
9277  res /= homog2d_sqrt( (l1_a*l1_a + l1_b*l1_b) * (l2_a*l2_a + l2_b*l2_b) );
9278  auto fres = homog2d_abs(res);
9279 
9280  if( fres > 1.0 )
9281  {
9283  "homog2d Warning: angle computation overflow detected, value "
9284  << std::scientific << std::setprecision(20)
9285  << fres << ", truncated to 1.0\n input lines:\n l1: "
9286  << *this << "\n l2: " << li
9287  );
9288  fres = 1.0;
9289  }
9290  return homog2d_acos( fres );
9291 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define homog2d_abs
Definition: homog2d.hpp:69
#define homog2d_sqrt
Definition: homog2d.hpp:75
#define HOMOG2D_LOG_WARNING(a)
Definition: homog2d.hpp:151
Line2d li
Definition: homog2d_test.cpp:4053
#define homog2d_acos
Definition: homog2d.hpp:72

◆ getBB()

template<typename LP, typename FPT>
FRect_<HOMOG2D_INUMTYPE> h2d::base::LPBase< LP, FPT >::getBB ( ) const
inline

Needed so the function getBB(T1,T2) builds, whatever the types and because of variant (.

See also
CommonType)
4180  {
4181  HOMOG2D_THROW_ERROR_1( "invalid call, Point/Line has no Bounding Box" );
4182  }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181

◆ getCoord()

template<typename LP , typename FPT >
template<typename FPT2 >
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getCoord ( GivenCoord  gc,
FPT2  other 
) const
8836 {
8837  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
8838 
8839  const auto a = static_cast<HOMOG2D_INUMTYPE>( _v[0] );
8840  const auto b = static_cast<HOMOG2D_INUMTYPE>( _v[1] );
8841  auto denom = ( gc == GivenCoord::X ? b : a );
8842 #ifndef HOMOG2D_NOCHECKS
8843  if( homog2d_abs(denom) < thr::nullDenom() )
8844  HOMOG2D_THROW_ERROR_1( "null denominator encountered" );
8845 #endif
8846  if( gc == GivenCoord::X )
8847  return ( -a * other - _v[2] ) / b;
8848  else
8849  return ( -b * other - _v[2] ) / a;
8850 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define homog2d_abs
Definition: homog2d.hpp:69
static HOMOG2D_INUMTYPE & nullDenom()
Definition: homog2d.hpp:1245
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the caller graph for this function:

◆ getCvPtd()

template<typename LP, typename FPT>
cv::Point2i h2d::base::LPBase< LP, FPT >::getCvPtd ( ) const
inline
4439 { return impl_getPt<cv::Point2d>( detail::BaseHelper<typename typ::IsPoint>() ); }
Here is the caller graph for this function:

◆ getCvPtf()

template<typename LP, typename FPT>
cv::Point2i h2d::base::LPBase< LP, FPT >::getCvPtf ( ) const
inline
4440 { return impl_getPt<cv::Point2f>( detail::BaseHelper<typename typ::IsPoint>() ); }
Here is the caller graph for this function:

◆ getCvPti()

template<typename LP, typename FPT>
cv::Point2i h2d::base::LPBase< LP, FPT >::getCvPti ( ) const
inline
4438 { return impl_getPt<cv::Point2i>( detail::BaseHelper<typename typ::IsPoint>() ); }
Here is the caller graph for this function:

◆ getOrthogLine() [1/2]

template<typename LP , typename FPT >
template<typename FPT2 >
Line2d_< FPT > h2d::base::LPBase< LP, FPT >::getOrthogLine ( GivenCoord  gc,
FPT2  other 
) const

Returns an orthogonal line to the one it is called on, at a point on the line defined by one of its coordinates.

8883 {
8884  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getOrthogLine() on a point" );
8885 
8886  auto other_val = getCoord( gc, val );
8887  Point2d_<HOMOG2D_INUMTYPE> pt( other_val, val ) ;
8888  if( gc == GivenCoord::X )
8889  pt.set( val, other_val );
8890 
8891  return priv::getOrthogonalLine_B2( pt, *this );
8892 }
HOMOG2D_INUMTYPE getCoord(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:8835
Point2d pt
Definition: homog2d_test.cpp:4052
Line2d_< T1 > getOrthogonalLine_B2(const Point2d_< T2 > &pt, const Line2d_< T1 > &li)
Helper function for impl_getOrthogonalLine_A() and impl_getOrthogonalLine_B(), Compute orthogonal lin...
Definition: homog2d.hpp:3740
Here is the caller graph for this function:

◆ getOrthogLine() [2/2]

template<typename LP , typename FPT >
template<typename FPT2 >
Line2d_< FPT > h2d::base::LPBase< LP, FPT >::getOrthogLine ( const Point2d_< FPT2 > &  pt) const

Returns an orthogonal line to the one it is called on, at point pt.

8899 {
8900  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getOrthogLine() on a point" );
8901 
8902 /*
8903 #ifndef HOMOG2D_NOCHECKS
8904  if( this->distTo( pt ) > thr::nullDistance() )
8905  {
8906  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8907  << "> null distance (" << thr::nullDistance() << ")\n";
8908  HOMOG2D_THROW_ERROR_1( "point is not on line" );
8909  }
8910 #endif
8911 */
8912  return priv::getOrthogonalLine_B2( pt, *this );
8913 }
Point2d pt
Definition: homog2d_test.cpp:4052
Line2d_< T1 > getOrthogonalLine_B2(const Point2d_< T2 > &pt, const Line2d_< T1 > &li)
Helper function for impl_getOrthogonalLine_A() and impl_getOrthogonalLine_B(), Compute orthogonal lin...
Definition: homog2d.hpp:3740

◆ getOrthogSegment()

template<typename LP , typename FPT >
template<typename FPT2 >
OSegment_< FPT > h2d::base::LPBase< LP, FPT >::getOrthogSegment ( const Point2d_< FPT2 > &  pt) const

Returns the segment from the point (not on line) to the line, shortest path.

Returns the shortest (oriented) segment that joins a point and a line.

Upon return, the first point will hold the intersection point (projection of point on line), and the second will hold the given point.

8946 {
8947  static_assert( !std::is_same_v<LP,typ::IsPoint>, "Invalid call, cannot compute orthogonal segment between two points" );
8948 
8949  Line2d_<HOMOG2D_INUMTYPE> src = *this; // copy to highest precision
8950  auto dist = src.distTo(pt);
8951 #ifndef HOMOG2D_NOCHECKS
8952  if( dist < thr::nullDistance() ) // sanity check
8953  HOMOG2D_THROW_ERROR_1( "unable to compute segment, distance too small=" << dist );
8954 #endif
8955  auto pair_lines = getParallelLines( dist );
8956 
8957 // determine on which of the two parallel lines does the point lie?
8958  Line2d_<HOMOG2D_INUMTYPE>* pline = &pair_lines.first;
8959  if( pt.distTo(pair_lines.second) < thr::nullDistance() )
8960  pline = &pair_lines.second;
8961 
8962  auto oline = pline->getOrthogLine( pt );
8963  auto p2 = *this * oline;
8964  return OSegment_<FPT>( p2, pt );
8965 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
std::pair< Line2d_< FPT >, Line2d_< FPT > > getParallelLines(T dist) const
Returns the pair of parallel lines at a distance dist from line.
Definition: homog2d.hpp:8988
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Point2d pt
Definition: homog2d_test.cpp:4052

◆ getParallelLine()

template<typename LP , typename FPT >
template<typename FPT2 >
Line2d_< FPT > h2d::base::LPBase< LP, FPT >::getParallelLine ( const Point2d_< FPT2 > &  pt) const

Returns an parallel line to the one it is called on, with pt lying on it.

Returns an parallel line, implementation of getParallelLine().

Todo:
clarify orientation: on which side will that line appear?
8973 {
8974  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getParallelLine() on a point" );
8975 
8976  Line2d_<FPT> out = *this;
8977  out._v[2] = static_cast<HOMOG2D_INUMTYPE>(-_v[0]) * pt.getX() - _v[1] * pt.getY();
8978  out.p_normalizePL();
8979  return out;
8980 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
Point2d pt
Definition: homog2d_test.cpp:4052
Here is the caller graph for this function:

◆ getParallelLines()

template<typename LP , typename FPT >
template<typename T >
std::pair< Line2d_< FPT >, Line2d_< FPT > > h2d::base::LPBase< LP, FPT >::getParallelLines ( dist) const

Returns the pair of parallel lines at a distance dist from line.

Implementation for lines.

8989 {
8990  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getParallelLines() on a point" );
8991 
8992  Line2d_<FPT> l1 = *this;
8993  Line2d_<FPT> l2 = *this;
8994  l1._v[2] = static_cast<HOMOG2D_INUMTYPE>(this->_v[2]) + dist;
8995  l2._v[2] = static_cast<HOMOG2D_INUMTYPE>(this->_v[2]) - dist;
8996  return std::make_pair( l1, l2 );
8997 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
Here is the caller graph for this function:

◆ getPoint()

template<typename LP, typename FPT>
template<typename FPT2 >
Point2d_<FPT> h2d::base::LPBase< LP, FPT >::getPoint ( GivenCoord  gc,
FPT2  other 
) const
inline
4076  {
4077  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
4078  HOMOG2D_CHECK_IS_NUMBER( FPT2 );
4079 
4080  auto coord = getCoord( gc, other );
4081  if( gc == GivenCoord::X )
4082  return Point2d_<FPT>( other, coord );
4083  return Point2d_<FPT>( coord, other );
4084  }
HOMOG2D_INUMTYPE getCoord(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:8835
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
Here is the caller graph for this function:

◆ getPoints() [1/2]

template<typename LP, typename FPT>
template<typename FPT2 , typename FPT3 >
PointPair_<FPT> h2d::base::LPBase< LP, FPT >::getPoints ( GivenCoord  gc,
FPT2  coord,
FPT3  dist 
) const
inline

Returns a pair of points that are lying on line at distance dist from a point defined by one of its coordinates.

4090  {
4091  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
4094 
4095  const auto pt = getPoint( gc, coord );
4096  return priv::getPoints_B2( pt, dist, *this );
4097  }
Point2d_< FPT > getPoint(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:4075
auto getPoints_B2(const Point2d_< FPT > &pt, FPT2 dist, const Line2d_< FPT3 > &li)
Helper function, factorized here for the two impl_getPoints_A() implementations.
Definition: homog2d.hpp:3717
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
Point2d pt
Definition: homog2d_test.cpp:4052
Here is the caller graph for this function:

◆ getPoints() [2/2]

template<typename LP , typename FPT >
template<typename FPT2 , typename FPT3 >
PointPair_< FPT > h2d::base::LPBase< LP, FPT >::getPoints ( const Point2d_< FPT2 > &  pt,
FPT3  dist 
) const

Returns a pair of points that are lying on line at distance dist from point pt, assuming that one is lying on the line.

Returns pair of points on line at distance dist from point on line at coord coord.

8859 {
8860  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
8863 
8864 #ifndef HOMOG2D_NOCHECKS
8865  if( this->distTo( pt ) > thr::nullDistance() )
8866  {
8867  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8868  << " > null distance (" << thr::nullDistance() << ")\n";
8869  HOMOG2D_THROW_ERROR_2( "getPoints", "point is not on line" );
8870  }
8871 #endif
8872 
8873  return priv::getPoints_B2( pt, dist, *this );
8874 }
#define HOMOG2D_THROW_ERROR_2(func, msg)
Error throw wrapper macro, first arg is the function name.
Definition: homog2d.hpp:191
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
auto getPoints_B2(const Point2d_< FPT > &pt, FPT2 dist, const Line2d_< FPT3 > &li)
Helper function, factorized here for the two impl_getPoints_A() implementations.
Definition: homog2d.hpp:3717
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
HOMOG2D_INUMTYPE distTo(const Point2d_< FPT2 > &pt) const
overload for line to point distance
Definition: homog2d.hpp:4227
Point2d pt
Definition: homog2d_test.cpp:4052

◆ getPt()

template<typename LP, typename FPT>
template<typename ANY >
ANY h2d::base::LPBase< LP, FPT >::getPt ( ) const
inline

Generic transformation into any other point type, as long as it provides a 2-args constructor (is the case for Opencv and Boost Geometry).

See also
h2d::getPt()
4203  {
4204  return impl_getPt<ANY>( detail::BaseHelper<LP>() );
4205  }
Here is the caller graph for this function:

◆ getRotatedLine()

template<typename LP , typename FPT >
template<typename FPT2 , typename T >
Line2d_< FPT > h2d::base::LPBase< LP, FPT >::getRotatedLine ( const Point2d_< FPT2 > &  pt,
theta 
) const

Returns a line rotated at point pt with angle theta.

8920 {
8922  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getRotatedLine() on a point" );
8923 
8924 #ifndef HOMOG2D_NOCHECKS
8925  if( this->distTo( pt ) > thr::nullDistance() )
8926  {
8927  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8928  << "> null distance (" << thr::nullDistance() << ")\n";
8929  HOMOG2D_THROW_ERROR_2( "getLineAngle", "point is not on line" );
8930  }
8931 #endif
8932  Homogr_<HOMOG2D_INUMTYPE> H;
8933  H.addTranslation( -pt.getX(), -pt.getY() ).addRotation(theta).addTranslation( pt.getX(), pt.getY() );
8934  return H * *this;
8935 }
#define HOMOG2D_THROW_ERROR_2(func, msg)
Error throw wrapper macro, first arg is the function name.
Definition: homog2d.hpp:191
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
HOMOG2D_INUMTYPE distTo(const Point2d_< FPT2 > &pt) const
overload for line to point distance
Definition: homog2d.hpp:4227
Point2d pt
Definition: homog2d_test.cpp:4052
Here is the caller graph for this function:

◆ getX()

template<typename LP, typename FPT>
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getX ( ) const
inline
4134  {
4135  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot get x for a line" );
4136  return static_cast<HOMOG2D_INUMTYPE>(_v[0]) / _v[2];
4137  }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
Here is the caller graph for this function:

◆ getY()

template<typename LP, typename FPT>
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getY ( ) const
inline
4139  {
4140  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot get y for a line" );
4141  return static_cast<HOMOG2D_INUMTYPE>(_v[1]) / _v[2];
4142  }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
Here is the caller graph for this function:

◆ intersects() [1/7]

template<typename LP, typename FPT>
template<typename FPT2 >
detail::Intersect<detail::Inters_1,FPT> h2d::base::LPBase< LP, FPT >::intersects ( const Line2d_< FPT2 > &  other) const
inline

Line/Line intersection.

4290  {
4291  detail::Intersect<detail::Inters_1,FPT> out;
4292  if( this->isParallelTo( other ) )
4293  return out;
4294  out.set( *this * other );
4295  return out;
4296  }
bool isParallelTo(const Line2d_< FPT2 > &) const
Definition: homog2d.hpp:9232
Here is the caller graph for this function:

◆ intersects() [2/7]

template<typename LP, typename FPT>
template<typename FPT2 >
detail::IntersectM<FPT> h2d::base::LPBase< LP, FPT >::intersects ( const Point2d_< FPT2 > &  pt1,
const Point2d_< FPT2 > &  pt2 
) const
inline

Line/FRect intersection (rectangle defined by pt1 and pt2)

4300  {
4301  return intersects( FRect_<FPT2>( pt1, pt2 ) ) ;
4302  }
detail::Intersect< detail::Inters_1, FPT > intersects(const Line2d_< FPT2 > &other) const
Line/Line intersection.
Definition: homog2d.hpp:4289

◆ intersects() [3/7]

template<typename LP, typename FPT>
template<typename FPT2 >
detail::IntersectM<FPT> h2d::base::LPBase< LP, FPT >::intersects ( const FRect_< FPT2 > &  rect) const
inline

Line/FRect intersection.

4306  {
4307  return impl_intersectsFRect( rect, detail::BaseHelper<LP>() );
4308  }
FRect rect
Definition: homog2d_test.cpp:4056

◆ intersects() [4/7]

template<typename LP, typename FPT>
template<typename SV , typename FPT2 >
detail::Intersect<detail::Inters_1,FPT> h2d::base::LPBase< LP, FPT >::intersects ( const SegVec< SV, FPT2 > &  seg) const
inline

Line/Segment intersection.

Warning
no implementation for points
4314  {
4315  return seg.intersects( *this );
4316  }
Segment seg
Definition: homog2d_test.cpp:4051

◆ intersects() [5/7]

template<typename LP, typename FPT>
template<typename T , typename std::enable_if<(std::is_arithmetic< T >::value &&!std::is_same< T, bool >::value), T >::type * = nullptr>
detail::Intersect<detail::Inters_2,FPT> h2d::base::LPBase< LP, FPT >::intersects ( const Point2d_< FPT > &  pt0,
radius 
) const
inline

Line/Circle intersection.


The Sfinae below is needed to avoid ambiguity with the other 2 args "intersects()" function (with 2 points defining a FRect, see above)

4330  {
4331  return impl_intersectsCircle( pt0, radius, detail::BaseHelper<LP>() );
4332  }
FPT & radius(Circle_< FPT > &cir)
Returns reference on radius of circle (free function), non-const version.
Definition: homog2d.hpp:10920

◆ intersects() [6/7]

template<typename LP, typename FPT>
template<typename T >
detail::Intersect<detail::Inters_2,FPT> h2d::base::LPBase< LP, FPT >::intersects ( const Circle_< T > &  cir) const
inline

Line/Circle intersection.

4337  {
4338  return impl_intersectsCircle( cir.center(), cir.radius(), detail::BaseHelper<LP>() );
4339  }
Circle cir
Definition: homog2d_test.cpp:4054

◆ intersects() [7/7]

template<typename LP, typename FPT>
template<typename PLT , typename FPT2 >
detail::IntersectM<FPT> h2d::base::LPBase< LP, FPT >::intersects ( const base::PolylineBase< PLT, FPT2 > &  pl) const
inline

Line/Polyline intersection.

4344  {
4345  return pl.intersects( *this );
4346  }

◆ isInf()

template<typename LP, typename FPT>
bool h2d::base::LPBase< LP, FPT >::isInf ( ) const
inline

Returns true if point is at infinity (third value less than thr::nullDenom() )

4258  {
4259  if constexpr( std::is_same_v<LP,typ::IsLine> )
4260  return false;
4261  else
4262  return homog2d_abs( _v[2] ) < thr::nullDenom();
4263  }
#define homog2d_abs
Definition: homog2d.hpp:69
static HOMOG2D_INUMTYPE & nullDenom()
Definition: homog2d.hpp:1245
Here is the caller graph for this function:

◆ isInside() [1/6]

template<typename LP, typename FPT>
template<typename T1 , typename T2 >
bool h2d::base::LPBase< LP, FPT >::isInside ( const Point2d_< T1 > &  pt1,
const Point2d_< T2 > &  pt2 
) const
inline

Point is inside flat rectangle.

4351  {
4352  HOMOG2D_START;
4353  return isInside( FRect_<FPT>(pt1, pt2) );
4354  }
#define HOMOG2D_START
Definition: homog2d.hpp:106
bool isInside(const Point2d_< T1 > &pt1, const Point2d_< T2 > &pt2) const
Point is inside flat rectangle.
Definition: homog2d.hpp:4350
Here is the caller graph for this function:

◆ isInside() [2/6]

template<typename LP , typename FPT >
template<typename FPT2 >
bool h2d::base::LPBase< LP, FPT >::isInside ( const FRect_< FPT2 > &  rect) const

Point is inside FRect.

Returns true if point is inside (or on the edge) of a flat rectangle.

9299 {
9300  if constexpr( std::is_same_v<LP,typ::IsLine> )
9301  return false;
9302  else
9303  {
9304  auto pair_pts = rect.getPts();
9305  const auto& p00 = pair_pts.first;
9306  const auto& p11 = pair_pts.second;
9307  return detail::ptIsInside( *this, p00, p11 );
9308  }
9309 }
FRect rect
Definition: homog2d_test.cpp:4056
bool ptIsInside(const Point2d_< FPT1 > &pt, const Point2d_< FPT2 > &p00, const Point2d_< FPT2 > &p11)
Private free function, returns true if point pt is inside the rectangle defined by (p00 ...
Definition: homog2d.hpp:4682

◆ isInside() [3/6]

template<typename LP, typename FPT>
template<typename T , typename std::enable_if< !std::is_same_v< T, Point2d_< FPT >>, T >::type * = nullptr>
bool h2d::base::LPBase< LP, FPT >::isInside ( const Point2d_< FPT > &  center,
radius 
) const
inline

Point is inside circle defined by center and radius.

4370  {
4372 
4373  if constexpr( std::is_same_v<LP,typ::IsLine> )
4374  return false;
4375  else
4376  {
4377  if( distTo( center ) < radius )
4378  return true;
4379  return false;
4380  }
4381  }
Point2d_< FPT > & center(Circle_< FPT > &cir)
Returns reference on center of circle (free function), non-const version.
Definition: homog2d.hpp:10938
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
FPT & radius(Circle_< FPT > &cir)
Returns reference on radius of circle (free function), non-const version.
Definition: homog2d.hpp:10920
HOMOG2D_INUMTYPE distTo(const Point2d_< FPT2 > &pt) const
overload for line to point distance
Definition: homog2d.hpp:4227

◆ isInside() [4/6]

template<typename LP, typename FPT>
template<typename T >
bool h2d::base::LPBase< LP, FPT >::isInside ( const Circle_< T > &  cir) const
inline

Point is inside Circle.

4389  {
4390  return isInside( cir.center(), cir.radius() );
4391  }
bool isInside(const Point2d_< T1 > &pt1, const Point2d_< T2 > &pt2) const
Point is inside flat rectangle.
Definition: homog2d.hpp:4350
Circle cir
Definition: homog2d_test.cpp:4054

◆ isInside() [5/6]

template<typename LP , typename FPT>
template<typename FPT2 >
bool h2d::base::LPBase< LP, FPT >::isInside ( const Ellipse_< FPT2 > &  ell) const

Point is inside Ellipse.

Point is inside Polyline.

9439 {
9440  if constexpr( std::is_same_v<LP,typ::IsPoint> )
9441  return ell.pointIsInside( *this );
9442  else
9443  return false;
9444 }
Ellipse ell
Definition: homog2d_test.cpp:4055

◆ isInside() [6/6]

template<typename LP, typename FPT>
template<typename FPT2 , typename PTYPE >
bool h2d::base::LPBase< LP, FPT >::isInside ( const base::PolylineBase< PTYPE, FPT2 > &  poly) const
inline
4399  {
4400  HOMOG2D_START;
4401  return impl_isInsidePoly( poly, detail::BaseHelper<LP>() );
4402  }
#define HOMOG2D_START
Definition: homog2d.hpp:106

◆ isParallelTo() [1/2]

template<typename LP , typename FPT >
template<typename FPT2 >
bool h2d::base::LPBase< LP, FPT >::isParallelTo ( const Line2d_< FPT2 > &  li) const
9233 {
9234  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot use IsParallel() with a point" );
9235 
9236  if( this->getAngle(li) < thr::nullAngleValue() )
9237  return true;
9238  return false;
9239 }
HOMOG2D_INUMTYPE getAngle(const LPBase< T, FPT2 > &other) const
Line2d li
Definition: homog2d_test.cpp:4053
static HOMOG2D_INUMTYPE & nullAngleValue()
Definition: homog2d.hpp:1239
Here is the caller graph for this function:

◆ isParallelTo() [2/2]

template<typename LP, typename FPT>
template<typename T >
bool h2d::base::LPBase< LP, FPT >::isParallelTo ( const Segment_< T > &  seg) const
inline
4242  {
4243  return isParallelTo( seg.getLine() );
4244  }
Segment seg
Definition: homog2d_test.cpp:4051
bool isParallelTo(const Line2d_< FPT2 > &) const
Definition: homog2d.hpp:9232

◆ length()

template<typename LP, typename FPT>
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::length ( ) const
inlinevirtual

A point has a null length, a line has an infinite length.

Implements h2d::rtp::Root.

4267  {
4268  if constexpr( std::is_same_v<LP,typ::IsLine> )
4269  {
4270  HOMOG2D_THROW_ERROR_1( "unable, a line has an infinite length" );
4271  }
4272  else
4273  return 0.;
4274  }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the caller graph for this function:

◆ moveTo()

template<typename LP, typename FPT>
template<typename T1 >
void h2d::base::LPBase< LP, FPT >::moveTo ( const Point2d_< T1 > &  pt)
inline

Move point to other location (same as set(), but this one will be virtual). Does nothing for lines => NO, FAILS TO BUILD !

4171  {
4172  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot move a line" );
4173  *this = pt;
4174  }
Point2d pt
Definition: homog2d_test.cpp:4052

◆ operator!=()

template<typename LP, typename FPT>
bool h2d::base::LPBase< LP, FPT >::operator!= ( const base::LPBase< LP, FPT > &  other) const
inline
4412  {
4413  return !(*this == other);
4414  }

◆ operator<()

template<typename LP, typename FPT>
bool h2d::base::LPBase< LP, FPT >::operator< ( const base::LPBase< LP, FPT > &  other) const

Sorting operator, for points (illegal for lines)

9033 {
9034  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid < operator: you cannot sort lines" );
9035 
9036  if( getX() < other.getX() )
9037  return true;
9038  if( getX() > other.getX() )
9039  return false;
9040  if( getY() < other.getY() )
9041  return true;
9042  return false;
9043 }
HOMOG2D_INUMTYPE getX() const
Definition: homog2d.hpp:4133
HOMOG2D_INUMTYPE getY() const
Definition: homog2d.hpp:4138

◆ operator==()

template<typename LP, typename FPT>
bool h2d::base::LPBase< LP, FPT >::operator== ( const base::LPBase< LP, FPT > &  other) const
inline
4408  {
4409  return impl_op_equal( other, detail::BaseHelper<LP>() );
4410  }

◆ set() [1/3]

template<typename LP, typename FPT>
template<typename T0 , typename T1 , typename T2 >
void h2d::base::LPBase< LP, FPT >::set ( T0  v0,
T1  v1,
T2  v2 
)
inline

Assign homogeneous values.

3893  {
3897  _v[0] = v0;
3898  _v[1] = v1;
3899  _v[2] = v2;
3900  p_normalizePL();
3901  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
Here is the caller graph for this function:

◆ set() [2/3]

template<typename LP, typename FPT>
template<typename BFPT >
void h2d::base::LPBase< LP, FPT >::set ( const boost::geometry::model::point< BFPT, 2, boost::geometry::cs::cartesian > &  pt)
inline

Set from boost::geometry point type.

4018  {
4019  set( boost::geometry::get<0>(pt), boost::geometry::get<1>(pt), 1.0 );
4020  }
Point2d pt
Definition: homog2d_test.cpp:4052

◆ set() [3/3]

template<typename LP, typename FPT>
template<typename T1 , typename T2 >
void h2d::base::LPBase< LP, FPT >::set ( T1  x,
T2  y 
)
inline

Set point from 2 euclidean values.

4215  {
4218  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid call for lines" );
4219 
4220  _v[0] = x;
4221  _v[1] = y;
4222  _v[2] = 1.;
4223  p_normalizePL();
4224  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144

◆ size()

template<typename LP, typename FPT>
size_t h2d::base::LPBase< LP, FPT >::size ( ) const
inlinevirtual

Implements h2d::rtp::Root.

4062  {
4063  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4064  return 1;
4065  else
4066  return 0;
4067  }
Here is the caller graph for this function:

◆ translate() [1/2]

template<typename LP, typename FPT>
template<typename T1 , typename T2 >
void h2d::base::LPBase< LP, FPT >::translate ( T1  dx,
T2  dy 
)
inline

Translate Point2d, does nothing for Line2d.

4147  {
4150 
4151  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4152  {
4153  _v[0] = static_cast<HOMOG2D_INUMTYPE>(_v[0]) / _v[2] + dx;
4154  _v[1] = static_cast<HOMOG2D_INUMTYPE>(_v[1]) / _v[2] + dy;
4155  _v[2] = 1.;
4156  p_normalizePL();
4157  }
4158  }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
Here is the caller graph for this function:

◆ translate() [2/2]

template<typename LP, typename FPT>
template<typename T1 , typename T2 >
void h2d::base::LPBase< LP, FPT >::translate ( const std::pair< T1, T2 > &  pa)
inline

Translate Point2d, does nothing for Line2d.

4163  {
4164  this->translate( pa.first, pa.second );
4165  }
void translate(T1 dx, T2 dy)
Translate Point2d, does nothing for Line2d.
Definition: homog2d.hpp:4146

◆ type()

template<typename LP, typename FPT>
Type h2d::base::LPBase< LP, FPT >::type ( ) const
inlinevirtual

Implements h2d::rtp::Root.

4054  {
4055  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4056  return Type::Point2d;
4057  else
4058  return Type::Line2d;
4059  }
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ detail::crossProduct

template<typename LP, typename FPT>
template<typename T1 , typename T2 , typename FPT1 , typename FPT2 >
base::LPBase<T1,FPT1> detail::crossProduct ( const base::LPBase< T2, FPT1 > &  ,
const base::LPBase< T2, FPT2 > &   
)
friend

◆ detail::product

template<typename LP, typename FPT>
template<typename T1 , typename T2 , typename FPT1 , typename FPT2 >
void detail::product ( base::LPBase< T1, FPT1 > &  ,
const detail::Matrix_< FPT2 > &  ,
const base::LPBase< T2, FPT1 > &   
)
friend

◆ h2d::operator* [1/3]

template<typename LP, typename FPT>
template<typename FPT1 , typename FPT2 >
Point2d_<FPT1> h2d::operator* ( const h2d::Line2d_< FPT1 > &  ,
const h2d::Line2d_< FPT2 > &   
)
friend

◆ h2d::operator* [2/3]

template<typename LP, typename FPT>
template<typename FPT1 , typename FPT2 >
auto h2d::operator* ( const h2d::Point2d_< FPT1 > &  ,
const h2d::Point2d_< FPT2 > &   
) -> h2d::Line2d_< FPT1 >
friend

◆ h2d::operator* [3/3]

template<typename LP, typename FPT>
template<typename T , typename U >
auto h2d::operator* ( const h2d::Homogr_< U > &  ,
const h2d::Line2d_< T > &   
) -> h2d::Line2d_< T >
friend

◆ Hmatrix_

template<typename LP, typename FPT>
template<typename U , typename V >
friend class Hmatrix_
friend

◆ LPBase

template<typename LP, typename FPT>
template<typename U , typename V >
friend class LPBase
friend

◆ operator<<

template<typename LP, typename FPT>
template<typename U , typename V >
auto operator<< ( std::ostream &  ,
const h2d::base::LPBase< U, V > &   
) -> std::ostream &
friend

◆ priv::getOrthogonalLine_B2

template<typename LP, typename FPT>
template<typename T1 , typename T2 >
Line2d_<T1> priv::getOrthogonalLine_B2 ( const Point2d_< T2 > &  ,
const Line2d_< T1 > &   
)
friend

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