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.

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

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

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

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

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

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

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

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

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

◆ LPBase() [10/14]

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

Default constructor, depends on the type.

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

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

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

◆ 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.
4000  {
4001  init_BoostGeomPoint( pt );
4002  }
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.

4007  {
4008  init_BoostGeomPoint( pt );
4009  }
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.

4441  {
4442  if constexpr( std::is_same_v<LP,typ::IsPoint> )
4443  {
4444  p_init_2( pt.x, pt.y );
4445  }
4446  else
4447  {
4448  Point2d_<FPT> p(pt);
4449  impl_init_1_Point<FPT>( p );
4450  }
4451  }
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.

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

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

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

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

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

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

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

8942 {
8943  static_assert( !std::is_same_v<LP,typ::IsPoint>, "Invalid call, cannot compute orthogonal segment between two points" );
8944 
8945  Line2d_<HOMOG2D_INUMTYPE> src = *this; // copy to highest precision
8946  auto dist = src.distTo(pt);
8947 #ifndef HOMOG2D_NOCHECKS
8948  if( dist < thr::nullDistance() ) // sanity check
8949  HOMOG2D_THROW_ERROR_1( "unable to compute segment, distance too small=" << dist );
8950 #endif
8951  auto pair_lines = getParallelLines( dist );
8952 
8953 // determine on which of the two parallel lines does the point lie?
8954  Line2d_<HOMOG2D_INUMTYPE>* pline = &pair_lines.first;
8955  if( pt.distTo(pair_lines.second) < thr::nullDistance() )
8956  pline = &pair_lines.second;
8957 
8958  auto oline = pline->getOrthogLine( pt );
8959  auto p2 = *this * oline;
8960  return OSegment_<FPT>( p2, pt );
8961 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1195
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:8984
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
#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?
8969 {
8970  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getParallelLine() on a point" );
8971 
8972  Line2d_<FPT> out = *this;
8973  out._v[2] = static_cast<HOMOG2D_INUMTYPE>(-_v[0]) * pt.getX() - _v[1] * pt.getY();
8974  out.p_normalizePL();
8975  return out;
8976 }
#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.

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

4086  {
4087  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
4090 
4091  const auto pt = getPoint( gc, coord );
4092  return priv::getPoints_B2( pt, dist, *this );
4093  }
Point2d_< FPT > getPoint(GivenCoord gc, FPT2 other) const
Definition: homog2d.hpp:4071
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:3679
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
#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.

8855 {
8856  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call on a point" );
8859 
8860 #ifndef HOMOG2D_NOCHECKS
8861  if( this->distTo( pt ) > thr::nullDistance() )
8862  {
8863  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8864  << " > null distance (" << thr::nullDistance() << ")\n";
8865  HOMOG2D_THROW_ERROR_2( "getPoints", "point is not on line" );
8866  }
8867 #endif
8868 
8869  return priv::getPoints_B2( pt, dist, *this );
8870 }
#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:1195
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:3679
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
#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:4223
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()
4199  {
4200  return impl_getPt<ANY>( detail::BaseHelper<LP>() );
4201  }
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.

8916 {
8918  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot call getRotatedLine() on a point" );
8919 
8920 #ifndef HOMOG2D_NOCHECKS
8921  if( this->distTo( pt ) > thr::nullDistance() )
8922  {
8923  std::cerr << "homog2d: distance=" << std::scientific << this->distTo( pt )
8924  << "> null distance (" << thr::nullDistance() << ")\n";
8925  HOMOG2D_THROW_ERROR_2( "getLineAngle", "point is not on line" );
8926  }
8927 #endif
8928  Homogr_<HOMOG2D_INUMTYPE> H;
8929  H.addTranslation( -pt.getX(), -pt.getY() ).addRotation(theta).addTranslation( pt.getX(), pt.getY() );
8930  return H * *this;
8931 }
#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:1195
#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:4223
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
4130  {
4131  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot get x for a line" );
4132  return static_cast<HOMOG2D_INUMTYPE>(_v[0]) / _v[2];
4133  }
#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
4135  {
4136  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot get y for a line" );
4137  return static_cast<HOMOG2D_INUMTYPE>(_v[1]) / _v[2];
4138  }
#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.

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

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

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

4302  {
4303  return impl_intersectsFRect( rect, detail::BaseHelper<LP>() );
4304  }
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
4310  {
4311  return seg.intersects( *this );
4312  }
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)

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

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

4333  {
4334  return impl_intersectsCircle( cir.center(), cir.radius(), detail::BaseHelper<LP>() );
4335  }
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.

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

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

4254  {
4255  if constexpr( std::is_same_v<LP,typ::IsLine> )
4256  return false;
4257  else
4258  return homog2d_abs( _v[2] ) < thr::nullDenom();
4259  }
#define homog2d_abs
Definition: homog2d.hpp:69
static HOMOG2D_INUMTYPE & nullDenom()
Definition: homog2d.hpp:1211
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.

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

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

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

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

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

4385  {
4386  return isInside( cir.center(), cir.radius() );
4387  }
bool isInside(const Point2d_< T1 > &pt1, const Point2d_< T2 > &pt2) const
Point is inside flat rectangle.
Definition: homog2d.hpp:4346
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.

9435 {
9436  if constexpr( std::is_same_v<LP,typ::IsPoint> )
9437  return ell.pointIsInside( *this );
9438  else
9439  return false;
9440 }
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
4395  {
4396  HOMOG2D_START;
4397  return impl_isInsidePoly( poly, detail::BaseHelper<LP>() );
4398  }
#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
9229 {
9230  static_assert( std::is_same_v<LP,typ::IsLine>, "Invalid: you cannot use IsParallel() with a point" );
9231 
9232  if( this->getAngle(li) < thr::nullAngleValue() )
9233  return true;
9234  return false;
9235 }
HOMOG2D_INUMTYPE getAngle(const LPBase< T, FPT2 > &other) const
Line2d li
Definition: homog2d_test.cpp:4035
static HOMOG2D_INUMTYPE & nullAngleValue()
Definition: homog2d.hpp:1205
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
4238  {
4239  return isParallelTo( seg.getLine() );
4240  }
Segment seg
Definition: homog2d_test.cpp:4033
bool isParallelTo(const Line2d_< FPT2 > &) const
Definition: homog2d.hpp:9228

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

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

4167  {
4168  static_assert( std::is_same_v<LP,typ::IsPoint>, "Invalid: cannot move a line" );
4169  *this = pt;
4170  }
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
4408  {
4409  return !(*this == other);
4410  }

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

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

◆ operator==()

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

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

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

4014  {
4015  set( boost::geometry::get<0>(pt), boost::geometry::get<1>(pt), 1.0 );
4016  }
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.

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

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

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

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

◆ type()

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

Implements h2d::rtp::Root.

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