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 FPT2 >
detail::Intersect< detail::Inters_1, FPT > intersects (const Segment_< 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.

3825  {
3826 #ifndef HOMOG2D_NOCHECKS
3827  if( v1.isParallelTo(v2) )
3828  HOMOG2D_THROW_ERROR_1( "unable to build point from these two lines, are parallel" );
3829 #endif
3830  *this = detail::crossProduct<typ::IsPoint>( v1, v2 );
3831  p_normalizePL();
3832  }
#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.

3837  {
3838 #ifndef HOMOG2D_NOCHECKS
3839  if( v1 == v2 )
3840  HOMOG2D_THROW_ERROR_1( "unable to build line from these two points, are the same: " << v1 );
3841 #endif
3842  *this = detail::crossProduct<typ::IsLine>( v1, v2 );
3843  p_normalizePL();
3844  }
#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...
3854  {
3855  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot build a point from a line" );
3856  p_copyFrom( li );
3857  }
Line2d li
Definition: homog2d_test.cpp:4035

◆ 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
3867  {
3868  impl_init_1_Point<T>( pt );
3869  }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ 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.

3874  {
3877  p_init_2( v1, v2 );
3878  }
#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.

3883  {
3884  set( v0, v1, v2 );
3885  }

◆ 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.

3903  {
3908  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot build a point from 4 values" );
3909  *this = Point2d_<HOMOG2D_INUMTYPE>(x1, y1) * Point2d_<HOMOG2D_INUMTYPE>(x2, y2);
3910  }
#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)

3936  {
3937  _v = arr;
3938  p_normalizePL();
3939  }

◆ 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.

3956  {
3957  _v[0] = static_cast<FPT>(arr[0]);
3958  _v[1] = static_cast<FPT>(arr[1]);
3959  _v[2] = static_cast<FPT>(arr[2]);
3960  p_normalizePL();
3961  }

◆ LPBase() [10/14]

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

Default constructor, depends on the type.

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

◆ 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.

3983  {
3984  impl_init_or( orient, value );
3985  }

◆ 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.
4001  {
4002  init_BoostGeomPoint( pt );
4003  }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ 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.

4008  {
4009  init_BoostGeomPoint( pt );
4010  }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ 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.

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

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.

4275  { 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

4225  {
4226  return impl_distToPoint( pt, detail::BaseHelper<LP>() );
4227  }
Point2d pt
Definition: homog2d_test.cpp:4034
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
9192 {
9193  static_assert( !std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot compute distance between a line and a segment" );
9194  return seg.distTo( *this );
9195 }
Segment seg
Definition: homog2d_test.cpp:4033

◆ 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.

4416  {
4417  impl_draw_LP( im, dp, detail::BaseHelper<LP>() );
4418  }
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.

4431  {
4432  impl_draw_LP( im, dp, detail::BaseHelper<LP>() );
4433  }
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
4205  {
4206  return std::array<FPT,3> { _v[0], _v[1], _v[2] };
4207  }
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()
4249  {
4250  return getAngle( seg.getLine() );
4251  }
Segment seg
Definition: homog2d_test.cpp:4033
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?
9265 {
9266  static_assert( !std::is_same_v<LP,typ::IsPoint>, "cannot get angle of a point" );
9267 
9268  HOMOG2D_INUMTYPE l1_a = _v[0];
9269  HOMOG2D_INUMTYPE l1_b = _v[1];
9270  HOMOG2D_INUMTYPE l2_a = li._v[0];
9271  HOMOG2D_INUMTYPE l2_b = li._v[1];
9272  HOMOG2D_INUMTYPE res = l1_a * l2_a + l1_b * l2_b;
9273 
9274  res /= homog2d_sqrt( (l1_a*l1_a + l1_b*l1_b) * (l2_a*l2_a + l2_b*l2_b) );
9275  auto fres = homog2d_abs(res);
9276 
9277  if( fres > 1.0 )
9278  {
9280  "homog2d Warning: angle computation overflow detected, value "
9281  << std::scientific << std::setprecision(20)
9282  << fres << ", truncated to 1.0\n input lines:\n l1: "
9283  << *this << "\n l2: " << li
9284  );
9285  fres = 1.0;
9286  }
9287  return homog2d_acos( fres );
9288 }
#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:4035
#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)
4177  {
4178  HOMOG2D_THROW_ERROR_1( "invalid call, Point/Line has no Bounding Box" );
4179  }
#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
8833 {
8834  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
8835 
8836  const auto a = static_cast<HOMOG2D_INUMTYPE>( _v[0] );
8837  const auto b = static_cast<HOMOG2D_INUMTYPE>( _v[1] );
8838  auto denom = ( gc == GivenCoord::X ? b : a );
8839 #ifndef HOMOG2D_NOCHECKS
8840  if( homog2d_abs(denom) < thr::nullDenom() )
8841  HOMOG2D_THROW_ERROR_1( "null denominator encountered" );
8842 #endif
8843  if( gc == GivenCoord::X )
8844  return ( -a * other - _v[2] ) / b;
8845  else
8846  return ( -b * other - _v[2] ) / a;
8847 }
#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
4436 { 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
4437 { 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
4435 { 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.

8880 {
8881  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getOrthogLine() on a point" );
8882 
8883  auto other_val = getCoord( gc, val );
8884  Point2d_<HOMOG2D_INUMTYPE> pt( other_val, val ) ;
8885  if( gc == GivenCoord::X )
8886  pt.set( val, other_val );
8887 
8888  return priv::getOrthogonalLine_B2( pt, *this );
8889 }
HOMOG2D_INUMTYPE getCoord(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:8832
Point2d pt
Definition: homog2d_test.cpp:4034
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:3737
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.

8896 {
8897  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getOrthogLine() on a point" );
8898 
8899 /*
8900 #ifndef HOMOG2D_NOCHECKS
8901  if( this->distTo( pt ) > thr::nullDistance() )
8902  {
8903  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8904  << "> null distance (" << thr::nullDistance() << ")\n";
8905  HOMOG2D_THROW_ERROR_1( "point is not on line" );
8906  }
8907 #endif
8908 */
8909  return priv::getOrthogonalLine_B2( pt, *this );
8910 }
Point2d pt
Definition: homog2d_test.cpp:4034
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:3737

◆ 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.

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

◆ 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?
8970 {
8971  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getParallelLine() on a point" );
8972 
8973  Line2d_<FPT> out = *this;
8974  out._v[2] = static_cast<HOMOG2D_INUMTYPE>(-_v[0]) * pt.getX() - _v[1] * pt.getY();
8975  out.p_normalizePL();
8976  return out;
8977 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
Point2d pt
Definition: homog2d_test.cpp:4034
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.

8986 {
8987  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getParallelLines() on a point" );
8988 
8989  Line2d_<FPT> l1 = *this;
8990  Line2d_<FPT> l2 = *this;
8991  l1._v[2] = static_cast<HOMOG2D_INUMTYPE>(this->_v[2]) + dist;
8992  l2._v[2] = static_cast<HOMOG2D_INUMTYPE>(this->_v[2]) - dist;
8993  return std::make_pair( l1, l2 );
8994 }
#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:9848
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
4073  {
4074  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
4075  HOMOG2D_CHECK_IS_NUMBER( FPT2 );
4076 
4077  auto coord = getCoord( gc, other );
4078  if( gc == GivenCoord::X )
4079  return Point2d_<FPT>( other, coord );
4080  return Point2d_<FPT>( coord, other );
4081  }
HOMOG2D_INUMTYPE getCoord(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:8832
#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.

4087  {
4088  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
4091 
4092  const auto pt = getPoint( gc, coord );
4093  return priv::getPoints_B2( pt, dist, *this );
4094  }
Point2d_< FPT > getPoint(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:4072
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:3714
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9848
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
Point2d pt
Definition: homog2d_test.cpp:4034
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.

8856 {
8857  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
8860 
8861 #ifndef HOMOG2D_NOCHECKS
8862  if( this->distTo( pt ) > thr::nullDistance() )
8863  {
8864  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8865  << " > null distance (" << thr::nullDistance() << ")\n";
8866  HOMOG2D_THROW_ERROR_2( "getPoints", "point is not on line" );
8867  }
8868 #endif
8869 
8870  return priv::getPoints_B2( pt, dist, *this );
8871 }
#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:3714
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9848
#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:4224
Point2d pt
Definition: homog2d_test.cpp:4034

◆ 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()
4200  {
4201  return impl_getPt<ANY>( detail::BaseHelper<LP>() );
4202  }
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.

8917 {
8919  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getRotatedLine() on a point" );
8920 
8921 #ifndef HOMOG2D_NOCHECKS
8922  if( this->distTo( pt ) > thr::nullDistance() )
8923  {
8924  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8925  << "> null distance (" << thr::nullDistance() << ")\n";
8926  HOMOG2D_THROW_ERROR_2( "getLineAngle", "point is not on line" );
8927  }
8928 #endif
8929  Homogr_<HOMOG2D_INUMTYPE> H;
8930  H.addTranslation( -pt.getX(), -pt.getY() ).addRotation(theta).addTranslation( pt.getX(), pt.getY() );
8931  return H * *this;
8932 }
#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:4224
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the caller graph for this function:

◆ getX()

template<typename LP, typename FPT>
HOMOG2D_INUMTYPE h2d::base::LPBase< LP, FPT >::getX ( ) const
inline
4131  {
4132  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot get x for a line" );
4133  return static_cast<HOMOG2D_INUMTYPE>(_v[0]) / _v[2];
4134  }
#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
4136  {
4137  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot get y for a line" );
4138  return static_cast<HOMOG2D_INUMTYPE>(_v[1]) / _v[2];
4139  }
#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.

4287  {
4288  detail::Intersect<detail::Inters_1,FPT> out;
4289  if( this->isParallelTo( other ) )
4290  return out;
4291  out.set( *this * other );
4292  return out;
4293  }
bool isParallelTo(const Line2d_< FPT2 > &) const
Definition: homog2d.hpp:9229
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)

4297  {
4298  return intersects( FRect_<FPT2>( pt1, pt2 ) ) ;
4299  }
detail::Intersect< detail::Inters_1, FPT > intersects(const Line2d_< FPT2 > &other) const
Line/Line intersection.
Definition: homog2d.hpp:4286

◆ 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.

4303  {
4304  return impl_intersectsFRect( rect, detail::BaseHelper<LP>() );
4305  }
FRect rect
Definition: homog2d_test.cpp:4038

◆ intersects() [4/7]

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

Line/Segment intersection.

Warning
no implementation for points
4311  {
4312  return seg.intersects( *this );
4313  }
Segment seg
Definition: homog2d_test.cpp:4033

◆ 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)

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

◆ 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.

4334  {
4335  return impl_intersectsCircle( cir.center(), cir.radius(), detail::BaseHelper<LP>() );
4336  }
Circle cir
Definition: homog2d_test.cpp:4036

◆ 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.

4341  {
4342  return pl.intersects( *this );
4343  }

◆ 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() )

4255  {
4256  if constexpr( std::is_same_v<LP,typ::IsLine> )
4257  return false;
4258  else
4259  return homog2d_abs( _v[2] ) < thr::nullDenom();
4260  }
#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.

4348  {
4349  HOMOG2D_START;
4350  return isInside( FRect_<FPT>(pt1, pt2) );
4351  }
#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:4347
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.

9296 {
9297  if constexpr( std::is_same_v<LP,typ::IsLine> )
9298  return false;
9299  else
9300  {
9301  auto pair_pts = rect.getPts();
9302  const auto& p00 = pair_pts.first;
9303  const auto& p11 = pair_pts.second;
9304  return detail::ptIsInside( *this, p00, p11 );
9305  }
9306 }
FRect rect
Definition: homog2d_test.cpp:4038
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:4679

◆ 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.

4367  {
4369 
4370  if constexpr( std::is_same_v<LP,typ::IsLine> )
4371  return false;
4372  else
4373  {
4374  if( distTo( center ) < radius )
4375  return true;
4376  return false;
4377  }
4378  }
Point2d_< FPT > & center(Circle_< FPT > &cir)
Returns reference on center of circle (free function), non-const version.
Definition: homog2d.hpp:10935
#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:10917
HOMOG2D_INUMTYPE distTo(const Point2d_< FPT2 > &pt) const
overload for line to point distance
Definition: homog2d.hpp:4224

◆ 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.

4386  {
4387  return isInside( cir.center(), cir.radius() );
4388  }
bool isInside(const Point2d_< T1 > &pt1, const Point2d_< T2 > &pt2) const
Point is inside flat rectangle.
Definition: homog2d.hpp:4347
Circle cir
Definition: homog2d_test.cpp:4036

◆ 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.

9436 {
9437  if constexpr( std::is_same_v<LP,typ::IsPoint> )
9438  return ell.pointIsInside( *this );
9439  else
9440  return false;
9441 }
Ellipse ell
Definition: homog2d_test.cpp:4037

◆ 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
4396  {
4397  HOMOG2D_START;
4398  return impl_isInsidePoly( poly, detail::BaseHelper<LP>() );
4399  }
#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
9230 {
9231  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot use IsParallel() with a point" );
9232 
9233  if( this->getAngle(li) < thr::nullAngleValue() )
9234  return true;
9235  return false;
9236 }
HOMOG2D_INUMTYPE getAngle(const LPBase< T, FPT2 > &other) const
Line2d li
Definition: homog2d_test.cpp:4035
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
4239  {
4240  return isParallelTo( seg.getLine() );
4241  }
Segment seg
Definition: homog2d_test.cpp:4033
bool isParallelTo(const Line2d_< FPT2 > &) const
Definition: homog2d.hpp:9229

◆ 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.

4264  {
4265  if constexpr( std::is_same_v<LP,typ::IsLine> )
4266  {
4267  HOMOG2D_THROW_ERROR_1( "unable, a line has an infinite length" );
4268  }
4269  else
4270  return 0.;
4271  }
#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 !

4168  {
4169  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot move a line" );
4170  *this = pt;
4171  }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ operator!=()

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

◆ 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)

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

◆ operator==()

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

◆ 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.

3890  {
3894  _v[0] = v0;
3895  _v[1] = v1;
3896  _v[2] = v2;
3897  p_normalizePL();
3898  }
#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.

4015  {
4016  set( boost::geometry::get<0>(pt), boost::geometry::get<1>(pt), 1.0 );
4017  }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ 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.

4212  {
4215  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid call for lines" );
4216 
4217  _v[0] = x;
4218  _v[1] = y;
4219  _v[2] = 1.;
4220  p_normalizePL();
4221  }
#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.

4059  {
4060  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4061  return 1;
4062  else
4063  return 0;
4064  }
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.

4144  {
4147 
4148  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4149  {
4150  _v[0] = static_cast<HOMOG2D_INUMTYPE>(_v[0]) / _v[2] + dx;
4151  _v[1] = static_cast<HOMOG2D_INUMTYPE>(_v[1]) / _v[2] + dy;
4152  _v[2] = 1.;
4153  p_normalizePL();
4154  }
4155  }
#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.

4160  {
4161  this->translate( pa.first, pa.second );
4162  }
void translate(T1 dx, T2 dy)
Translate Point2d, does nothing for Line2d.
Definition: homog2d.hpp:4143

◆ type()

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

Implements h2d::rtp::Root.

4051  {
4052  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4053  return Type::Point2d;
4054  else
4055  return Type::Line2d;
4056  }
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: