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:12403
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12399
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12392
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12396
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12380
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12393
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12406
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12402
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12383

Function Documentation

◆ angle()

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

Return angle of ellipse (free function)

See also
Ellipse_::angle()
10998 {
10999  return ell.angle();
11000 }
Ellipse ell
Definition: homog2d_test.cpp:4055
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
3688 {
3689  if( pt1 == pt2 || pt2 == pt3 || pt1 == pt3 )
3690  return true;
3691 
3692  auto pt_arr = priv::getLargestDistancePoints( pt1, pt2, pt3 );
3693 
3694  auto li = pt_arr[0] * pt_arr[1];
3695  if( li.distTo( pt_arr[2] ) < thr::nullDistance() )
3696  return true;
3697  return false;
3698 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1229
Line2d li
Definition: homog2d_test.cpp:4053
std::array< PT, 3 > getLargestDistancePoints(PT pt1, PT pt2, PT pt3)
Helper function, used to check for colinearity of three points.
Definition: homog2d.hpp:3616
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.

4627 {
4628  return t1.isParallelTo(t2);
4629 }
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
4777 {
4778  Homogr_<FPT> H;
4779  H.buildFrom4Points( vpt1, vpt2, method );
4780  return H;
4781 }
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()
10939 {
10940  return cir.center();
10941 }
Circle cir
Definition: homog2d_test.cpp:4054
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()
10948 {
10949  return cir.center();
10950 }
Circle cir
Definition: homog2d_test.cpp:4054
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()
10912 {
10913  return pl.centroid();
10914 }
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)

11541 {
11542  return convexHull( input.getPts() );
11543 }
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:11555
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()
9852 {
9853  return pt1.distTo( pt2 );
9854 }
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
11257 {
11258  prim.draw( img, dp );
11259 }
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...

11350 {
11351  size_t c=0;
11352  for( const auto& elem: cont )
11353  {
11354  auto dp = func(c);
11355  elem.draw( img, dp );
11356  priv::impl_drawIndexes( img, c++, dp, elem );
11357  }
11358 }
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:11292
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

11370 {
11371  pa.first.draw( img, dp );
11372  pa.second.draw( img, dp );
11373 }

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

11265 {
11266  im.drawText( str, pt, dp );
11267 }
img::Image< img::SvgImage > im(300, 400)
Point2d pt
Definition: homog2d_test.cpp:4052
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()
10957 {
10958  return t.dsize();
10959 }
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.

11161 {
11162  return priv::findPoint( pt, cont, priv::F_MAX() );
11163 }
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:11088
Point2d pt
Definition: homog2d_test.cpp:4052
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
11172 {
11173  if( cont.size() < 2 )
11174  HOMOG2D_THROW_ERROR_1( "container holds " << cont.size() \
11175  << " points, minimum is 2" );
11176 
11177  auto maxDist = priv::sqDist( pt, cont[0] );
11178  auto minDist = maxDist;
11179  size_t idxMin = 0;
11180  size_t idxMax = 0;
11181  size_t startIdx = 1;
11182  if( pt == cont[0] )
11183  {
11184  idxMin++;
11185  idxMax++;
11186  startIdx++;
11187  maxDist = priv::sqDist( pt, cont[1] );
11188  minDist = maxDist;
11189  }
11190  for( size_t i=startIdx; i<cont.size(); i++ )
11191  {
11192  if( pt != cont[i] )
11193  {
11194  auto currentDist = priv::sqDist( pt, cont[i] );
11195  if( currentDist > maxDist )
11196  {
11197  idxMax = i;
11198  maxDist = currentDist;
11199  }
11200  if( currentDist < minDist )
11201  {
11202  idxMin = i;
11203  minDist = currentDist;
11204  }
11205  }
11206  }
11207  return std::make_pair(idxMin, idxMax);
11208 }
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:3577
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Point2d pt
Definition: homog2d_test.cpp:4052
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?

11153 {
11154  return priv::findPoint( pt, cont, priv::F_MIN() );
11155 }
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:11088
Point2d pt
Definition: homog2d_test.cpp:4052
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()
10862 {
10863  return rect.get4Pts();
10864 }
FRect rect
Definition: homog2d_test.cpp:4056
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()
9209 {
9210  static_assert(
9211  (
9212  std::is_same_v<typename T1::SType,typ::IsLine>
9213  || std::is_same_v<typename T1::SType,typ::IsSegment>
9214  || std::is_same_v<typename T1::SType,typ::IsOSeg>
9215  ) &&
9216  (
9217  std::is_same_v<typename T2::SType,typ::IsLine>
9218  || std::is_same_v<typename T2::SType,typ::IsSegment>
9219  || std::is_same_v<typename T2::SType,typ::IsOSeg>
9220  ),
9221  "Both types must be either a Line or a Segment"
9222  );
9223  return t1.getAngle( t2 );
9224 }
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()
11070 {
11071  return ell.getAxisLines();
11072 }
Ellipse ell
Definition: homog2d_test.cpp:4055
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]
10424 {
10425  HOMOG2D_START;
10426  return FRect_<T1>( getMinMax( pp1, pp2 ) );
10427 }
#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:10402
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!)

10442 {
10443  HOMOG2D_START;
10444 
10445  bool isPoly_1 = false;
10446  if( elem1.type() == Type::OPolyline || elem1.type() == Type::CPolyline )
10447  isPoly_1 = true;
10448 
10449  bool isPoly_2 = false;
10450  if( elem2.type() == Type::OPolyline || elem2.type() == Type::CPolyline )
10451  isPoly_1 = true;
10452 
10453  auto siz_1 = elem1.size();
10454  auto siz_2 = elem2.size();
10455 
10456  if( isPoly_1 && isPoly_2 )
10457  if( siz_1==0 && siz_2==0 )
10458  HOMOG2D_THROW_ERROR_1( "unable to compute bounding box of two empty polyline objects" );
10459 
10460  FRect_<typename T1::FType> out;
10461 // we need to do that in two steps: first, copy return value into `out`, then return
10462 // because the underlying floating point might not be the same for the two arguments.
10463  if( isPoly_2 && siz_1==0 )
10464  {
10465  auto pp = ppair::getPointPair( elem2 );
10466  if( shareCommonCoord(pp) )
10467  {
10468  HOMOG2D_THROW_ERROR_1( "Unable to build common Bounding Box of empty polyline and elem2:" << elem2 );
10469  }
10470  else
10471  return FRect_<typename T1::FType>( pp );
10472  }
10473  if( isPoly_1 && siz_2==0 )
10474  {
10475  auto pp = ppair::getPointPair( elem1 );
10476  if( shareCommonCoord(pp) )
10477  {
10478  HOMOG2D_THROW_ERROR_1( "Unable to build common Bounding Box of empty polyline and elem1:" << elem1 );
10479  }
10480  else
10481  return FRect_<typename T1::FType>( pp );
10482  }
10483 
10484  try
10485  {
10486  out = getBB(
10487  ppair::getPointPair( elem1 ),
10488  ppair::getPointPair( elem2 )
10489  );
10490  }
10491  catch( const std::exception& err )
10492  {
10493  HOMOG2D_THROW_ERROR_1( "unable to compute bounding box:\n -arg1="
10494  << elem1 << "\n -arg2=" << elem2 << "\n -err=" << err.what() );
10495  }
10496  return out;
10497 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12403
#define HOMOG2D_START
Definition: homog2d.hpp:106
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12402
#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:10441
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:10121
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()
10719 {
10720  return seg.getBisector();
10721 }
Segment seg
Definition: homog2d_test.cpp:4051
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
9987 {
9988  if( pl.size() < 3 )
9989  {
9990  HOMOG2D_THROW_ERROR_1( "unable, minimum size is 3, currently=" << pl.size() );
9991  }
9992  const auto& pts = pl.getPts();
9993  std::vector<Line2d_<HOMOG2D_INUMTYPE>> out;
9994 
9995  if constexpr ( std::is_same_v<PLT,typ::IsOpen> )
9996  {
9997  out.reserve( pl.size()-2 );
9998  OSegment_<HOMOG2D_INUMTYPE> seg1( pts[1], pts[0] );
9999  for( size_t i=0; i<pl.size()-2; i++ )
10000  {
10001  OSegment_<HOMOG2D_INUMTYPE> seg2( pts[i+1], pts[i+2] );
10002  auto angle = seg1.getAngle( seg2 );
10003  out.emplace_back( seg1.getLine().getRotatedLine( pts[i+1], angle/2. ) );
10004  seg1 = -seg2;
10005  }
10006  }
10007  else
10008  {
10009  out.reserve( pl.size() );
10010  OSegment_<HOMOG2D_INUMTYPE> seg1( pts[0], pts[pl.size()-1] );
10011  for( size_t i=0; i<pl.size(); i++ )
10012  {
10013  auto next = ( i != pl.size()-1 ? i+1 : 0 );
10014  OSegment_<HOMOG2D_INUMTYPE> seg2( pts[i], pts[next] );
10015  auto angle = seg1.getAngle( seg2 );
10016  out.emplace_back( seg1.getLine().getRotatedLine( pts[i], angle/2. ) );
10017  seg1 = -seg2;
10018  }
10019  }
10020  return out;
10021 }
HOMOG2D_INUMTYPE angle(const Ellipse_< FPT > &ell)
Return angle of ellipse (free function)
Definition: homog2d.hpp:10997
#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.

6920 {
6921 #ifndef HOMOG2D_NOCHECKS
6922  if( t.size() == 0 )
6923  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6924 #endif
6925  auto it = priv::getBmPoint_helper( t );
6926  return std::make_pair(
6927  *it,
6928  std::distance( std::begin(t), it )
6929  );
6930 }
auto getBmPoint_helper(const T &t)
Return iterator on Bottom-most point of container holding points.
Definition: homog2d.hpp:6882
#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)

7066 {
7067  return getBmPoint( poly.getPts() ).first;
7068 }
Point2d_< FPT > getBmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Bottom-most point of Polyline (free function)
Definition: homog2d.hpp:7065
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()
9892 {
9893  return rect.getBoundingCircle();
9894 }
FRect rect
Definition: homog2d_test.cpp:4056
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()
10710 {
10711  return seg.getCenter();
10712 }
Segment seg
Definition: homog2d_test.cpp:4051
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()
11009 {
11010  return other.getCenter();
11011 }

◆ 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)
10748 {
10749  std::vector<Point2d_<typename T::value_type::FType>> vout( vsegs.size() );
10750 
10751  auto it = std::begin( vout );
10752  for( const auto& seg: vsegs )
10753  *it++ = getCenter( seg );
10754  return vout;
10755 }
Segment seg
Definition: homog2d_test.cpp:4051
Point2d_< typename T::FType > getCenter(const T &other)
Return center of Segment_, FRect_, or Ellipse_ (free function)
Definition: homog2d.hpp:11008
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)

10599 {
10600 #ifndef HOMOG2D_NOCHECKS
10601  if( poly1.size() == 0 )
10602  HOMOG2D_THROW_ERROR_1( "arg 1 is empty" );
10603  if( poly2.size() == 0 )
10604  HOMOG2D_THROW_ERROR_1( "arg 2 is empty" );
10605 #endif
10606  priv::ClosestPoints<PLT1,FPT1,PLT2,FPT2> out( poly1, poly2 );
10607  for( size_t i=0; i<poly1.size(); i++ )
10608  {
10609  const auto& pt1 = poly1.getPoint(i);
10610  for( size_t j=0; j<poly2.size(); j++ )
10611  {
10612  const auto& pt2 = poly2.getPoint(j);
10613  auto currentDist = dist( pt1, pt2 );
10614  if( currentDist < out._minDist )
10615  out.store( currentDist, i, j );
10616  }
10617  }
10618  return out;
10619 }
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
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)

4597 {
4598  return pt.getCvPtd();
4599 }
Point2d pt
Definition: homog2d_test.cpp:4052
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)

4604 {
4605  return pt.getCvPtf();
4606 }
Point2d pt
Definition: homog2d_test.cpp:4052
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)

4611 {
4612  return pt.getCvPti();
4613 }
Point2d pt
Definition: homog2d_test.cpp:4052
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.

10903 {
10904  return rect.getDiagonals();
10905 }
FRect rect
Definition: homog2d_test.cpp:4056
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()
10645 {
10646  return seg.getExtended();
10647 }
Segment seg
Definition: homog2d_test.cpp:4051
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.

10895 {
10896  return rect.getExtended();
10897 }
FRect rect
Definition: homog2d_test.cpp:4056
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_

7100 {
7101  switch( dir )
7102  {
7103  case CardDir::Top: return getTmPoint(t); break;
7104  case CardDir::Bottom: return getBmPoint(t); break;
7105  case CardDir::Left: return getLmPoint(t); break;
7106  case CardDir::Right: return getRmPoint(t); break;
7107  default: assert(0);
7108  }
7109 }
Point2d_< FPT > getTmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Top-most point of Polyline (free function)
Definition: homog2d.hpp:7072
Point2d_< FPT > getBmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Bottom-most point of Polyline (free function)
Definition: homog2d.hpp:7065
Point2d_< FPT > getRmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Right-most point of Polyline (free function)
Definition: homog2d.hpp:7086
Point2d_< FPT > getLmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Left-most point of Polyline (free function)
Definition: homog2d.hpp:7079
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)
4581 {
4582  if( mat.cols == 0 || mat.rows == 0 )
4584  "Illegal values: cols=" << mat.cols << ", rows=" << mat.rows
4585  );
4586 
4587  return FRect_<FPT>(
4588  Point2d_<FPT>(), // (0,0)
4589  Point2d_<FPT>( mat.cols, mat.rows ) // (w,h)
4590  );
4591 }
#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()
9902 {
9903  return rect.getInscribedCircle();
9904 }
FRect rect
Definition: homog2d_test.cpp:4056
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()
10636 {
10637  return seg.getLine();
10638 }
Segment seg
Definition: homog2d_test.cpp:4051
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.

10701 {
10702  return Line2d_<FPT1>( c1.center(), c2.center() );
10703 }
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()
10770 {
10771  std::vector<Line2d_<typename T::value_type::FType>> vout( vsegs.size() );
10772 
10773  auto it = std::begin( vout );
10774  for( const auto& seg: vsegs )
10775  *it++ = seg.getLine();
10776  return vout;
10777 }
Segment seg
Definition: homog2d_test.cpp:4051
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)
6992 {
6993  using FPT = typename T::value_type::FType;
6994 
6995 #ifndef HOMOG2D_NOCHECKS
6996  if( t.size() == 0 )
6997  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6998 #endif
6999 
7000  auto it = std::min_element(
7001  std::begin(t),
7002  std::end(t),
7003  [] // lambda
7004  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
7005  {
7006  if( pt1.getX() < pt2.getX() )
7007  return true;
7008  if( pt1.getX() > pt2.getX() )
7009  return false;
7010  return( pt1.getY() < pt2.getY() );
7011  }
7012  );
7013 
7014  return std::make_pair(
7015  *it,
7016  std::distance( std::begin(t), it )
7017  );
7018 }
#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)

7080 {
7081  return getLmPoint( poly.getPts() ).first;
7082 }
Point2d_< FPT > getLmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Left-most point of Polyline (free function)
Definition: homog2d.hpp:7079
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]

10403 {
10404  HOMOG2D_START;
10405 
10406  std::array<Point2d_<HOMOG2D_INUMTYPE>,4> arr;
10407  arr[0] = pp1.first;
10408  arr[1] = pp2.first;
10409  arr[2] = pp1.second;
10410  arr[3] = pp2.second;
10411 
10412  return priv::getBB_Points( arr );
10413 }
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:5907
#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()
9970 {
9971  return ell.getOBB();
9972 }
Ellipse ell
Definition: homog2d_test.cpp:4055
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()
10684 {
10685  return seg.getOrthogPts();
10686 }
Segment seg
Definition: homog2d_test.cpp:4051
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()
10675 {
10676  return seg.getOrthogSegs();
10677 }
Segment seg
Definition: homog2d_test.cpp:4051
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.

10974 {
10975 #ifndef HOMOG2D_NOCHECKS
10976  if( !li1.isParallelTo(li2) )
10977  HOMOG2D_THROW_ERROR_1( "lines are not parallel" );
10978 #endif
10979  const auto ar1 = li1.get();
10980  const auto ar2 = li2.get();
10981  const HOMOG2D_INUMTYPE a1 = ar1[0];
10982  const HOMOG2D_INUMTYPE b1 = ar1[1];
10983  const HOMOG2D_INUMTYPE c1 = ar1[2];
10984  const HOMOG2D_INUMTYPE a2 = ar2[0];
10985  const HOMOG2D_INUMTYPE b2 = ar2[1];
10986  const HOMOG2D_INUMTYPE c2 = ar2[2];
10987 
10988  HOMOG2D_INUMTYPE a = homog2d_sqrt( a1*a2 );
10989  HOMOG2D_INUMTYPE b = homog2d_sqrt( b1*b2 );
10990  return homog2d_abs( c1 - c2 ) / homog2d_sqrt( a*a + b*b );
10991 }
#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)

8474 {
8475  return li.getParallelLines( dist );
8476 }
Line2d li
Definition: homog2d_test.cpp:4053
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
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()
10728 {
10729  return seg.getParallelSegs(dist);
10730 }
Segment seg
Definition: homog2d_test.cpp:4051
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
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()
4647 {
4648  return pt.template getPt<RT>();
4649 }
Point2d pt
Definition: homog2d_test.cpp:4052

◆ 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
4666 {
4667  std::vector<RT> vout( vpt.size() );
4668  auto it = vout.begin();
4669  for( const auto& pt: vpt )
4670  *it++ = getPt<RT>(pt);
4671  return vout;
4672 }
Point2d pt
Definition: homog2d_test.cpp:4052
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()
10627 {
10628  return seg.getPts();
10629 }
Segment seg
Definition: homog2d_test.cpp:4051
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()
10871 {
10872  return rect.getPts();
10873 }
FRect rect
Definition: homog2d_test.cpp:4056
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, ...?)
11222 {
11223  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_OPol>, "Cannot find points inside a Open Polyline" );
11224  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_Line>, "Cannot find points inside a Line" );
11225  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_Point>, "Cannot find points inside a Point" );
11226  static_assert( !std::is_same_v<typename PRIM::SType, typ::T_Segment>, "Cannot find points inside a Segment" );
11227  static_assert( !trait::IsArray<CONT>::value, "Cannot use std::array as container" );
11228 
11229  CONT out;
11230  out.reserve( input_set.size() );
11231 
11232  for( auto pt: input_set )
11233  if( pt.isInside( prim ) )
11234  out.push_back( pt );
11235  return out;
11236 }
Point2d pt
Definition: homog2d_test.cpp:4052
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.

7033 {
7034  using FPT = typename T::value_type::FType;
7035 
7036 #ifndef HOMOG2D_NOCHECKS
7037  if( t.size() == 0 )
7038  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
7039 #endif
7040 
7041  auto it = std::min_element(
7042  std::begin(t),
7043  std::end(t),
7044  [] // lambda
7045  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
7046  {
7047  if( pt1.getX() > pt2.getX() )
7048  return true;
7049  if( pt1.getX() < pt2.getX() )
7050  return false;
7051  return( pt1.getY() < pt2.getY() );
7052  }
7053  );
7054 
7055  return std::make_pair(
7056  *it,
7057  std::distance( std::begin(t), it )
7058  );
7059 }
#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)

7087 {
7088  return getRmPoint( poly.getPts() ).first;
7089 }
Point2d_< FPT > getRmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Right-most point of Polyline (free function)
Definition: homog2d.hpp:7086
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)

10693 {
10694  return Segment_<typename T1::FType>( c1.getCenter(), c2.getCenter() );
10695 }
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()
9942 {
9943  return pl.getSegs();
9944 }
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()
10784 {
10785  return seg.getSegs();
10786 }
Segment seg
Definition: homog2d_test.cpp:4051
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:12403
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12399
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12392
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12396
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12380
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12393
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12406
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12402
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12383
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
4837 {
4838  const char* s=0;
4839  switch( t )
4840  {
4841  case PointSide::Left: s="Left"; break;
4842  case PointSide::Right: s="Right"; break;
4843  case PointSide::Neither: s="Neither"; break;
4844  assert(0);
4845  }
4846  return s;
4847 }

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

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

6945 {
6946  using FPT = typename T::value_type::FType;
6947 
6948 #ifndef HOMOG2D_NOCHECKS
6949  if( t.size() == 0 )
6950  HOMOG2D_THROW_ERROR_1( "invalid call, container is empty" );
6951 #endif
6952 
6953  auto it = std::min_element(
6954  std::begin(t),
6955  std::end(t),
6956  [] // lambda
6957  ( const Point2d_<FPT>& pt1, const Point2d_<FPT>& pt2 )
6958  {
6959  if( pt1.getY() > pt2.getY() )
6960  return true;
6961  if( pt1.getY() < pt2.getY() )
6962  return false;
6963  return( pt1.getX() < pt2.getX() );
6964  }
6965  );
6966  return std::make_pair(
6967  *it,
6968  std::distance( std::begin(t), it )
6969  );
6970 }
#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)

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

◆ getX()

template<typename FPT >
FPT h2d::getX ( const Point2d_< FPT > &  pt)
9824 { return pt.getX(); }
Point2d pt
Definition: homog2d_test.cpp:4052
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)
9827 { return pt.getY(); }
Point2d pt
Definition: homog2d_test.cpp:4052
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.

10879 {
10880  return rect.height();
10881 }
FRect rect
Definition: homog2d_test.cpp:4056
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()

9882 {
9883  return r1.intersectArea(r2);
9884 }
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)

9861 {
9862  auto ia = intersectArea( r1, r2 );
9863  if( ia() )
9864  return ia.get().area() / unionArea( r1, r2 ).area();
9865  return 0.;
9866 }
CPolyline_< FPT1 > unionArea(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Free function, see FRect_::unionArea()
Definition: homog2d.hpp:9872
detail::RectArea< FPT1 > intersectArea(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Free function, see FRect_::intersectArea()
Definition: homog2d.hpp:9881
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()
11061 {
11062  return ell.isCircle( thres );
11063 }
Ellipse ell
Definition: homog2d_test.cpp:4055
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()
9922 {
9923  return poly.isConvex();
9924 }
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()
9912 {
9913  return pl.isSimple();
9914 }
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.

11042 {
11043  prim.moveTo( pt );
11044 }
Point2d pt
Definition: homog2d_test.cpp:4052
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.

11052  {
11053  prim.moveTo( x, y );
11054  }

◆ 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()
9932 {
9933  return pl.nbSegs();
9934 }
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.

9679 {
9680  if( h._hmt == nullptr ) // if H^-T not allocated yet, do it
9681  {
9682  h._hmt = std::unique_ptr<detail::Matrix_<U>>( new detail::Matrix_<U>() );
9683  h._hasChanged = true;
9684  }
9685 
9686  if( h._hasChanged ) // if homography has changed, recompute inverse and transposed
9687  {
9688  auto hi = h;
9689  auto mat_inv = hi.inverse().transpose();
9690  *h._hmt = mat_inv;
9691  h._hasChanged = false;
9692  }
9693 
9694  Line2d_<T> out;
9695  detail::product( out, *h._hmt, in );
9696  out.p_normalizePL();
9697  return out;
9698 }
void product(base::LPBase< T1, FPT1 > &, const detail::Matrix_< FPT2 > &, const base::LPBase< T2, FPT1 > &)
Implementation of product 3x3 by 3x1.
Definition: homog2d.hpp:9608
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.

3669 {
3670 #ifndef HOMOG2D_NOCHECKS
3671  if( lhs == rhs )
3672  HOMOG2D_THROW_ERROR_1( "points are identical, unable to compute product:" << lhs );
3673 #endif
3674  Line2d_<FPT> line = detail::crossProduct<typ::IsLine,typ::IsPoint,FPT>(lhs, rhs);
3675  line.p_normalizePL();
3676  return line;
3677 }
#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.

9727 {
9729  for( const auto& pt: rin.get4Pts() )
9730  out.p_addPoint( h * pt );
9731  return out;
9732 }
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Point2d pt
Definition: homog2d_test.cpp:4052
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.

9633 {
9634 #ifndef HOMOG2D_NOCHECKS
9635  if( lhs.isParallelTo(rhs) )
9636  HOMOG2D_THROW_ERROR_1( "lines are parallel, unable to compute product:\nlhs="
9637  << lhs << " rhs=" << rhs
9638  );
9639 #endif
9640 
9641  return detail::crossProduct<typ::IsPoint,typ::IsLine,FPT>(lhs, rhs);
9642 }
#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.

9648 {
9649  return lhs.getLine() * rhs.getLine();
9650 }
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.

9669 {
9670  Point2d_<T> out;
9671  detail::product( out, h, in );
9672  return out;
9673 }
void product(base::LPBase< T1, FPT1 > &, const detail::Matrix_< FPT2 > &, const base::LPBase< T2, FPT1 > &)
Implementation of product 3x3 by 3x1.
Definition: homog2d.hpp:9608
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.

9704 {
9705  const auto& pts = seg.getPts();
9706  Point2d_<FPT1> pt1 = h * pts.first;
9707  Point2d_<FPT1> pt2 = h * pts.second;
9708  return base::SegVec<SV,FPT2>( pt1, pt2 );
9709 }
Segment seg
Definition: homog2d_test.cpp:4051
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.

9715 {
9716  base::PolylineBase<PLT,FPT1> out;
9717  const auto& pts = pl.getPts();
9718  for( const auto& pt: pts )
9719  out.p_addPoint( h * pt );
9720  return out;
9721 }
Point2d pt
Definition: homog2d_test.cpp:4052
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} \]

9743 {
9744  auto hm = static_cast<detail::Matrix_<HOMOG2D_INUMTYPE>>(h);
9745  hm.inverse();
9746  auto hmt = hm;
9747  hmt.transpose();
9748 
9749  const auto& ell_in2 = static_cast<detail::Matrix_<FPT1>>(ell_in);
9750  auto prod = hmt * ell_in2 * hm;
9751 
9752  Ellipse_<FPT1> out( prod );
9753  return out;
9754 }
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

9761 {
9762  Ellipse_<FPT1> ell_in( cir );
9763  return h * ell_in;
9764 }
Circle cir
Definition: homog2d_test.cpp:4054

◆ 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
9811 {
9812  Cont vout = priv::alloc<Cont>( vin.size() );
9813  auto it = std::begin( vout );
9814  for( const auto& elem: vin )
9815  *it++ = h * elem;
9816  return vout;
9817 }

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

8394 {
8395  f << "#="<< vec.size() << '\n';
8396  for( const auto& elem: vec )
8397  f << elem << '\n';
8398  return f;
8399 }
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.

8405 {
8406  f << "std::pair (" << getString(pr.first.type()) << "-" << getString(pr.second.type())
8407  << "):\n -first=" << pr.first
8408  << "\n -second=" << pr.second
8409  << ' ';
8410  return f;
8411 }
const char * getString(PointSide t)
Definition: homog2d.hpp:4836
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 
)
8416 {
8417  f << "pt1: " << r._ptR1 << " pt2: " << r._ptR2;
8418  return f;
8419 }

◆ operator<<() [4/5]

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

◆ operator<<() [5/5]

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

◆ 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()
10921 {
10922  return cir.radius();
10923 }
Circle cir
Definition: homog2d_test.cpp:4054
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()
10930 {
10931  return cir.radius();
10932 }
Circle cir
Definition: homog2d_test.cpp:4054
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)

9951 {
9952  prim.rotate( rot );
9953 }
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.

9960 {
9961  prim.rotate( rot, refpt );
9962 }
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.

9834 {
9835  const auto& arr = li.get();
9836  HOMOG2D_INUMTYPE a = arr[0];
9837  HOMOG2D_INUMTYPE b = arr[1];
9838  HOMOG2D_INUMTYPE c = arr[2];
9839 
9840  auto dist = a * pt.getX() + b * pt.getY() + c;
9842  return 0;
9843  return (std::signbit( dist ) ? -1 : +1);
9844 }
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:4053
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
Point2d pt
Definition: homog2d_test.cpp:4052
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()
10654 {
10655  return seg.split();
10656 }
Segment seg
Definition: homog2d_test.cpp:4051
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 )
10664 {
10666  return seg.split( dist );
10667 }
Segment seg
Definition: homog2d_test.cpp:4051
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9851
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
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.

11020 {
11021  prim.translate( dx, dy );
11022 }
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.

11031 {
11032  prim.translate( ppt.first, ppt.second );
11033 }

◆ unionArea()

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

Free function, see FRect_::unionArea()

9873 {
9874  return r1.unionArea(r2);
9875 }
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.

10887 {
10888  return rect.width();
10889 }
FRect rect
Definition: homog2d_test.cpp:4056
Here is the call graph for this function:
Here is the caller graph for this function: