homog2d library
Namespaces | Classes | Typedefs | Enumerations | Functions
h2d Namespace Reference

Namespaces

 base
 Holds base classes, not part of API.
 
 detail
 This namespace holds some private stuff, types here are not to be used directly by end-user code.
 
 err
 Holds static counters, for runtime errors and warnings.
 
 fct
 Holds functors, used to manage runtime polymorphism using std::variant. See https://github.com/skramm/homog2d/blob/master/docs/homog2d_manual.md#section_rtp.
 
 img
 Holds drawing related code, independent of back-end library.
 
 ppair
 Holds free functions returning a pair of points.
 
 priv
 Holds private stuff.
 
 rtp
 Holds pointer-based runtime polymorphism stuff.
 
 svg
 Holds stuff related to SVG import.
 
 thr
 Holds threshold values and api to access these.
 
 trait
 Holds traits classes.
 
 typ
 Holds the types needed for policy based design.
 

Classes

class  Circle_
 A circle. More...
 
class  Ellipse_
 Ellipse as a conic in matrix form. More...
 
class  FRect_
 A Flat Rectangle, modeled by its two opposite points. More...
 
class  Hmatrix_
 A 2D homography, defining a planar transformation. More...
 
struct  OffsetPolyParams
 Parameters for base::PolylineBase::getOffsetPoly() More...
 

Typedefs

using Circle = Circle_< HOMOG2D_INUMTYPE >
 Default circle type. More...
 
using CircleD = Circle_< double >
 
using CircleF = Circle_< float >
 
using CircleL = Circle_< long double >
 
using CommonType = CommonType_< HOMOG2D_INUMTYPE >
 
template<typename FPT >
using CommonType_ = std::variant< Segment_< FPT >, OSegment_< FPT >, Point2d_< FPT >, Line2d_< FPT >, Circle_< FPT >, Ellipse_< FPT >, FRect_< FPT >, CPolyline_< FPT >, OPolyline_< FPT > >
 A variant type, holding all possible types. Used to achieve runtime polymorphism. More...
 
using CommonTypeD = CommonType_< double >
 
using CommonTypeF = CommonType_< float >
 
using CommonTypeL = CommonType_< long double >
 
using CPolyline = CPolyline_< HOMOG2D_INUMTYPE >
 Default polyline type. More...
 
template<typename T >
using CPolyline_ = base::PolylineBase< typ::IsClosed, T >
 
using CPolylineD = CPolyline_< double >
 
using CPolylineF = CPolyline_< float >
 
using CPolylineL = CPolyline_< long double >
 
using Ellipse = Ellipse_< HOMOG2D_INUMTYPE >
 Default ellipse type. More...
 
using EllipseD = Ellipse_< double >
 
using EllipseF = Ellipse_< float >
 
using EllipseL = Ellipse_< long double >
 
using Epipmat = Hmatrix_< typ::IsEpipmat, HOMOG2D_INUMTYPE >
 Default homogeneous matrix, uses double as numerical type. More...
 
using FRect = FRect_< HOMOG2D_INUMTYPE >
 Default rectangle type. More...
 
using FRectD = FRect_< double >
 
using FRectF = FRect_< float >
 
using FRectL = FRect_< long double >
 
using Homogr = Homogr_< HOMOG2D_INUMTYPE >
 Default homography (3x3 matrix) type, uses double as numerical type. More...
 
template<typename T >
using Homogr_ = Hmatrix_< typ::IsHomogr, T >
 
using HomogrD = Homogr_< double >
 
using HomogrF = Homogr_< float >
 
using HomogrL = Homogr_< long double >
 
using Line2d = Line2d_< HOMOG2D_INUMTYPE >
 Default line type, uses double as numerical type. More...
 
template<typename T >
using Line2d_ = base::LPBase< typ::IsLine, T >
 
using Line2dD = Line2d_< double >
 
using Line2dF = Line2d_< float >
 
using Line2dL = Line2d_< long double >
 
using OPolyline = OPolyline_< HOMOG2D_INUMTYPE >
 
template<typename T >
using OPolyline_ = base::PolylineBase< typ::IsOpen, T >
 
using OPolylineD = OPolyline_< double >
 
using OPolylineF = OPolyline_< float >
 
using OPolylineL = OPolyline_< long double >
 
using OSegment = OSegment_< HOMOG2D_INUMTYPE >
 
template<typename T >
using OSegment_ = base::SegVec< typ::IsOSeg, T >
 
using OSegmentD = OSegment_< double >
 
using OSegmentF = OSegment_< float >
 
using OSegmentL = OSegment_< long double >
 
using Point2d = Point2d_< HOMOG2D_INUMTYPE >
 Default point type, uses double as numerical type. More...
 
template<typename T >
using Point2d_ = base::LPBase< typ::IsPoint, T >
 
using Point2dD = Point2d_< double >
 
using Point2dF = Point2d_< float >
 
using Point2dL = Point2d_< long double >
 
using PointPair = PointPair_< double >
 
template<typename T1 , typename T2 >
using PointPair2_ = std::pair< Point2d_< T1 >, Point2d_< T2 > >
 
template<typename T >
using PointPair_ = std::pair< Point2d_< T >, Point2d_< T > >
 
using PointPairD = PointPair_< double >
 
using PointPairF = PointPair_< float >
 
using PointPairL = PointPair_< long double >
 
using Segment = Segment_< HOMOG2D_INUMTYPE >
 Default segment type. More...
 
template<typename T >
using Segment_ = base::SegVec< typ::IsSegment, T >
 
using SegmentD = Segment_< double >
 
using SegmentF = Segment_< float >
 
using SegmentL = Segment_< long double >
 

Enumerations

enum  CardDir : int8_t { CardDir::Bottom, CardDir::Top, CardDir::Left, CardDir::Right }
 
enum  Dtype : uint8_t {
  Dtype::Float, Dtype::Double, Dtype::LongDouble, Dtype::Other,
  Dtype::Ttmath
}
 Type of underlying floating point, see LPBase::dtype(). Maybe printed out with getString() More...
 
enum  GivenCoord : uint8_t { GivenCoord::X, GivenCoord::Y }
 Used in Line2d::getValue() and getOrthogLine() More...
 
enum  LineDir : uint8_t { LineDir::H, LineDir::V }
 Used in line constructor, to instanciate a H or V line, see base::LPBase( LineDir, T ) More...
 
enum  PointSide : uint8_t { PointSide::Left, PointSide::Right, PointSide::Neither }
 Point related to a OSegment. More...
 
enum  Rotate : int8_t {
  Rotate::CCW, Rotate::CW, Rotate::Full, Rotate::VMirror,
  Rotate::HMirror
}
 Used in base::PolylineBase_::rotate() member function. More...
 
enum  Type : uint8_t {
  Type::Line2d, Type::Point2d, Type::Segment, Type::OSegment,
  Type::FRect, Type::Circle, Type::Ellipse, Type::OPolyline,
  Type::CPolyline
}
 Type of Root object, see rtp::Root::type(). Maybe printed out with getString() More...
 

Functions

template<typename FPT >
HOMOG2D_INUMTYPE angle (const Ellipse_< FPT > &ell)
 Return angle of ellipse (free function) More...
 
template<typename T >
HOMOG2D_INUMTYPE area (const T &elem)
 Returns area of element or variant (free function) More...
 
template<typename FPT >
bool areCollinear (const Point2d_< FPT > &pt1, const Point2d_< FPT > &pt2, const Point2d_< FPT > &pt3)
 Returns true if the 3 points are on the same line. More...
 
template<typename T1 , typename T2 >
bool areParallel (const T1 &t1, const T2 &t2)
 Returns true is lines (or segments) are parallel. More...
 
template<typename FPT >
Homogr_< FPT > buildFrom4Points (const std::vector< Point2d_< FPT >> &vpt1, const std::vector< Point2d_< FPT >> &vpt2, int method=1)
 Build Homography from 2 sets of 4 points (free function) More...
 
template<typename FPT >
Point2d_< FPT > & center (Circle_< FPT > &cir)
 Returns reference on center of circle (free function), non-const version. More...
 
template<typename FPT >
const Point2d_< FPT > & center (const Circle_< FPT > &cir)
 Returns reference on center of circle (free function), const version. More...
 
template<typename PLT , typename FPT >
base::LPBase< typ::IsPoint, FPT > centroid (const base::PolylineBase< PLT, FPT > &pl)
 Returns centroid of Polyline (free function) More...
 
template<typename CT , typename FPT >
CPolyline_< FPT > convexHull (const base::PolylineBase< CT, FPT > &input)
 Compute Convex Hull of a Polyline (free function) More...
 
template<typename FPT1 , typename FPT2 >
HOMOG2D_INUMTYPE dist (const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
 Free function, distance between points. More...
 
template<typename U , typename Prim , typename std::enable_if< trait::IsDrawable< Prim >::value, Prim >::type * = nullptr>
void draw (img::Image< U > &img, const Prim &prim, const img::DrawParams &dp=img::DrawParams())
 Free function, draws any of the primitives by calling the relevant member function. More...
 
template<typename U , typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
void draw (img::Image< U > &img, const T &cont, const img::DrawParams &dp=img::DrawParams())
 Free function, draws a set of primitives. More...
 
template<typename U , typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
void draw (img::Image< U > &img, const T &cont, std::function< img::DrawParams(int)> &func)
 This version holds a std::function as 3th parameter. It can be used to pass a function that will return a different img::DrawParams for a given index of the container. More...
 
template<typename T1 , typename T2 , typename U >
void draw (img::Image< U > &img, const std::pair< T1, T2 > &pa, const img::DrawParams &dp=img::DrawParams())
 Free function, draws a pair of objects. More...
 
template<typename U , typename FPT >
void drawText (img::Image< U > &im, std::string str, Point2d_< FPT > pt, img::DrawParams dp=img::DrawParams())
 Free function, draws text str at position pt. More...
 
template<typename T >
std::pair< int, int > dsize (const T &t)
 Get data size expressed as number of bits for, respectively, mantissa and exponent. More...
 
template<typename T >
Dtype dtype (const T &elem)
 Returns the underlying data type of object or variant. More...
 
template<typename FPT , typename T >
size_t findFarthestPoint (const Point2d_< FPT > &pt, const T &cont)
 Returns index of point in container cont that is the farthest to pt. More...
 
template<typename FPT , typename T >
auto findNearestFarthestPoint (const Point2d_< FPT > &pt, const T &cont)
 Returns indexes of points in container cont that are nearest/farthest. More...
 
template<typename FPT , typename T >
size_t findNearestPoint (const Point2d_< FPT > &pt, const T &cont)
 Returns index of point in container cont that is the nearest to pt. More...
 
template<typename FPT >
std::array< Point2d_< FPT >, 4 > get4Pts (const FRect_< FPT > &rect)
 Returns the 4 points of the rectangle (free function) More...
 
template<typename T1 , typename T2 >
HOMOG2D_INUMTYPE getAngle (const T1 &t1, const T2 &t2)
 Free function, returns angle between two segments/lines. More...
 
template<typename FPT >
std::pair< Line2d_< FPT >, Line2d_< FPT > > getAxisLines (const Ellipse_< FPT > &ell)
 Returns ellipse axis lines. More...
 
template<typename T >
FRect_< HOMOG2D_INUMTYPEgetBB (const T &t)
 Return Bounding Box of primitive or container holding primitives (free function) More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
auto getBB (const PointPair2_< T1, T2 > &pp1, const PointPair2_< T3, T4 > &pp2)
 Returns bounding box of two pairs of points. More...
 
template<typename T1 , typename T2 >
auto getBB (const T1 &elem1, const T2 &elem2)
 Overload 1/3. This one is called if NONE of the args are a Line2d. More...
 
template<typename FPT >
Line2d_< FPT > getBisector (const Segment_< FPT > &seg)
 Free function, returns bisector line of segment. More...
 
template<typename PLT , typename FPT >
std::vector< Line2d_< HOMOG2D_INUMTYPE > > getBisectorLines (const base::PolylineBase< PLT, FPT > &pl)
 Returns bisector lines of a Polyline. More...
 
template<typename T >
auto getBmPoint (const T &t)
 Return Bottom-most point of container holding points. More...
 
template<typename PLT , typename FPT >
Point2d_< FPT > getBmPoint (const base::PolylineBase< PLT, FPT > &poly)
 Return Bottom-most point of Polyline (free function) More...
 
template<typename FPT >
Circle_< FPT > getBoundingCircle (const FRect_< FPT > &rect)
 Returns circle passing through 4 points of flat rectangle (free function) More...
 
template<typename FPT >
Point2d_< FPT > getCenter (const Segment_< FPT > &seg)
 Free function, returns middle point of segment. More...
 
template<typename T >
Point2d_< typename T::FType > getCenter (const T &other)
 Return center of Segment_, FRect_, or Ellipse_ (free function) More...
 
template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
auto getCenters (const T &vsegs)
 Free function, returns middle points of set of segments/circles. More...
 
template<typename PLT1 , typename FPT1 , typename PLT2 , typename FPT2 >
priv::ClosestPoints< PLT1, FPT1, PLT2, FPT2 > getClosestPoints (const base::PolylineBase< PLT1, FPT1 > &poly1, const base::PolylineBase< PLT2, FPT2 > &poly2)
 Computes the closest points between two polylines (types can be different) More...
 
template<typename FPT >
cv::Point2d getCvPtd (const Point2d_< FPT > &pt)
 Free function to return an OpenCv point (double) More...
 
template<typename FPT >
cv::Point2f getCvPtf (const Point2d_< FPT > &pt)
 Free function to return an OpenCv point (float) More...
 
template<typename FPT >
cv::Point2i getCvPti (const Point2d_< FPT > &pt)
 Free function to return an OpenCv point (integer) More...
 
template<typename FPT >
std::pair< Segment_< FPT >, Segment_< FPT > > getDiagonals (const FRect_< FPT > &rect)
 Free function. More...
 
template<typename FPT >
Segment_< FPT > getExtended (const Segment_< FPT > &seg)
 Returns Extended Segment (free function) More...
 
template<typename FPT >
FRect_< FPT > getExtended (const FRect_< FPT > &rect)
 Free function. More...
 
template<typename T >
auto getExtremePoint (CardDir dir, const T &t)
 Get Top-most / Bottom-most / Left-most / Right-most point, depending on dir (free function) More...
 
template<typename FPT >
FRect_< FPT > getFRect (cv::Mat &mat)
 
template<typename FPT >
Circle_< FPT > getInscribedCircle (const FRect_< FPT > &rect)
 Return circle inscribed in rectangle. More...
 
template<typename FPT >
Line2d_< FPT > getLine (const Segment_< FPT > &seg)
 Returns Segment supporting line (free function) More...
 
template<typename FPT1 , typename FPT2 , typename FPT3 >
Line2d_< FPT1 > getLine (const Circle_< FPT2 > &c1, const Circle_< FPT3 > &c2)
 Free function, returns line between two circle centers. More...
 
template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
auto getLines (const T &vsegs)
 Free function, returns a set of lines from a set of segments. More...
 
template<typename T >
auto getLmPoint (const T &t)
 Return Left-most point of container as a pair holding: More...
 
template<typename PLT , typename FPT >
Point2d_< FPT > getLmPoint (const base::PolylineBase< PLT, FPT > &poly)
 Return Left-most point of Polyline (free function) More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
auto getMinMax (const PointPair2_< T1, T2 > &pp1, const PointPair2_< T3, T4 > &pp2)
 Returns a pair of points holding min and max coordinates of the two input pair of points. More...
 
template<typename FPT >
CPolyline_< FPT > getOBB (const Ellipse_< FPT > &ell)
 Returns Bounding Box of Ellipse_ (free function) More...
 
template<typename FPT >
std::array< Point2d_< FPT >, 4 > getOrthogPts (const Segment_< FPT > &seg)
 Returns the 4 orthogonal points to the segment. More...
 
template<typename FPT >
std::array< Segment_< FPT >, 4 > getOrthogSegs (const Segment_< FPT > &seg)
 Returns the 4 orthogonal segments to the segment. More...
 
template<typename FPT >
HOMOG2D_INUMTYPE getParallelDistance (const Line2d_< FPT > &li1, const Line2d_< FPT > &li2)
 Returns the distance between 2 parallel lines (free function) More...
 
template<typename FPT , typename T >
std::pair< Line2d_< FPT >, Line2d_< FPT > > getParallelLines (const Line2d_< FPT > &li, T dist)
 Returns the 2 parallel lines at distance dist from li (free function) More...
 
template<typename FPT , typename T >
std::pair< Segment_< FPT >, Segment_< FPT > > getParallelSegs (const Segment_< FPT > &seg, T dist)
 Free function, returns a pair of parallel segments at a distance dist. More...
 
template<typename RT , typename FPT >
RT getPt (const Point2d_< FPT > &pt)
 Generic free function to return a point of other type. More...
 
template<typename RT , typename FPT >
std::vector< RT > getPts (const std::vector< Point2d_< FPT >> &vpt)
 Free function, returns a vector of points of other type from a vector of h2d points. More...
 
template<typename FPT >
auto getPts (const Segment_< FPT > &seg)
 Returns the points of Segment as a std::pair (free function) More...
 
template<typename FPT >
auto getPts (const FRect_< FPT > &rect)
 Returns the 2 major points of the rectangle (free function) More...
 
template<typename CONT , typename PRIM >
CONT getPtsInside (const CONT &input_set, const PRIM &prim)
 Returns set of points that are inside primitive prim. More...
 
template<typename T >
auto getRmPoint (const T &t)
 Return Right-most point of container holding points. More...
 
template<typename PLT , typename FPT >
Point2d_< FPT > getRmPoint (const base::PolylineBase< PLT, FPT > &poly)
 Return Right-most point of Polyline (free function) More...
 
template<typename T1 , typename T2 >
Segment_< typename T1::FType > getSegment (const T1 &c1, const T2 &c2)
 Free function, returns segment between two circle centers (or ellipse) More...
 
template<typename PLT , typename FPT >
std::vector< Segment_< FPT > > getSegs (const base::PolylineBase< PLT, FPT > &pl)
 Returns the segments of the polyline (free function) More...
 
template<typename FPT >
std::array< Segment_< FPT >, 4 > getSegs (const FRect_< FPT > &seg)
 Free function, returns segments of the rectangle. More...
 
const char * getString (Type t)
 Returns stringified version of type() More...
 
const char * getString (Dtype t)
 
const char * getString (PointSide t)
 
template<typename FPT1 , typename FPT2 >
std::pair< Segment_< FPT1 >, Segment_< FPT1 > > getTanSegs (const Circle_< FPT1 > &c1, const Circle_< FPT2 > &c2)
 Free function, returns the pair of segments tangential to the two circles. More...
 
template<typename T >
auto getTmPoint (const T &t)
 Return Top-most point of container. More...
 
template<typename PLT , typename FPT >
Point2d_< FPT > getTmPoint (const base::PolylineBase< PLT, FPT > &poly)
 Return Top-most point of Polyline (free function) More...
 
template<typename FPT >
FPT getX (const Point2d_< FPT > &pt)
 
template<typename FPT >
FPT getY (const Point2d_< FPT > &pt)
 
template<typename FPT >
HOMOG2D_INUMTYPE height (const FRect_< FPT > &rect)
 Free function. More...
 
template<typename FPT1 , typename FPT2 >
detail::RectArea< FPT1 > intersectArea (const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
 Free function, see FRect_::intersectArea() More...
 
template<typename FPT1 , typename FPT2 >
HOMOG2D_INUMTYPE IoU (const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
 Intersection area over Union area (free function) More...
 
template<typename FPT >
bool isCircle (const Ellipse_< FPT > &ell, HOMOG2D_INUMTYPE thres=1.E-10)
 Returns true if ellipse is a circle. More...
 
template<typename PLT , typename FPT >
bool isConvex (const base::PolylineBase< PLT, FPT > &poly)
 Returns true if polygon is convex (free function) More...
 
template<typename PLT , typename FPT >
bool isSimple (const base::PolylineBase< PLT, FPT > &pl)
 Returns true if is a polygon (free function)   More...
 
template<typename T >
HOMOG2D_INUMTYPE length (const T &elem)
 Returns length of element or variant (free function) More...
 
template<typename T , typename FP >
void moveTo (T &prim, const Point2d_< FP > &pt)
 Move primitive to other location (free function) More...
 
template<typename T , typename FP1 , typename FP2 >
void moveTo (T &prim, FP1 x, FP2 y)
 Move primitive to other location (free function) More...
 
template<typename PLT , typename FPT >
size_t nbSegs (const base::PolylineBase< PLT, FPT > &pl)
 Returns the number of segments (free function) More...
 
template<typename T , typename U >
Line2d_< T > operator* (const Homogr_< U > &h, const Line2d_< T > &in)
 Free function, apply homography to a line. More...
 
template<typename FPT , typename FPT2 >
Line2d_< FPT > operator* (const Point2d_< FPT > &lhs, const Point2d_< FPT2 > &rhs)
 Free function template, product of two points, returns a line. More...
 
template<typename FPT1 , typename FPT2 >
Line2d_< FPT1 > operator* (const Point2d_< FPT1 > &, const Point2d_< FPT2 > &)
 
template<typename FPT1 , typename FPT2 >
Point2d_< FPT1 > operator* (const Line2d_< FPT1 > &, const Line2d_< FPT2 > &)
 
template<typename FPT1 , typename FPT2 >
CPolyline_< FPT1 > operator* (const h2d::Homogr_< FPT2 > &h, const h2d::FRect_< FPT1 > &rin)
 Apply homography to a flat rectangle produces a closed polyline. More...
 
template<typename FPT1 , typename FPT2 , typename PLT2 >
auto operator* (const Homogr_< FPT2 > &, const base::PolylineBase< PLT2, FPT1 > &) -> base::PolylineBase< PLT2, FPT1 >
 
template<typename FPT , typename FPT2 >
Point2d_< FPT > operator* (const Line2d_< FPT > &lhs, const Line2d_< FPT2 > &rhs)
 Free function template, product of two lines, returns a point. More...
 
template<typename SV1 , typename SV2 , typename FPT1 , typename FPT2 >
Point2d_< FPT1 > operator* (const base::SegVec< SV1, FPT1 > &lhs, const base::SegVec< SV2, FPT2 > &rhs)
 Free function template, product of two segments/vector, returns a point. More...
 
template<typename T , typename U >
Point2d_< T > operator* (const Homogr_< U > &h, const Point2d_< T > &in)
 Free function, apply homography to a point. More...
 
template<typename SV , typename FPT1 , typename FPT2 >
Segment_< FPT1 > operator* (const Homogr_< FPT1 > &h, const base::SegVec< SV, FPT2 > &seg)
 Apply homography to a Segment. More...
 
template<typename FPT1 , typename FPT2 , typename PLT >
base::PolylineBase< PLT, FPT1 > operator* (const Homogr_< FPT2 > &h, const base::PolylineBase< PLT, FPT1 > &pl)
 Apply homography to a Polyline. More...
 
template<typename FPT1 , typename FPT2 >
Ellipse_< FPT1 > operator* (const Homogr_< FPT2 > &h, const Ellipse_< FPT1 > &ell_in)
 Apply homography to a Ellipse, produces an Ellipse. More...
 
template<typename FPT1 , typename FPT2 >
Ellipse_< FPT1 > operator* (const Homogr_< FPT2 > &h, const Circle_< FPT1 > &cir)
 Apply homography to a Circle, produces an Ellipse. More...
 
template<typename FPT , typename Cont >
std::enable_if< trait::IsContainer< Cont >::value, Cont >::type operator* (const Hmatrix_< typ::IsHomogr, FPT > &h, const Cont &vin)
 Used to proceed multiple products, whatever the container (std::list, std::vector, or std::array). Returned container is of same type as given input. More...
 
template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
std::ostream & operator<< (std::ostream &f, const T &vec)
 Stream operator for a container of points/lines, free function. More...
 
template<typename LP1 , typename LP2 , typename FPT >
std::ostream & operator<< (std::ostream &f, const std::pair< base::LPBase< LP1, FPT >, base::LPBase< LP2, FPT >> &pr)
 Stream operator for a pair of points/lines, free function. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &f, const FRect_< T > &r)
 
template<typename T >
std::ostream & operator<< (std::ostream &f, const Circle_< T > &r)
 
template<typename T >
std::ostream & operator<< (std::ostream &f, const Ellipse_< T > &ell)
 
template<typename FPT >
FPT & radius (Circle_< FPT > &cir)
 Returns reference on radius of circle (free function), non-const version. More...
 
template<typename FPT >
const FPT & radius (const Circle_< FPT > &cir)
 Returns reference on radius of circle (free function), const version. More...
 
template<typename T >
void rotate (T &prim, Rotate rot)
 Rotates the primitive (only available for Polyline and FRect) around (0,0) More...
 
template<typename T , typename FPT >
void rotate (T &prim, Rotate rot, const Point2d_< FPT > &refpt)
 Rotates the primitive (only available for Polyline and FRect) around refpt. More...
 
template<typename FPT1 , typename FPT2 >
int side (const Point2d_< FPT1 > &pt, const Line2d_< FPT2 > &li)
 Free function, returns -1 or +1 depending on the side of pt, related to li. More...
 
template<typename T >
HOMOG2D_INUMTYPE size (const T &elem)
 Returns size of element or variant (free function) More...
 
template<typename SV , typename FPT >
std::pair< base::SegVec< SV, FPT >, base::SegVec< SV, FPT > > split (const base::SegVec< SV, FPT > &seg)
 Returns a pair of segments, corresponding to the input segment split by middle point (free function) More...
 
template<typename FPT , typename T >
std::pair< OSegment_< FPT >, OSegment_< FPT > > split (const OSegment_< FPT > &seg, T dist)
 Returns a pair of segments, corresponding to the input segment split by point at distance dist (free function) More...
 
template<typename T , typename FPT >
CommonType_< FPT > transform (const Homogr_< FPT > &h, const T &elem)
 Apply homography to primitive. More...
 
template<typename T , typename FP1 , typename FP2 >
void translate (T &prim, FP1 dx, FP2 dy)
 Translate primitive prim (free function) More...
 
template<typename T , typename FP1 , typename FP2 >
void translate (T &prim, const std::pair< FP1, FP2 > &ppt)
 Translate primitive prim with values in a std::pair (free function) More...
 
template<typename T >
Type type (const T &elem)
 Free function. Returns the type of object or variant. More...
 
template<typename FPT1 , typename FPT2 >
CPolyline_< FPT1 > unionArea (const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
 Free function, see FRect_::unionArea() More...
 
template<typename FPT >
HOMOG2D_INUMTYPE width (const FRect_< FPT > &rect)
 Free function. More...
 

Typedef Documentation

◆ Circle

Default circle type.

◆ CircleD

using h2d::CircleD = typedef Circle_<double>

◆ CircleF

using h2d::CircleF = typedef Circle_<float>

◆ CircleL

using h2d::CircleL = typedef Circle_<long double>

◆ CommonType

◆ CommonType_

template<typename FPT >
using h2d::CommonType_ = typedef std::variant< Segment_<FPT>, OSegment_<FPT>, Point2d_<FPT>, Line2d_<FPT>, Circle_<FPT>, Ellipse_<FPT>, FRect_<FPT>, CPolyline_<FPT>, OPolyline_<FPT> >

A variant type, holding all possible types. Used to achieve runtime polymorphism.

See https://github.com/skramm/homog2d/blob/master/docs/homog2d_manual.md#section_rtp

◆ CommonTypeD

using h2d::CommonTypeD = typedef CommonType_<double>

◆ CommonTypeF

using h2d::CommonTypeF = typedef CommonType_<float>

◆ CommonTypeL

using h2d::CommonTypeL = typedef CommonType_<long double>

◆ CPolyline

Default polyline type.

◆ CPolyline_

template<typename T >
using h2d::CPolyline_ = typedef base::PolylineBase<typ::IsClosed,T>

◆ CPolylineD

using h2d::CPolylineD = typedef CPolyline_<double>

◆ CPolylineF

using h2d::CPolylineF = typedef CPolyline_<float>

◆ CPolylineL

using h2d::CPolylineL = typedef CPolyline_<long double>

◆ Ellipse

Default ellipse type.

◆ EllipseD

using h2d::EllipseD = typedef Ellipse_<double>

◆ EllipseF

using h2d::EllipseF = typedef Ellipse_<float>

◆ EllipseL

using h2d::EllipseL = typedef Ellipse_<long double>

◆ Epipmat

Default homogeneous matrix, uses double as numerical type.

◆ FRect

Default rectangle type.

◆ FRectD

using h2d::FRectD = typedef FRect_<double>

◆ FRectF

using h2d::FRectF = typedef FRect_<float>

◆ FRectL

using h2d::FRectL = typedef FRect_<long double>

◆ Homogr

Default homography (3x3 matrix) type, uses double as numerical type.

◆ Homogr_

template<typename T >
using h2d::Homogr_ = typedef Hmatrix_<typ::IsHomogr,T>

◆ HomogrD

using h2d::HomogrD = typedef Homogr_<double>

◆ HomogrF

using h2d::HomogrF = typedef Homogr_<float>

◆ HomogrL

using h2d::HomogrL = typedef Homogr_<long double>

◆ Line2d

Default line type, uses double as numerical type.

◆ Line2d_

template<typename T >
using h2d::Line2d_ = typedef base::LPBase<typ::IsLine,T>

◆ Line2dD

using h2d::Line2dD = typedef Line2d_<double>

◆ Line2dF

using h2d::Line2dF = typedef Line2d_<float>

◆ Line2dL

using h2d::Line2dL = typedef Line2d_<long double>

◆ OPolyline

◆ OPolyline_

template<typename T >
using h2d::OPolyline_ = typedef base::PolylineBase<typ::IsOpen,T>

◆ OPolylineD

using h2d::OPolylineD = typedef OPolyline_<double>

◆ OPolylineF

using h2d::OPolylineF = typedef OPolyline_<float>

◆ OPolylineL

using h2d::OPolylineL = typedef OPolyline_<long double>

◆ OSegment

◆ OSegment_

template<typename T >
using h2d::OSegment_ = typedef base::SegVec<typ::IsOSeg,T>

◆ OSegmentD

using h2d::OSegmentD = typedef OSegment_<double>

◆ OSegmentF

using h2d::OSegmentF = typedef OSegment_<float>

◆ OSegmentL

using h2d::OSegmentL = typedef OSegment_<long double>

◆ Point2d

Default point type, uses double as numerical type.

◆ Point2d_

template<typename T >
using h2d::Point2d_ = typedef base::LPBase<typ::IsPoint,T>

◆ Point2dD

using h2d::Point2dD = typedef Point2d_<double>

◆ Point2dF

using h2d::Point2dF = typedef Point2d_<float>

◆ Point2dL

using h2d::Point2dL = typedef Point2d_<long double>

◆ PointPair

using h2d::PointPair = typedef PointPair_<double>

◆ PointPair2_

template<typename T1 , typename T2 >
using h2d::PointPair2_ = typedef std::pair<Point2d_<T1>,Point2d_<T2> >

◆ PointPair_

template<typename T >
using h2d::PointPair_ = typedef std::pair<Point2d_<T>,Point2d_<T> >

◆ PointPairD

using h2d::PointPairD = typedef PointPair_<double>

◆ PointPairF

using h2d::PointPairF = typedef PointPair_<float>

◆ PointPairL

using h2d::PointPairL = typedef PointPair_<long double>

◆ Segment

Default segment type.

◆ Segment_

template<typename T >
using h2d::Segment_ = typedef base::SegVec<typ::IsSegment,T>

◆ SegmentD

using h2d::SegmentD = typedef Segment_<double>

◆ SegmentF

using h2d::SegmentF = typedef Segment_<float>

◆ SegmentL

using h2d::SegmentL = typedef Segment_<long double>

Enumeration Type Documentation

◆ CardDir

enum h2d::CardDir : int8_t
strong
Enumerator
Bottom 
Top 
Left 
Right 

◆ Dtype

enum h2d::Dtype : uint8_t
strong

Type of underlying floating point, see LPBase::dtype(). Maybe printed out with getString()

Enumerator
Float 
Double 
LongDouble 
Other 
Ttmath 

only if HOMOG2D_USE_TTMATH is defined, see manual

937  : uint8_t {
939  Other, // ?
940 #ifdef HOMOG2D_USE_TTMATH
941  Ttmath
942 #endif
943 };
only if HOMOG2D_USE_TTMATH is defined, see manual

◆ GivenCoord

enum h2d::GivenCoord : uint8_t
strong

Used in Line2d::getValue() and getOrthogLine()

Enumerator

◆ LineDir

enum h2d::LineDir : uint8_t
strong

Used in line constructor, to instanciate a H or V line, see base::LPBase( LineDir, T )

Enumerator
928 : uint8_t { H, V };

◆ PointSide

enum h2d::PointSide : uint8_t
strong

Point related to a OSegment.

See also
SegVec::getPointSide()
Enumerator
Left 
Right 
Neither 

◆ Rotate

enum h2d::Rotate : int8_t
strong

Used in base::PolylineBase_::rotate() member function.

Enumerator
CCW 

Counter ClockWise rotation.

CW 

ClockWise rotation.

Full 

180° rotation

VMirror 

vertical symmetry

HMirror 

horizontal symmetry

913  : int8_t
914 {
915  CCW,
916  CW,
917  Full,
918  VMirror,
919  HMirror
920 };
180° rotation
ClockWise rotation.
horizontal symmetry
Counter ClockWise rotation.
vertical symmetry

◆ Type

enum h2d::Type : uint8_t
strong

Type of Root object, see rtp::Root::type(). Maybe printed out with getString()

See also
type()
Enumerator
Line2d 
Point2d 
Segment 
OSegment 
FRect 
Circle 
Ellipse 
OPolyline 
CPolyline 
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12400
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12396
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12389
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12393
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12377
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12390
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12403
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12399
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12380

Function Documentation

◆ angle()

template<typename FPT >
HOMOG2D_INUMTYPE h2d::angle ( const Ellipse_< FPT > &  ell)

Return angle of ellipse (free function)

See also
Ellipse_::angle()
10995 {
10996  return ell.angle();
10997 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ areCollinear()

template<typename FPT >
bool h2d::areCollinear ( const Point2d_< FPT > &  pt1,
const Point2d_< FPT > &  pt2,
const Point2d_< FPT > &  pt3 
)

Returns true if the 3 points are on the same line.

Todo:
at present, defined by the distance between third point and line. Need to change that, and replace by computation of the angle between the two lines
3685 {
3686  if( pt1 == pt2 || pt2 == pt3 || pt1 == pt3 )
3687  return true;
3688 
3689  auto pt_arr = priv::getLargestDistancePoints( pt1, pt2, pt3 );
3690 
3691  auto li = pt_arr[0] * pt_arr[1];
3692  if( li.distTo( pt_arr[2] ) < thr::nullDistance() )
3693  return true;
3694  return false;
3695 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
Line2d li
Definition: homog2d_test.cpp:4035
std::array< PT, 3 > getLargestDistancePoints(PT pt1, PT pt2, PT pt3)
Helper function, used to check for colinearity of three points.
Definition: homog2d.hpp:3613
Here is the call graph for this function:
Here is the caller graph for this function:

◆ areParallel()

template<typename T1 , typename T2 >
bool h2d::areParallel ( const T1 &  t1,
const T2 &  t2 
)

Returns true is lines (or segments) are parallel.

4624 {
4625  return t1.isParallelTo(t2);
4626 }
Here is the caller graph for this function:

◆ buildFrom4Points()

template<typename FPT >
Homogr_<FPT> h2d::buildFrom4Points ( const std::vector< Point2d_< FPT >> &  vpt1,
const std::vector< Point2d_< FPT >> &  vpt2,
int  method = 1 
)

Build Homography from 2 sets of 4 points (free function)

See also
Homogr_::buildFrom4Points()
Parameters
vpt1source points
vpt2destination points
method0: Eigen, 1: Opencv
4774 {
4775  Homogr_<FPT> H;
4776  H.buildFrom4Points( vpt1, vpt2, method );
4777  return H;
4778 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ center() [1/2]

template<typename FPT >
Point2d_<FPT>& h2d::center ( Circle_< FPT > &  cir)

Returns reference on center of circle (free function), non-const version.

See also
Circle_::center()
10936 {
10937  return cir.center();
10938 }
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function:
Here is the caller graph for this function:

◆ center() [2/2]

template<typename FPT >
const Point2d_<FPT>& h2d::center ( const Circle_< FPT > &  cir)

Returns reference on center of circle (free function), const version.

See also
Circle_::center()
10945 {
10946  return cir.center();
10947 }
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function:

◆ centroid()

template<typename PLT , typename FPT >
base::LPBase<typ::IsPoint,FPT> h2d::centroid ( const base::PolylineBase< PLT, FPT > &  pl)

Returns centroid of Polyline (free function)

See also
PolylineBase::centroid()
10909 {
10910  return pl.centroid();
10911 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convexHull()

template<typename CT , typename FPT >
CPolyline_<FPT> h2d::convexHull ( const base::PolylineBase< CT, FPT > &  input)

Compute Convex Hull of a Polyline (free function)

11538 {
11539  return convexHull( input.getPts() );
11540 }
CPolyline_< FPT > convexHull(const std::vector< Point2d_< FPT >> &input)
Computes and returns the convex hull of a set of points (free function)
Definition: homog2d.hpp:11552
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dist()

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

Free function, distance between points.

See also
Point2d_::distTo()
9849 {
9850  return pt1.distTo( pt2 );
9851 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw() [1/3]

template<typename U , typename Prim , typename std::enable_if< trait::IsDrawable< Prim >::value, Prim >::type * = nullptr>
void h2d::draw ( img::Image< U > &  img,
const Prim &  prim,
const img::DrawParams dp = img::DrawParams() 
)

Free function, draws any of the primitives by calling the relevant member function.

Todo:
20240504: see note on the IsDrawable trait class
11254 {
11255  prim.draw( img, dp );
11256 }
Here is the caller graph for this function:

◆ draw() [2/3]

template<typename U , typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
void h2d::draw ( img::Image< U > &  img,
const T &  cont,
std::function< img::DrawParams(int)> &  func 
)

This version holds a std::function as 3th parameter. It can be used to pass a function that will return a different img::DrawParams for a given index of the container.

At present, cannot be used with container holding variants...

11347 {
11348  size_t c=0;
11349  for( const auto& elem: cont )
11350  {
11351  auto dp = func(c);
11352  elem.draw( img, dp );
11353  priv::impl_drawIndexes( img, c++, dp, elem );
11354  }
11355 }
void impl_drawIndexes(img::Image< IMG > &, size_t, const img::DrawParams &, const DUMMY &)
Default signature, will be instanciated if no other fits (and does nothing)
Definition: homog2d.hpp:11289
Here is the call graph for this function:

◆ draw() [3/3]

template<typename T1 , typename T2 , typename U >
void h2d::draw ( img::Image< U > &  img,
const std::pair< T1, T2 > &  pa,
const img::DrawParams dp = img::DrawParams() 
)

Free function, draws a pair of objects.

Type T1 and T2 can be anything drawable

11367 {
11368  pa.first.draw( img, dp );
11369  pa.second.draw( img, dp );
11370 }

◆ drawText()

template<typename U , typename FPT >
void h2d::drawText ( img::Image< U > &  im,
std::string  str,
Point2d_< FPT >  pt,
img::DrawParams  dp = img::DrawParams() 
)

Free function, draws text str at position pt.

11262 {
11263  im.drawText( str, pt, dp );
11264 }
img::Image< img::SvgImage > im(300, 400)
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dsize()

template<typename T >
std::pair<int,int> h2d::dsize ( const T &  t)

Get data size expressed as number of bits for, respectively, mantissa and exponent.

See also
detail::Common::dsize()
10954 {
10955  return t.dsize();
10956 }
Here is the caller graph for this function:

◆ findFarthestPoint()

template<typename FPT , typename T >
size_t h2d::findFarthestPoint ( const Point2d_< FPT > &  pt,
const T &  cont 
)

Returns index of point in container cont that is the farthest to pt.

11158 {
11159  return priv::findPoint( pt, cont, priv::F_MAX() );
11160 }
size_t findPoint(const Point2d_< FPT > &qpt, const CONT &cont, const S_WHAT &)
Private. Common function for searching nearest of farthest point.
Definition: homog2d.hpp:11085
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findNearestFarthestPoint()

template<typename FPT , typename T >
auto h2d::findNearestFarthestPoint ( const Point2d_< FPT > &  pt,
const T &  cont 
)

Returns indexes of points in container cont that are nearest/farthest.

  • return pair: first is nearest, second is farthest
11169 {
11170  if( cont.size() < 2 )
11171  HOMOG2D_THROW_ERROR_1( "container holds " << cont.size() \
11172  << " points, minimum is 2" );
11173 
11174  auto maxDist = priv::sqDist( pt, cont[0] );
11175  auto minDist = maxDist;
11176  size_t idxMin = 0;
11177  size_t idxMax = 0;
11178  size_t startIdx = 1;
11179  if( pt == cont[0] )
11180  {
11181  idxMin++;
11182  idxMax++;
11183  startIdx++;
11184  maxDist = priv::sqDist( pt, cont[1] );
11185  minDist = maxDist;
11186  }
11187  for( size_t i=startIdx; i<cont.size(); i++ )
11188  {
11189  if( pt != cont[i] )
11190  {
11191  auto currentDist = priv::sqDist( pt, cont[i] );
11192  if( currentDist > maxDist )
11193  {
11194  idxMax = i;
11195  maxDist = currentDist;
11196  }
11197  if( currentDist < minDist )
11198  {
11199  idxMin = i;
11200  minDist = currentDist;
11201  }
11202  }
11203  }
11204  return std::make_pair(idxMin, idxMax);
11205 }
HOMOG2D_INUMTYPE sqDist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, squared distance between points (sqrt not needed for comparisons, and can save some ti...
Definition: homog2d.hpp:3574
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findNearestPoint()

template<typename FPT , typename T >
size_t h2d::findNearestPoint ( const Point2d_< FPT > &  pt,
const T &  cont 
)

Returns index of point in container cont that is the nearest to pt.

Todo:

add some sfinae and/or checking on type T

perform some speed analysis, and check if usage of squared distance is really better

add other distance computations (Manhattan?)

Would it be better to return an iterator?

11150 {
11151  return priv::findPoint( pt, cont, priv::F_MIN() );
11152 }
size_t findPoint(const Point2d_< FPT > &qpt, const CONT &cont, const S_WHAT &)
Private. Common function for searching nearest of farthest point.
Definition: homog2d.hpp:11085
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get4Pts()

template<typename FPT >
std::array<Point2d_<FPT>,4> h2d::get4Pts ( const FRect_< FPT > &  rect)

Returns the 4 points of the rectangle (free function)

See also
FRect_::get4Pts()
10859 {
10860  return rect.get4Pts();
10861 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAngle()

template<typename T1 , typename T2 >
HOMOG2D_INUMTYPE h2d::getAngle ( const T1 &  t1,
const T2 &  t2 
)

Free function, returns angle between two segments/lines.

See also
Segment_::getAngle()
Line2d_::getAngle()
9206 {
9207  static_assert(
9208  (
9209  std::is_same_v<typename T1::SType,typ::IsLine>
9210  || std::is_same_v<typename T1::SType,typ::IsSegment>
9211  || std::is_same_v<typename T1::SType,typ::IsOSeg>
9212  ) &&
9213  (
9214  std::is_same_v<typename T2::SType,typ::IsLine>
9215  || std::is_same_v<typename T2::SType,typ::IsSegment>
9216  || std::is_same_v<typename T2::SType,typ::IsOSeg>
9217  ),
9218  "Both types must be either a Line or a Segment"
9219  );
9220  return t1.getAngle( t2 );
9221 }
Here is the caller graph for this function:

◆ getAxisLines()

template<typename FPT >
std::pair<Line2d_<FPT>,Line2d_<FPT> > h2d::getAxisLines ( const Ellipse_< FPT > &  ell)

Returns ellipse axis lines.

See also
Ellipse_::getAxisLines()
11067 {
11068  return ell.getAxisLines();
11069 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBB() [1/2]

template<typename T1 , typename T2 , typename T3 , typename T4 >
auto h2d::getBB ( const PointPair2_< T1, T2 > &  pp1,
const PointPair2_< T3, T4 > &  pp2 
)

Returns bounding box of two pairs of points.

Warning
May throw in case of identical coordinates (for example with [0,0]-[1,0] and [10,0]-[20,0]
10421 {
10422  HOMOG2D_START;
10423  return FRect_<T1>( getMinMax( pp1, pp2 ) );
10424 }
#define HOMOG2D_START
Definition: homog2d.hpp:106
auto getMinMax(const PointPair2_< T1, T2 > &pp1, const PointPair2_< T3, T4 > &pp2)
Returns a pair of points holding min and max coordinates of the two input pair of points...
Definition: homog2d.hpp:10399
Here is the call graph for this function:

◆ getBB() [2/2]

template<typename T1 , typename T2 >
auto h2d::getBB ( const T1 &  elem1,
const T2 &  elem2 
)

Overload 1/3. This one is called if NONE of the args are a Line2d.

Overload 3/3. Called if one of the args is a Line2d (=> no build!)

10439 {
10440  HOMOG2D_START;
10441 
10442  bool isPoly_1 = false;
10443  if( elem1.type() == Type::OPolyline || elem1.type() == Type::CPolyline )
10444  isPoly_1 = true;
10445 
10446  bool isPoly_2 = false;
10447  if( elem2.type() == Type::OPolyline || elem2.type() == Type::CPolyline )
10448  isPoly_1 = true;
10449 
10450  auto siz_1 = elem1.size();
10451  auto siz_2 = elem2.size();
10452 
10453  if( isPoly_1 && isPoly_2 )
10454  if( siz_1==0 && siz_2==0 )
10455  HOMOG2D_THROW_ERROR_1( "unable to compute bounding box of two empty polyline objects" );
10456 
10457  FRect_<typename T1::FType> out;
10458 // we need to do that in two steps: first, copy return value into `out`, then return
10459 // because the underlying floating point might not be the same for the two arguments.
10460  if( isPoly_2 && siz_1==0 )
10461  {
10462  auto pp = ppair::getPointPair( elem2 );
10463  if( shareCommonCoord(pp) )
10464  {
10465  HOMOG2D_THROW_ERROR_1( "Unable to build common Bounding Box of empty polyline and elem2:" << elem2 );
10466  }
10467  else
10468  return FRect_<typename T1::FType>( pp );
10469  }
10470  if( isPoly_1 && siz_2==0 )
10471  {
10472  auto pp = ppair::getPointPair( elem1 );
10473  if( shareCommonCoord(pp) )
10474  {
10475  HOMOG2D_THROW_ERROR_1( "Unable to build common Bounding Box of empty polyline and elem1:" << elem1 );
10476  }
10477  else
10478  return FRect_<typename T1::FType>( pp );
10479  }
10480 
10481  try
10482  {
10483  out = getBB(
10484  ppair::getPointPair( elem1 ),
10485  ppair::getPointPair( elem2 )
10486  );
10487  }
10488  catch( const std::exception& err )
10489  {
10490  HOMOG2D_THROW_ERROR_1( "unable to compute bounding box:\n -arg1="
10491  << elem1 << "\n -arg2=" << elem2 << "\n -err=" << err.what() );
10492  }
10493  return out;
10494 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12400
#define HOMOG2D_START
Definition: homog2d.hpp:106
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12399
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
auto getBB(const T1 &elem1, const T2 &elem2)
Overload 1/3. This one is called if NONE of the args are a Line2d.
Definition: homog2d.hpp:10438
bool shareCommonCoord(const std::pair< Point2d_< FPT1 >, Point2d_< FPT2 >> &ppts)
Returns true if one of the points share a common coordinate (thus making them unable to define a boun...
Definition: homog2d.hpp:1336
PointPair_< FPT > getPointPair(const Line2d_< FPT > &)
Needed because of variant.
Definition: homog2d.hpp:10118
Here is the call graph for this function:

◆ getBisector()

template<typename FPT >
Line2d_<FPT> h2d::getBisector ( const Segment_< FPT > &  seg)

Free function, returns bisector line of segment.

See also
Segment_::getBisector()
10716 {
10717  return seg.getBisector();
10718 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ getBisectorLines()

template<typename PLT , typename FPT >
std::vector< Line2d_< HOMOG2D_INUMTYPE > > h2d::getBisectorLines ( const base::PolylineBase< PLT, FPT > &  pl)

Returns bisector lines of a Polyline.

Size of vector will be:

  • equal to size() of polyline if closed
  • equal to size()-2 of polyline if open
Warning
:
  • if open: the FIRST line (index 0) will correspond to SECOND point of the polyline
9984 {
9985  if( pl.size() < 3 )
9986  {
9987  HOMOG2D_THROW_ERROR_1( "unable, minimum size is 3, currently=" << pl.size() );
9988  }
9989  const auto& pts = pl.getPts();
9990  std::vector<Line2d_<HOMOG2D_INUMTYPE>> out;
9991 
9992  if constexpr ( std::is_same_v<PLT,typ::IsOpen> )
9993  {
9994  out.reserve( pl.size()-2 );
9995  OSegment_<HOMOG2D_INUMTYPE> seg1( pts[1], pts[0] );
9996  for( size_t i=0; i<pl.size()-2; i++ )
9997  {
9998  OSegment_<HOMOG2D_INUMTYPE> seg2( pts[i+1], pts[i+2] );
9999  auto angle = seg1.getAngle( seg2 );
10000  out.emplace_back( seg1.getLine().getRotatedLine( pts[i+1], angle/2. ) );
10001  seg1 = -seg2;
10002  }
10003  }
10004  else
10005  {
10006  out.reserve( pl.size() );
10007  OSegment_<HOMOG2D_INUMTYPE> seg1( pts[0], pts[pl.size()-1] );
10008  for( size_t i=0; i<pl.size(); i++ )
10009  {
10010  auto next = ( i != pl.size()-1 ? i+1 : 0 );
10011  OSegment_<HOMOG2D_INUMTYPE> seg2( pts[i], pts[next] );
10012  auto angle = seg1.getAngle( seg2 );
10013  out.emplace_back( seg1.getLine().getRotatedLine( pts[i], angle/2. ) );
10014  seg1 = -seg2;
10015  }
10016  }
10017  return out;
10018 }
HOMOG2D_INUMTYPE angle(const Ellipse_< FPT > &ell)
Return angle of ellipse (free function)
Definition: homog2d.hpp:10994
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBmPoint() [1/2]

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

Return Bottom-most point of container holding points.

6917 {
6918 #ifndef HOMOG2D_NOCHECKS
6919  if( t.size() == 0 )
6920  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6921 #endif
6922  auto it = priv::getBmPoint_helper( t );
6923  return std::make_pair(
6924  *it,
6925  std::distance( std::begin(t), it )
6926  );
6927 }
auto getBmPoint_helper(const T &t)
Return iterator on Bottom-most point of container holding points.
Definition: homog2d.hpp:6879
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBmPoint() [2/2]

template<typename PLT , typename FPT >
Point2d_<FPT> h2d::getBmPoint ( const base::PolylineBase< PLT, FPT > &  poly)

Return Bottom-most point of Polyline (free function)

7063 {
7064  return getBmPoint( poly.getPts() ).first;
7065 }
Point2d_< FPT > getBmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Bottom-most point of Polyline (free function)
Definition: homog2d.hpp:7062
Here is the call graph for this function:

◆ getBoundingCircle()

template<typename FPT >
Circle_<FPT> h2d::getBoundingCircle ( const FRect_< FPT > &  rect)

Returns circle passing through 4 points of flat rectangle (free function)

See also
FRect_::getBoundingCircle()
9889 {
9890  return rect.getBoundingCircle();
9891 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:

◆ getCenter() [1/2]

template<typename FPT >
Point2d_<FPT> h2d::getCenter ( const Segment_< FPT > &  seg)

Free function, returns middle point of segment.

See also
Segment_::getCenter()
10707 {
10708  return seg.getCenter();
10709 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCenter() [2/2]

template<typename T >
Point2d_<typename T::FType> h2d::getCenter ( const T &  other)

Return center of Segment_, FRect_, or Ellipse_ (free function)

See also
Ellipse_::getCenter()
FRect_::getCenter()
Segment_::getCenter()
11006 {
11007  return other.getCenter();
11008 }

◆ getCenters()

template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
auto h2d::getCenters ( const T &  vsegs)

Free function, returns middle points of set of segments/circles.

See also
Segment_::getCenter()
Circle_::getCenter()
  • input: set of segments
  • output: set of points (same container)
10745 {
10746  std::vector<Point2d_<typename T::value_type::FType>> vout( vsegs.size() );
10747 
10748  auto it = std::begin( vout );
10749  for( const auto& seg: vsegs )
10750  *it++ = getCenter( seg );
10751  return vout;
10752 }
Segment seg
Definition: homog2d_test.cpp:4033
Point2d_< typename T::FType > getCenter(const T &other)
Return center of Segment_, FRect_, or Ellipse_ (free function)
Definition: homog2d.hpp:11005
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getClosestPoints()

template<typename PLT1 , typename FPT1 , typename PLT2 , typename FPT2 >
priv::ClosestPoints< PLT1, FPT1, PLT2, FPT2 > h2d::getClosestPoints ( const base::PolylineBase< PLT1, FPT1 > &  poly1,
const base::PolylineBase< PLT2, FPT2 > &  poly2 
)

Computes the closest points between two polylines (types can be different)

10596 {
10597 #ifndef HOMOG2D_NOCHECKS
10598  if( poly1.size() == 0 )
10599  HOMOG2D_THROW_ERROR_1( "arg 1 is empty" );
10600  if( poly2.size() == 0 )
10601  HOMOG2D_THROW_ERROR_1( "arg 2 is empty" );
10602 #endif
10603  priv::ClosestPoints<PLT1,FPT1,PLT2,FPT2> out( poly1, poly2 );
10604  for( size_t i=0; i<poly1.size(); i++ )
10605  {
10606  const auto& pt1 = poly1.getPoint(i);
10607  for( size_t j=0; j<poly2.size(); j++ )
10608  {
10609  const auto& pt2 = poly2.getPoint(j);
10610  auto currentDist = dist( pt1, pt2 );
10611  if( currentDist < out._minDist )
10612  out.store( currentDist, i, j );
10613  }
10614  }
10615  return out;
10616 }
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCvPtd()

template<typename FPT >
cv::Point2d h2d::getCvPtd ( const Point2d_< FPT > &  pt)

Free function to return an OpenCv point (double)

4594 {
4595  return pt.getCvPtd();
4596 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCvPtf()

template<typename FPT >
cv::Point2f h2d::getCvPtf ( const Point2d_< FPT > &  pt)

Free function to return an OpenCv point (float)

4601 {
4602  return pt.getCvPtf();
4603 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCvPti()

template<typename FPT >
cv::Point2i h2d::getCvPti ( const Point2d_< FPT > &  pt)

Free function to return an OpenCv point (integer)

4608 {
4609  return pt.getCvPti();
4610 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDiagonals()

template<typename FPT >
std::pair<Segment_<FPT>,Segment_<FPT> > h2d::getDiagonals ( const FRect_< FPT > &  rect)

Free function.

10900 {
10901  return rect.getDiagonals();
10902 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExtended() [1/2]

template<typename FPT >
Segment_<FPT> h2d::getExtended ( const Segment_< FPT > &  seg)

Returns Extended Segment (free function)

See also
Segment_::geExtended()
10642 {
10643  return seg.getExtended();
10644 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExtended() [2/2]

template<typename FPT >
FRect_<FPT> h2d::getExtended ( const FRect_< FPT > &  rect)

Free function.

10892 {
10893  return rect.getExtended();
10894 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:

◆ getExtremePoint()

template<typename T >
auto h2d::getExtremePoint ( CardDir  dir,
const T &  t 
)

Get Top-most / Bottom-most / Left-most / Right-most point, depending on dir (free function)

Type T can be either a Polyline (open or closed), or a container holding points, or a FRect_

7097 {
7098  switch( dir )
7099  {
7100  case CardDir::Top: return getTmPoint(t); break;
7101  case CardDir::Bottom: return getBmPoint(t); break;
7102  case CardDir::Left: return getLmPoint(t); break;
7103  case CardDir::Right: return getRmPoint(t); break;
7104  default: assert(0);
7105  }
7106 }
Point2d_< FPT > getTmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Top-most point of Polyline (free function)
Definition: homog2d.hpp:7069
Point2d_< FPT > getBmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Bottom-most point of Polyline (free function)
Definition: homog2d.hpp:7062
Point2d_< FPT > getRmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Right-most point of Polyline (free function)
Definition: homog2d.hpp:7083
Point2d_< FPT > getLmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Left-most point of Polyline (free function)
Definition: homog2d.hpp:7076
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFRect()

template<typename FPT >
FRect_<FPT> h2d::getFRect ( cv::Mat &  mat)
4578 {
4579  if( mat.cols == 0 || mat.rows == 0 )
4581  "Illegal values: cols=" << mat.cols << ", rows=" << mat.rows
4582  );
4583 
4584  return FRect_<FPT>(
4585  Point2d_<FPT>(), // (0,0)
4586  Point2d_<FPT>( mat.cols, mat.rows ) // (w,h)
4587  );
4588 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181

◆ getInscribedCircle()

template<typename FPT >
Circle_<FPT> h2d::getInscribedCircle ( const FRect_< FPT > &  rect)

Return circle inscribed in rectangle.

See also
hFRect_::getInscribedCircle()
9899 {
9900  return rect.getInscribedCircle();
9901 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:

◆ getLine() [1/2]

template<typename FPT >
Line2d_<FPT> h2d::getLine ( const Segment_< FPT > &  seg)

Returns Segment supporting line (free function)

See also
Segment_::getLine()
10633 {
10634  return seg.getLine();
10635 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLine() [2/2]

template<typename FPT1 , typename FPT2 , typename FPT3 >
Line2d_<FPT1> h2d::getLine ( const Circle_< FPT2 > &  c1,
const Circle_< FPT3 > &  c2 
)

Free function, returns line between two circle centers.

10698 {
10699  return Line2d_<FPT1>( c1.center(), c2.center() );
10700 }
Here is the call graph for this function:

◆ getLines()

template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
auto h2d::getLines ( const T &  vsegs)

Free function, returns a set of lines from a set of segments.

See also
Segment_::getLine()
10767 {
10768  std::vector<Line2d_<typename T::value_type::FType>> vout( vsegs.size() );
10769 
10770  auto it = std::begin( vout );
10771  for( const auto& seg: vsegs )
10772  *it++ = seg.getLine();
10773  return vout;
10774 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the caller graph for this function:

◆ getLmPoint() [1/2]

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

Return Left-most point of container as a pair holding:

  • first: the point
  • second: the distance (index) from begin position
Todo:
20250222: CHANGE RETURN TYPE! => should return an iterator, not a pair (so this allows usage of any non-random access container)
6989 {
6990  using FPT = typename T::value_type::FType;
6991 
6992 #ifndef HOMOG2D_NOCHECKS
6993  if( t.size() == 0 )
6994  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6995 #endif
6996 
6997  auto it = std::min_element(
6998  std::begin(t),
6999  std::end(t),
7000  [] // lambda
7001  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
7002  {
7003  if( pt1.getX() < pt2.getX() )
7004  return true;
7005  if( pt1.getX() > pt2.getX() )
7006  return false;
7007  return( pt1.getY() < pt2.getY() );
7008  }
7009  );
7010 
7011  return std::make_pair(
7012  *it,
7013  std::distance( std::begin(t), it )
7014  );
7015 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLmPoint() [2/2]

template<typename PLT , typename FPT >
Point2d_<FPT> h2d::getLmPoint ( const base::PolylineBase< PLT, FPT > &  poly)

Return Left-most point of Polyline (free function)

7077 {
7078  return getLmPoint( poly.getPts() ).first;
7079 }
Point2d_< FPT > getLmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Left-most point of Polyline (free function)
Definition: homog2d.hpp:7076
Here is the call graph for this function:

◆ getMinMax()

template<typename T1 , typename T2 , typename T3 , typename T4 >
auto h2d::getMinMax ( const PointPair2_< T1, T2 > &  pp1,
const PointPair2_< T3, T4 > &  pp2 
)

Returns a pair of points holding min and max coordinates of the two input pair of points.

Tests: search for [minmax]

10400 {
10401  HOMOG2D_START;
10402 
10403  std::array<Point2d_<HOMOG2D_INUMTYPE>,4> arr;
10404  arr[0] = pp1.first;
10405  arr[1] = pp2.first;
10406  arr[2] = pp1.second;
10407  arr[3] = pp2.second;
10408 
10409  return priv::getBB_Points( arr );
10410 }
PointPair_< typename T::value_type::FType > getBB_Points(const T &vpts)
Returns the bounding box of points in vector/list/array of points vpts (free function) ...
Definition: homog2d.hpp:5904
#define HOMOG2D_START
Definition: homog2d.hpp:106
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOBB()

template<typename FPT >
CPolyline_<FPT> h2d::getOBB ( const Ellipse_< FPT > &  ell)

Returns Bounding Box of Ellipse_ (free function)

See also
Ellipse_::getBB()
9967 {
9968  return ell.getOBB();
9969 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrthogPts()

template<typename FPT >
std::array<Point2d_<FPT>,4> h2d::getOrthogPts ( const Segment_< FPT > &  seg)

Returns the 4 orthogonal points to the segment.

See also
Segment_::getOrthogPts()
10681 {
10682  return seg.getOrthogPts();
10683 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrthogSegs()

template<typename FPT >
std::array<Segment_<FPT>,4> h2d::getOrthogSegs ( const Segment_< FPT > &  seg)

Returns the 4 orthogonal segments to the segment.

See also
Segment_::getOrthogSegs()
10672 {
10673  return seg.getOrthogSegs();
10674 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParallelDistance()

template<typename FPT >
HOMOG2D_INUMTYPE h2d::getParallelDistance ( const Line2d_< FPT > &  li1,
const Line2d_< FPT > &  li2 
)

Returns the distance between 2 parallel lines (free function)

We first check that the two lines are indeed parallel. This should ensure that a1=a2 and b1=b2. But due to numeric issues they could by slightly different. In order to gain accuracy, we use the geometric mean of these.

10971 {
10972 #ifndef HOMOG2D_NOCHECKS
10973  if( !li1.isParallelTo(li2) )
10974  HOMOG2D_THROW_ERROR_1( "lines are not parallel" );
10975 #endif
10976  const auto ar1 = li1.get();
10977  const auto ar2 = li2.get();
10978  const HOMOG2D_INUMTYPE a1 = ar1[0];
10979  const HOMOG2D_INUMTYPE b1 = ar1[1];
10980  const HOMOG2D_INUMTYPE c1 = ar1[2];
10981  const HOMOG2D_INUMTYPE a2 = ar2[0];
10982  const HOMOG2D_INUMTYPE b2 = ar2[1];
10983  const HOMOG2D_INUMTYPE c2 = ar2[2];
10984 
10985  HOMOG2D_INUMTYPE a = homog2d_sqrt( a1*a2 );
10986  HOMOG2D_INUMTYPE b = homog2d_sqrt( b1*b2 );
10987  return homog2d_abs( c1 - c2 ) / homog2d_sqrt( a*a + b*b );
10988 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define homog2d_abs
Definition: homog2d.hpp:69
#define homog2d_sqrt
Definition: homog2d.hpp:75
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParallelLines()

template<typename FPT , typename T >
std::pair<Line2d_<FPT>,Line2d_<FPT> > h2d::getParallelLines ( const Line2d_< FPT > &  li,
dist 
)

Returns the 2 parallel lines at distance dist from li (free function)

8471 {
8472  return li.getParallelLines( dist );
8473 }
Line2d li
Definition: homog2d_test.cpp:4035
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9848
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParallelSegs()

template<typename FPT , typename T >
std::pair<Segment_<FPT>,Segment_<FPT> > h2d::getParallelSegs ( const Segment_< FPT > &  seg,
dist 
)

Free function, returns a pair of parallel segments at a distance dist.

See also
Segment_::getBisector()
10725 {
10726  return seg.getParallelSegs(dist);
10727 }
Segment seg
Definition: homog2d_test.cpp:4033
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9848
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPt()

template<typename RT , typename FPT >
RT h2d::getPt ( const Point2d_< FPT > &  pt)

Generic free function to return a point of other type.

  • RT: return type
  • FPT: Floating Point Type

User code needs to provide the requested type as template argument, for example:

auto p1 = getPt<cv::Point2di>( pt ); // opencv type
auto p2 = getPt<boost::geometry::model::point_xy<double>>( pt ); // boost geometry type
See also
LPBase::getPt()
4644 {
4645  return pt.template getPt<RT>();
4646 }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ getPts() [1/3]

template<typename RT , typename FPT >
std::vector<RT> h2d::getPts ( const std::vector< Point2d_< FPT >> &  vpt)

Free function, returns a vector of points of other type from a vector of h2d points.

  • RT: return type
  • FPT: Floating Point Type

User code needs to provide the requested type as template argument.

See also
h2d::getPt<>()
Todo:
20230219: sfinae this to accept other containers using trait::IsContainer
4663 {
4664  std::vector<RT> vout( vpt.size() );
4665  auto it = vout.begin();
4666  for( const auto& pt: vpt )
4667  *it++ = getPt<RT>(pt);
4668  return vout;
4669 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the caller graph for this function:

◆ getPts() [2/3]

template<typename FPT >
auto h2d::getPts ( const Segment_< FPT > &  seg)

Returns the points of Segment as a std::pair (free function)

See also
Segment_::getPts()
10624 {
10625  return seg.getPts();
10626 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ getPts() [3/3]

template<typename FPT >
auto h2d::getPts ( const FRect_< FPT > &  rect)

Returns the 2 major points of the rectangle (free function)

See also
FRect_::getPts()
10868 {
10869  return rect.getPts();
10870 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:

◆ getPtsInside()

template<typename CONT , typename PRIM >
CONT h2d::getPtsInside ( const CONT &  input_set,
const PRIM &  prim 
)

Returns set of points that are inside primitive prim.

Output container will be of same type as input container (vector, list or array

Todo:
20250123: maybe replace the bunch of static_asserts with something around trait::HasArea ?
Parameters
primgeometrical primitive (FRect, Circle, ...?)
11219 {
11220  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_OPol>, "Cannot find points inside a Open Polyline" );
11221  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_Line>, "Cannot find points inside a Line" );
11222  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_Point>, "Cannot find points inside a Point" );
11223  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_Segment>, "Cannot find points inside a Segment" );
11224  static_assert( !trait::IsArray<CONT>::value, "Cannot use std::array as container" );
11225 
11226  CONT out;
11227  out.reserve( input_set.size() );
11228 
11229  for( auto pt: input_set )
11230  if( pt.isInside( prim ) )
11231  out.push_back( pt );
11232  return out;
11233 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:

◆ getRmPoint() [1/2]

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

Return Right-most point of container holding points.

7030 {
7031  using FPT = typename T::value_type::FType;
7032 
7033 #ifndef HOMOG2D_NOCHECKS
7034  if( t.size() == 0 )
7035  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
7036 #endif
7037 
7038  auto it = std::min_element(
7039  std::begin(t),
7040  std::end(t),
7041  [] // lambda
7042  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
7043  {
7044  if( pt1.getX() > pt2.getX() )
7045  return true;
7046  if( pt1.getX() < pt2.getX() )
7047  return false;
7048  return( pt1.getY() < pt2.getY() );
7049  }
7050  );
7051 
7052  return std::make_pair(
7053  *it,
7054  std::distance( std::begin(t), it )
7055  );
7056 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRmPoint() [2/2]

template<typename PLT , typename FPT >
Point2d_<FPT> h2d::getRmPoint ( const base::PolylineBase< PLT, FPT > &  poly)

Return Right-most point of Polyline (free function)

7084 {
7085  return getRmPoint( poly.getPts() ).first;
7086 }
Point2d_< FPT > getRmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Right-most point of Polyline (free function)
Definition: homog2d.hpp:7083
Here is the call graph for this function:

◆ getSegment()

template<typename T1 , typename T2 >
Segment_<typename T1::FType> h2d::getSegment ( const T1 &  c1,
const T2 &  c2 
)

Free function, returns segment between two circle centers (or ellipse)

10690 {
10691  return Segment_<typename T1::FType>( c1.getCenter(), c2.getCenter() );
10692 }
Here is the caller graph for this function:

◆ getSegs() [1/2]

template<typename PLT , typename FPT >
std::vector<Segment_<FPT> > h2d::getSegs ( const base::PolylineBase< PLT, FPT > &  pl)

Returns the segments of the polyline (free function)

See also
PolylineBase::getSegs()
9939 {
9940  return pl.getSegs();
9941 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSegs() [2/2]

template<typename FPT >
std::array<Segment_<FPT>,4> h2d::getSegs ( const FRect_< FPT > &  seg)

Free function, returns segments of the rectangle.

See also
FRect_::getSegs()
10781 {
10782  return seg.getSegs();
10783 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ getString() [1/3]

const char* h2d::getString ( Type  t)
inline

Returns stringified version of type()

949 {
950  const char* s=0;
951  switch( t )
952  {
953  case Type::Line2d: s="Line2d"; break;
954  case Type::Point2d: s="Point2d"; break;
955  case Type::Segment: s="Segment"; break;
956  case Type::OSegment: s="OSegment"; break;
957  case Type::FRect: s="FRect"; break;
958  case Type::Circle: s="Circle"; break;
959  case Type::Ellipse: s="Ellipse"; break;
960  case Type::OPolyline: s="OPolyline"; break;
961  case Type::CPolyline: s="CPolyline"; break;
962  assert(0);
963  }
964  return s;
965 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12400
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12396
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12389
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12393
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12377
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12390
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12403
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12399
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12380
Here is the caller graph for this function:

◆ getString() [2/3]

const char* h2d::getString ( Dtype  t)
inline
1118 {
1119  const char* s=0;
1120  switch( t )
1121  {
1122  case Dtype::Float: s="Float"; break;
1123  case Dtype::Double: s="Double"; break;
1124  case Dtype::LongDouble: s="LongDouble"; break;
1125  case Dtype::Other: s="Other"; break;
1126 #ifdef HOMOG2D_USE_TTMATH
1127  case Dtype::Ttmath: s="ttmath"; break;
1128 #endif
1129  assert(0);
1130  }
1131  return s;
1132 }

◆ getString() [3/3]

const char* h2d::getString ( PointSide  t)
inline
4834 {
4835  const char* s=0;
4836  switch( t )
4837  {
4838  case PointSide::Left: s="Left"; break;
4839  case PointSide::Right: s="Right"; break;
4840  case PointSide::Neither: s="Neither"; break;
4841  assert(0);
4842  }
4843  return s;
4844 }

◆ getTanSegs()

template<typename FPT1 , typename FPT2 >
std::pair<Segment_<FPT1>,Segment_<FPT1> > h2d::getTanSegs ( const Circle_< FPT1 > &  c1,
const Circle_< FPT2 > &  c2 
)

Free function, returns the pair of segments tangential to the two circles.

Sources:

10795 {
10796 #ifndef HOMOG2D_NOCHECKS
10797  if( c1 == c2 )
10798  HOMOG2D_THROW_ERROR_1( "c1 and c2 identical" );
10799 #endif
10800 
10801 // if same radius, return the two segments parallel to the one joining the centers
10802  if( homog2d_abs( c1.radius() - c2.radius() ) < thr::nullDistance() )
10803  {
10804  Segment_<HOMOG2D_INUMTYPE> seg_center( c1.center(), c2.center() );
10805  return seg_center.getParallelSegs( c1.radius() );
10806  }
10807 
10808 // check which one is the smallest
10809  Circle_<HOMOG2D_INUMTYPE> cA = c1;
10810  Circle_<HOMOG2D_INUMTYPE> cB = c2;
10811  if( c1.radius() < c2.radius() )
10812  std::swap( cA, cB );
10813 
10814  auto h = dist( cA.center(), cB.center() );
10815 
10816  auto theta = homog2d_asin( ( cA.radius() - cB.radius() ) / h ) ;
10817  auto hcost = h * homog2d_cos(theta);
10818 
10819 // get rotated lines at center of CB
10820  auto l0 = cA.center() * cB.center();
10821  auto l1 = l0.getRotatedLine( cB.center(), theta );
10822  auto l2 = l0.getRotatedLine( cB.center(), -theta );
10823 
10824 // build segments by getting the opposite point
10825 
10826  auto ppts1 = l1.getPoints( cB.center(), hcost );
10827  auto p1 = ppts1.first;
10828  if( ppts1.second.distTo( cA.center()) < p1.distTo( cA.center()) )
10829  p1 = ppts1.second;
10830 
10831  auto ppts2 = l2.getPoints( cB.center(), hcost );
10832  auto p2 = ppts2.first;
10833  if( ppts2.second.distTo( cA.center()) < p2.distTo( cA.center()) )
10834  p2 = ppts2.second;
10835 // std::cout <<"p1=" << p1 << " p2=" << p2 << '\n';
10836 
10837  auto seg1 = Segment_<HOMOG2D_INUMTYPE>( p1, cB.center() );
10838  auto seg2 = Segment_<HOMOG2D_INUMTYPE>( p2, cB.center() );
10839 
10840  auto psegs1 = seg1.getParallelSegs( cB.radius() );
10841  if( psegs1.first.distTo(cA.center()) < psegs1.second.distTo(cA.center()) )
10842  std::swap( psegs1.first, psegs1.second );
10843 
10844  auto psegs2 = seg2.getParallelSegs( cB.radius() );
10845  if( psegs2.second.distTo(cA.center()) < psegs2.first.distTo(cA.center()) )
10846  std::swap( psegs2.first, psegs2.second );
10847 
10848  return std::make_pair(
10849  psegs1.first,
10850  psegs2.second
10851  );
10852 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
#define homog2d_asin
Definition: homog2d.hpp:73
#define homog2d_abs
Definition: homog2d.hpp:69
#define homog2d_cos
Definition: homog2d.hpp:71
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTmPoint() [1/2]

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

Return Top-most point of container.

6942 {
6943  using FPT = typename T::value_type::FType;
6944 
6945 #ifndef HOMOG2D_NOCHECKS
6946  if( t.size() == 0 )
6947  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6948 #endif
6949 
6950  auto it = std::min_element(
6951  std::begin(t),
6952  std::end(t),
6953  [] // lambda
6954  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
6955  {
6956  if( pt1.getY() > pt2.getY() )
6957  return true;
6958  if( pt1.getY() < pt2.getY() )
6959  return false;
6960  return( pt1.getX() < pt2.getX() );
6961  }
6962  );
6963  return std::make_pair(
6964  *it,
6965  std::distance( std::begin(t), it )
6966  );
6967 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTmPoint() [2/2]

template<typename PLT , typename FPT >
Point2d_<FPT> h2d::getTmPoint ( const base::PolylineBase< PLT, FPT > &  poly)

Return Top-most point of Polyline (free function)

7070 {
7071  return getTmPoint( poly.getPts() ).first;
7072 }
Point2d_< FPT > getTmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Top-most point of Polyline (free function)
Definition: homog2d.hpp:7069
Here is the call graph for this function:

◆ getX()

template<typename FPT >
FPT h2d::getX ( const Point2d_< FPT > &  pt)
9821 { return pt.getX(); }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getY()

template<typename FPT >
FPT h2d::getY ( const Point2d_< FPT > &  pt)
9824 { return pt.getY(); }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ height()

template<typename FPT >
HOMOG2D_INUMTYPE h2d::height ( const FRect_< FPT > &  rect)

Free function.

10876 {
10877  return rect.height();
10878 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersectArea()

template<typename FPT1 , typename FPT2 >
detail::RectArea<FPT1> h2d::intersectArea ( const FRect_< FPT1 > &  r1,
const FRect_< FPT2 > &  r2 
)

Free function, see FRect_::intersectArea()

9879 {
9880  return r1.intersectArea(r2);
9881 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IoU()

template<typename FPT1 , typename FPT2 >
HOMOG2D_INUMTYPE h2d::IoU ( const FRect_< FPT1 > &  r1,
const FRect_< FPT2 > &  r2 
)

Intersection area over Union area (free function)

9858 {
9859  auto ia = intersectArea( r1, r2 );
9860  if( ia() )
9861  return ia.get().area() / unionArea( r1, r2 ).area();
9862  return 0.;
9863 }
CPolyline_< FPT1 > unionArea(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Free function, see FRect_::unionArea()
Definition: homog2d.hpp:9869
detail::RectArea< FPT1 > intersectArea(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Free function, see FRect_::intersectArea()
Definition: homog2d.hpp:9878
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCircle()

template<typename FPT >
bool h2d::isCircle ( const Ellipse_< FPT > &  ell,
HOMOG2D_INUMTYPE  thres = 1.E-10 
)

Returns true if ellipse is a circle.

See also
Ellipse_::isCircle()
11058 {
11059  return ell.isCircle( thres );
11060 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isConvex()

template<typename PLT , typename FPT >
bool h2d::isConvex ( const base::PolylineBase< PLT, FPT > &  poly)

Returns true if polygon is convex (free function)

See also
PolylineBase::isConvex()
9919 {
9920  return poly.isConvex();
9921 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSimple()

template<typename PLT , typename FPT >
bool h2d::isSimple ( const base::PolylineBase< PLT, FPT > &  pl)

Returns true if is a polygon (free function)  

See also
PolylineBase::isSimple()
9909 {
9910  return pl.isSimple();
9911 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ moveTo() [1/2]

template<typename T , typename FP >
void h2d::moveTo ( T &  prim,
const Point2d_< FP > &  pt 
)

Move primitive to other location (free function)

Calls the member function. Type checking is done there.

11039 {
11040  prim.moveTo( pt );
11041 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the caller graph for this function:

◆ moveTo() [2/2]

template<typename T , typename FP1 , typename FP2 >
void h2d::moveTo ( T &  prim,
FP1  x,
FP2  y 
)

Move primitive to other location (free function)

Calls the member function. Type checking is done there.

11049  {
11050  prim.moveTo( x, y );
11051  }

◆ nbSegs()

template<typename PLT , typename FPT >
size_t h2d::nbSegs ( const base::PolylineBase< PLT, FPT > &  pl)

Returns the number of segments (free function)

See also
PolylineBase::nbSegs()
9929 {
9930  return pl.nbSegs();
9931 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*() [1/14]

template<typename T , typename U >
Line2d_< T > h2d::operator* ( const Homogr_< U > &  h,
const Line2d_< T > &  in 
)

Free function, apply homography to a line.

9676 {
9677  if( h._hmt == nullptr ) // if H^-T not allocated yet, do it
9678  {
9679  h._hmt = std::unique_ptr<detail::Matrix_<U>>( new detail::Matrix_<U>() );
9680  h._hasChanged = true;
9681  }
9682 
9683  if( h._hasChanged ) // if homography has changed, recompute inverse and transposed
9684  {
9685  auto hi = h;
9686  auto mat_inv = hi.inverse().transpose();
9687  *h._hmt = mat_inv;
9688  h._hasChanged = false;
9689  }
9690 
9691  Line2d_<T> out;
9692  detail::product( out, *h._hmt, in );
9693  out.p_normalizePL();
9694  return out;
9695 }
void product(base::LPBase< T1, FPT1 > &, const detail::Matrix_< FPT2 > &, const base::LPBase< T2, FPT1 > &)
Implementation of product 3x3 by 3x1.
Definition: homog2d.hpp:9605
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*() [2/14]

template<typename FPT , typename FPT2 >
Line2d_<FPT> h2d::operator* ( const Point2d_< FPT > &  lhs,
const Point2d_< FPT2 > &  rhs 
)

Free function template, product of two points, returns a line.

3666 {
3667 #ifndef HOMOG2D_NOCHECKS
3668  if( lhs == rhs )
3669  HOMOG2D_THROW_ERROR_1( "points are identical, unable to compute product:" << lhs );
3670 #endif
3671  Line2d_<FPT> line = detail::crossProduct<typ::IsLine,typ::IsPoint,FPT>(lhs, rhs);
3672  line.p_normalizePL();
3673  return line;
3674 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181

◆ operator*() [3/14]

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

◆ operator*() [4/14]

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

◆ operator*() [5/14]

template<typename FPT1 , typename FPT2 >
CPolyline_< FPT1 > h2d::operator* ( const Homogr_< FPT2 > &  h,
const FRect_< FPT1 > &  rin 
)

Apply homography to a flat rectangle produces a closed polyline.

9724 {
9726  for( const auto& pt: rin.get4Pts() )
9727  out.p_addPoint( h * pt );
9728  return out;
9729 }
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:

◆ operator*() [6/14]

template<typename FPT1 , typename FPT2 , typename PLT2 >
auto h2d::operator* ( const Homogr_< FPT2 > &  ,
const base::PolylineBase< PLT2, FPT1 > &   
) -> base::PolylineBase< PLT2, FPT1 >
Todo:
20230215: check if this has to be moved in the 'base' namespace. Can it be called without using namespace std;. This was the case for the streaming operator...

◆ operator*() [7/14]

template<typename FPT , typename FPT2 >
Point2d_<FPT> h2d::operator* ( const Line2d_< FPT > &  lhs,
const Line2d_< FPT2 > &  rhs 
)

Free function template, product of two lines, returns a point.

9630 {
9631 #ifndef HOMOG2D_NOCHECKS
9632  if( lhs.isParallelTo(rhs) )
9633  HOMOG2D_THROW_ERROR_1( "lines are parallel, unable to compute product:\nlhs="
9634  << lhs << " rhs=" << rhs
9635  );
9636 #endif
9637 
9638  return detail::crossProduct<typ::IsPoint,typ::IsLine,FPT>(lhs, rhs);
9639 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the call graph for this function:

◆ operator*() [8/14]

template<typename SV1 , typename SV2 , typename FPT1 , typename FPT2 >
Point2d_<FPT1> h2d::operator* ( const base::SegVec< SV1, FPT1 > &  lhs,
const base::SegVec< SV2, FPT2 > &  rhs 
)

Free function template, product of two segments/vector, returns a point.

9645 {
9646  return lhs.getLine() * rhs.getLine();
9647 }
Here is the call graph for this function:

◆ operator*() [9/14]

template<typename T , typename U >
Point2d_<T> h2d::operator* ( const Homogr_< U > &  h,
const Point2d_< T > &  in 
)

Free function, apply homography to a point.

9666 {
9667  Point2d_<T> out;
9668  detail::product( out, h, in );
9669  return out;
9670 }
void product(base::LPBase< T1, FPT1 > &, const detail::Matrix_< FPT2 > &, const base::LPBase< T2, FPT1 > &)
Implementation of product 3x3 by 3x1.
Definition: homog2d.hpp:9605
Here is the call graph for this function:

◆ operator*() [10/14]

template<typename SV , typename FPT1 , typename FPT2 >
Segment_<FPT1> h2d::operator* ( const Homogr_< FPT1 > &  h,
const base::SegVec< SV, FPT2 > &  seg 
)

Apply homography to a Segment.

9701 {
9702  const auto& pts = seg.getPts();
9703  Point2d_<FPT1> pt1 = h * pts.first;
9704  Point2d_<FPT1> pt2 = h * pts.second;
9705  return base::SegVec<SV,FPT2>( pt1, pt2 );
9706 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ operator*() [11/14]

template<typename FPT1 , typename FPT2 , typename PLT >
base::PolylineBase<PLT,FPT1> h2d::operator* ( const Homogr_< FPT2 > &  h,
const base::PolylineBase< PLT, FPT1 > &  pl 
)

Apply homography to a Polyline.

9712 {
9713  base::PolylineBase<PLT,FPT1> out;
9714  const auto& pts = pl.getPts();
9715  for( const auto& pt: pts )
9716  out.p_addPoint( h * pt );
9717  return out;
9718 }
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:

◆ operator*() [12/14]

template<typename FPT1 , typename FPT2 >
Ellipse_<FPT1> h2d::operator* ( const Homogr_< FPT2 > &  h,
const Ellipse_< FPT1 > &  ell_in 
)

Apply homography to a Ellipse, produces an Ellipse.

\[ Q' = H^{-T} \cdot Q \cdot H^{-1} \]

9740 {
9741  auto hm = static_cast<detail::Matrix_<HOMOG2D_INUMTYPE>>(h);
9742  hm.inverse();
9743  auto hmt = hm;
9744  hmt.transpose();
9745 
9746  const auto& ell_in2 = static_cast<detail::Matrix_<FPT1>>(ell_in);
9747  auto prod = hmt * ell_in2 * hm;
9748 
9749  Ellipse_<FPT1> out( prod );
9750  return out;
9751 }
Here is the call graph for this function:

◆ operator*() [13/14]

template<typename FPT1 , typename FPT2 >
Ellipse_<FPT1> h2d::operator* ( const Homogr_< FPT2 > &  h,
const Circle_< FPT1 > &  cir 
)

Apply homography to a Circle, produces an Ellipse.

Converts the circle to an ellipse, then calls the corresponding code

9758 {
9759  Ellipse_<FPT1> ell_in( cir );
9760  return h * ell_in;
9761 }
Circle cir
Definition: homog2d_test.cpp:4036

◆ operator*() [14/14]

template<typename FPT , typename Cont >
std::enable_if<trait::IsContainer<Cont>::value,Cont>::type h2d::operator* ( const Hmatrix_< typ::IsHomogr, FPT > &  h,
const Cont &  vin 
)

Used to proceed multiple products, whatever the container (std::list, std::vector, or std::array). Returned container is of same type as given input.

Parameters
hMatrix
vinInput container
9808 {
9809  Cont vout = priv::alloc<Cont>( vin.size() );
9810  auto it = std::begin( vout );
9811  for( const auto& elem: vin )
9812  *it++ = h * elem;
9813  return vout;
9814 }

◆ operator<<() [1/5]

template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr>
std::ostream& h2d::operator<< ( std::ostream &  f,
const T &  vec 
)

Stream operator for a container of points/lines, free function.

8391 {
8392  f << "#="<< vec.size() << '\n';
8393  for( const auto& elem: vec )
8394  f << elem << '\n';
8395  return f;
8396 }
Here is the caller graph for this function:

◆ operator<<() [2/5]

template<typename LP1 , typename LP2 , typename FPT >
std::ostream& h2d::operator<< ( std::ostream &  f,
const std::pair< base::LPBase< LP1, FPT >, base::LPBase< LP2, FPT >> &  pr 
)

Stream operator for a pair of points/lines, free function.

8402 {
8403  f << "std::pair (" << getString(pr.first.type()) << "-" << getString(pr.second.type())
8404  << "):\n -first=" << pr.first
8405  << "\n -second=" << pr.second
8406  << ' ';
8407  return f;
8408 }
const char * getString(PointSide t)
Definition: homog2d.hpp:4833
Here is the call graph for this function:

◆ operator<<() [3/5]

template<typename T >
std::ostream& h2d::operator<< ( std::ostream &  f,
const FRect_< T > &  r 
)
8413 {
8414  f << "pt1: " << r._ptR1 << " pt2: " << r._ptR2;
8415  return f;
8416 }

◆ operator<<() [4/5]

template<typename T >
std::ostream& h2d::operator<< ( std::ostream &  f,
const Circle_< T > &  r 
)
8421 {
8422  f << "center: " << r._center << ", radius=" << r._radius;
8423  return f;
8424 }

◆ operator<<() [5/5]

template<typename T >
std::ostream& h2d::operator<< ( std::ostream &  f,
const Ellipse_< T > &  ell 
)
8460 {
8461  auto par = ell.template p_getParams<HOMOG2D_INUMTYPE>();
8462  f << par;
8463  return f;
8464 }
Ellipse ell
Definition: homog2d_test.cpp:4037

◆ radius() [1/2]

template<typename FPT >
FPT& h2d::radius ( Circle_< FPT > &  cir)

Returns reference on radius of circle (free function), non-const version.

See also
Circle_::radius()
10918 {
10919  return cir.radius();
10920 }
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function:
Here is the caller graph for this function:

◆ radius() [2/2]

template<typename FPT >
const FPT& h2d::radius ( const Circle_< FPT > &  cir)

Returns reference on radius of circle (free function), const version.

See also
Circle_::radius()
10927 {
10928  return cir.radius();
10929 }
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function:

◆ rotate() [1/2]

template<typename T >
void h2d::rotate ( T &  prim,
Rotate  rot 
)

Rotates the primitive (only available for Polyline and FRect) around (0,0)

9948 {
9949  prim.rotate( rot );
9950 }
Here is the caller graph for this function:

◆ rotate() [2/2]

template<typename T , typename FPT >
void h2d::rotate ( T &  prim,
Rotate  rot,
const Point2d_< FPT > &  refpt 
)

Rotates the primitive (only available for Polyline and FRect) around refpt.

9957 {
9958  prim.rotate( rot, refpt );
9959 }
Here is the caller graph for this function:

◆ side()

template<typename FPT1 , typename FPT2 >
int h2d::side ( const Point2d_< FPT1 > &  pt,
const Line2d_< FPT2 > &  li 
)

Free function, returns -1 or +1 depending on the side of pt, related to li.

9831 {
9832  const auto& arr = li.get();
9833  HOMOG2D_INUMTYPE a = arr[0];
9834  HOMOG2D_INUMTYPE b = arr[1];
9835  HOMOG2D_INUMTYPE c = arr[2];
9836 
9837  auto dist = a * pt.getX() + b * pt.getY() + c;
9839  return 0;
9840  return (std::signbit( dist ) ? -1 : +1);
9841 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define homog2d_abs
Definition: homog2d.hpp:69
Line2d li
Definition: homog2d_test.cpp:4035
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9848
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ split() [1/2]

template<typename SV , typename FPT >
std::pair<base::SegVec<SV,FPT>,base::SegVec<SV,FPT> > h2d::split ( const base::SegVec< SV, FPT > &  seg)

Returns a pair of segments, corresponding to the input segment split by middle point (free function)

See also
Segment_::split()
10651 {
10652  return seg.split();
10653 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:
Here is the caller graph for this function:

◆ split() [2/2]

template<typename FPT , typename T >
std::pair<OSegment_<FPT>,OSegment_<FPT> > h2d::split ( const OSegment_< FPT > &  seg,
dist 
)

Returns a pair of segments, corresponding to the input segment split by point at distance dist (free function)

Note
: can only be used on oriented segments
See also
Segment_::split( T )
10661 {
10663  return seg.split( dist );
10664 }
Segment seg
Definition: homog2d_test.cpp:4033
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
Here is the call graph for this function:

◆ translate() [1/2]

template<typename T , typename FP1 , typename FP2 >
void h2d::translate ( T &  prim,
FP1  dx,
FP2  dy 
)

Translate primitive prim (free function)

Calls the member function. Type checking is done there.

11017 {
11018  prim.translate( dx, dy );
11019 }
Here is the caller graph for this function:

◆ translate() [2/2]

template<typename T , typename FP1 , typename FP2 >
void h2d::translate ( T &  prim,
const std::pair< FP1, FP2 > &  ppt 
)

Translate primitive prim with values in a std::pair (free function)

Calls the member function. Type checking is done there.

11028 {
11029  prim.translate( ppt.first, ppt.second );
11030 }

◆ unionArea()

template<typename FPT1 , typename FPT2 >
CPolyline_<FPT1> h2d::unionArea ( const FRect_< FPT1 > &  r1,
const FRect_< FPT2 > &  r2 
)

Free function, see FRect_::unionArea()

9870 {
9871  return r1.unionArea(r2);
9872 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ width()

template<typename FPT >
HOMOG2D_INUMTYPE h2d::width ( const FRect_< FPT > &  rect)

Free function.

10884 {
10885  return rect.width();
10886 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:
Here is the caller graph for this function: