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:12399
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12395
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12392
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12376
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12389
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12402
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12398
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379

Function Documentation

◆ angle()

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

Return angle of ellipse (free function)

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

◆ areCollinear()

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

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

Todo:
at present, defined by the distance between third point and line. Need to change that, and replace by computation of the angle between the two lines
3650 {
3651  if( pt1 == pt2 || pt2 == pt3 || pt1 == pt3 )
3652  return true;
3653 
3654  auto pt_arr = priv::getLargestDistancePoints( pt1, pt2, pt3 );
3655 
3656  auto li = pt_arr[0] * pt_arr[1];
3657  if( li.distTo( pt_arr[2] ) < thr::nullDistance() )
3658  return true;
3659  return false;
3660 }
static HOMOG2D_INUMTYPE & nullDistance()
Definition: homog2d.hpp:1195
Line2d li
Definition: homog2d_test.cpp:4035
std::array< PT, 3 > getLargestDistancePoints(PT pt1, PT pt2, PT pt3)
Helper function, used to check for colinearity of three points.
Definition: homog2d.hpp:3578
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.

4623 {
4624  return t1.isParallelTo(t2);
4625 }
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
4773 {
4774  Homogr_<FPT> H;
4775  H.buildFrom4Points( vpt1, vpt2, method );
4776  return H;
4777 }
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()
10935 {
10936  return cir.center();
10937 }
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function:
Here is the caller graph for this function:

◆ center() [2/2]

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

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

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

◆ centroid()

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

Returns centroid of Polyline (free function)

See also
PolylineBase::centroid()
10908 {
10909  return pl.centroid();
10910 }
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)

11537 {
11538  return convexHull( input.getPts() );
11539 }
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:11551
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()
9848 {
9849  return pt1.distTo( pt2 );
9850 }
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
11253 {
11254  prim.draw( img, dp );
11255 }
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...

11346 {
11347  size_t c=0;
11348  for( const auto& elem: cont )
11349  {
11350  auto dp = func(c);
11351  elem.draw( img, dp );
11352  priv::impl_drawIndexes( img, c++, dp, elem );
11353  }
11354 }
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:11288
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

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

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

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

◆ dsize()

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

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

See also
detail::Common::dsize()
10953 {
10954  return t.dsize();
10955 }
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.

11157 {
11158  return priv::findPoint( pt, cont, priv::F_MAX() );
11159 }
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:11084
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findNearestFarthestPoint()

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

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

  • return pair: first is nearest, second is farthest
11168 {
11169  if( cont.size() < 2 )
11170  HOMOG2D_THROW_ERROR_1( "container holds " << cont.size() \
11171  << " points, minimum is 2" );
11172 
11173  auto maxDist = priv::sqDist( pt, cont[0] );
11174  auto minDist = maxDist;
11175  size_t idxMin = 0;
11176  size_t idxMax = 0;
11177  size_t startIdx = 1;
11178  if( pt == cont[0] )
11179  {
11180  idxMin++;
11181  idxMax++;
11182  startIdx++;
11183  maxDist = priv::sqDist( pt, cont[1] );
11184  minDist = maxDist;
11185  }
11186  for( size_t i=startIdx; i<cont.size(); i++ )
11187  {
11188  if( pt != cont[i] )
11189  {
11190  auto currentDist = priv::sqDist( pt, cont[i] );
11191  if( currentDist > maxDist )
11192  {
11193  idxMax = i;
11194  maxDist = currentDist;
11195  }
11196  if( currentDist < minDist )
11197  {
11198  idxMin = i;
11199  minDist = currentDist;
11200  }
11201  }
11202  }
11203  return std::make_pair(idxMin, idxMax);
11204 }
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:3539
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findNearestPoint()

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

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

Todo:

add some sfinae and/or checking on type T

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

add other distance computations (Manhattan?)

Would it be better to return an iterator?

11149 {
11150  return priv::findPoint( pt, cont, priv::F_MIN() );
11151 }
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:11084
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get4Pts()

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

Returns the 4 points of the rectangle (free function)

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

◆ getAngle()

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

Free function, returns angle between two segments/lines.

See also
Segment_::getAngle()
Line2d_::getAngle()
9205 {
9206  static_assert(
9207  (
9208  std::is_same_v<typename T1::SType,typ::IsLine>
9209  || std::is_same_v<typename T1::SType,typ::IsSegment>
9210  || std::is_same_v<typename T1::SType,typ::IsOSeg>
9211  ) &&
9212  (
9213  std::is_same_v<typename T2::SType,typ::IsLine>
9214  || std::is_same_v<typename T2::SType,typ::IsSegment>
9215  || std::is_same_v<typename T2::SType,typ::IsOSeg>
9216  ),
9217  "Both types must be either a Line or a Segment"
9218  );
9219  return t1.getAngle( t2 );
9220 }
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()
11066 {
11067  return ell.getAxisLines();
11068 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBB() [1/2]

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

Returns bounding box of two pairs of points.

Warning
May throw in case of identical coordinates (for example with [0,0]-[1,0] and [10,0]-[20,0]
10420 {
10421  HOMOG2D_START;
10422  return FRect_<T1>( getMinMax( pp1, pp2 ) );
10423 }
#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:10398
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!)

10438 {
10439  HOMOG2D_START;
10440 
10441  bool isPoly_1 = false;
10442  if( elem1.type() == Type::OPolyline || elem1.type() == Type::CPolyline )
10443  isPoly_1 = true;
10444 
10445  bool isPoly_2 = false;
10446  if( elem2.type() == Type::OPolyline || elem2.type() == Type::CPolyline )
10447  isPoly_1 = true;
10448 
10449  auto siz_1 = elem1.size();
10450  auto siz_2 = elem2.size();
10451 
10452  if( isPoly_1 && isPoly_2 )
10453  if( siz_1==0 && siz_2==0 )
10454  HOMOG2D_THROW_ERROR_1( "unable to compute bounding box of two empty polyline objects" );
10455 
10456  FRect_<typename T1::FType> out;
10457 // we need to do that in two steps: first, copy return value into `out`, then return
10458 // because the underlying floating point might not be the same for the two arguments.
10459  if( isPoly_2 && siz_1==0 )
10460  {
10461  auto pp = ppair::getPointPair( elem2 );
10462  if( shareCommonCoord(pp) )
10463  {
10464  HOMOG2D_THROW_ERROR_1( "Unable to build common Bounding Box of empty polyline and elem2:" << elem2 );
10465  }
10466  else
10467  return FRect_<typename T1::FType>( pp );
10468  }
10469  if( isPoly_1 && siz_2==0 )
10470  {
10471  auto pp = ppair::getPointPair( elem1 );
10472  if( shareCommonCoord(pp) )
10473  {
10474  HOMOG2D_THROW_ERROR_1( "Unable to build common Bounding Box of empty polyline and elem1:" << elem1 );
10475  }
10476  else
10477  return FRect_<typename T1::FType>( pp );
10478  }
10479 
10480  try
10481  {
10482  out = getBB(
10483  ppair::getPointPair( elem1 ),
10484  ppair::getPointPair( elem2 )
10485  );
10486  }
10487  catch( const std::exception& err )
10488  {
10489  HOMOG2D_THROW_ERROR_1( "unable to compute bounding box:\n -arg1="
10490  << elem1 << "\n -arg2=" << elem2 << "\n -err=" << err.what() );
10491  }
10492  return out;
10493 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12399
#define HOMOG2D_START
Definition: homog2d.hpp:106
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12398
#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:10437
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:1302
PointPair_< FPT > getPointPair(const Line2d_< FPT > &)
Needed because of variant.
Definition: homog2d.hpp:10117
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()
10715 {
10716  return seg.getBisector();
10717 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ getBisectorLines()

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

Returns bisector lines of a Polyline.

Size of vector will be:

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

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

7062 {
7063  return getBmPoint( poly.getPts() ).first;
7064 }
Point2d_< FPT > getBmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Bottom-most point of Polyline (free function)
Definition: homog2d.hpp:7061
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()
9888 {
9889  return rect.getBoundingCircle();
9890 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:

◆ getCenter() [1/2]

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

Free function, returns middle point of segment.

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

◆ getCenter() [2/2]

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

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

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

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

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

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

◆ getCvPtf()

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

Free function to return an OpenCv point (float)

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

◆ getCvPti()

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

Free function to return an OpenCv point (integer)

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

◆ getDiagonals()

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

Free function.

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

◆ getExtended() [1/2]

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

Returns Extended Segment (free function)

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

◆ getExtended() [2/2]

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

Free function.

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

◆ getExtremePoint()

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

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

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

7096 {
7097  switch( dir )
7098  {
7099  case CardDir::Top: return getTmPoint(t); break;
7100  case CardDir::Bottom: return getBmPoint(t); break;
7101  case CardDir::Left: return getLmPoint(t); break;
7102  case CardDir::Right: return getRmPoint(t); break;
7103  default: assert(0);
7104  }
7105 }
Point2d_< FPT > getTmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Top-most point of Polyline (free function)
Definition: homog2d.hpp:7068
Point2d_< FPT > getBmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Bottom-most point of Polyline (free function)
Definition: homog2d.hpp:7061
Point2d_< FPT > getRmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Right-most point of Polyline (free function)
Definition: homog2d.hpp:7082
Point2d_< FPT > getLmPoint(const base::PolylineBase< PLT, FPT > &poly)
Return Left-most point of Polyline (free function)
Definition: homog2d.hpp:7075
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)
4577 {
4578  if( mat.cols == 0 || mat.rows == 0 )
4580  "Illegal values: cols=" << mat.cols << ", rows=" << mat.rows
4581  );
4582 
4583  return FRect_<FPT>(
4584  Point2d_<FPT>(), // (0,0)
4585  Point2d_<FPT>( mat.cols, mat.rows ) // (w,h)
4586  );
4587 }
#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()
9898 {
9899  return rect.getInscribedCircle();
9900 }
FRect rect
Definition: homog2d_test.cpp:4038
Here is the call graph for this function:

◆ getLine() [1/2]

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

Returns Segment supporting line (free function)

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

◆ getLine() [2/2]

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

Free function, returns line between two circle centers.

10697 {
10698  return Line2d_<FPT1>( c1.center(), c2.center() );
10699 }
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()
10766 {
10767  std::vector<Line2d_<typename T::value_type::FType>> vout( vsegs.size() );
10768 
10769  auto it = std::begin( vout );
10770  for( const auto& seg: vsegs )
10771  *it++ = seg.getLine();
10772  return vout;
10773 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the caller graph for this function:

◆ getLmPoint() [1/2]

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

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

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

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

10399 {
10400  HOMOG2D_START;
10401 
10402  std::array<Point2d_<HOMOG2D_INUMTYPE>,4> arr;
10403  arr[0] = pp1.first;
10404  arr[1] = pp2.first;
10405  arr[2] = pp1.second;
10406  arr[3] = pp2.second;
10407 
10408  return priv::getBB_Points( arr );
10409 }
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:5903
#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()
9966 {
9967  return ell.getOBB();
9968 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrthogPts()

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

Returns the 4 orthogonal points to the segment.

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

◆ getOrthogSegs()

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

Returns the 4 orthogonal segments to the segment.

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

◆ getParallelDistance()

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

Returns the distance between 2 parallel lines (free function)

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

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

8470 {
8471  return li.getParallelLines( dist );
8472 }
Line2d li
Definition: homog2d_test.cpp:4035
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
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()
10724 {
10725  return seg.getParallelSegs(dist);
10726 }
Segment seg
Definition: homog2d_test.cpp:4033
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
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()
4643 {
4644  return pt.template getPt<RT>();
4645 }
Point2d pt
Definition: homog2d_test.cpp:4034

◆ getPts() [1/3]

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

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

  • RT: return type
  • FPT: Floating Point Type

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

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

◆ getPts() [2/3]

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

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

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

◆ getPts() [3/3]

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

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

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

◆ getPtsInside()

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

Returns set of points that are inside primitive prim.

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

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

◆ getRmPoint() [1/2]

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

Return Right-most point of container holding points.

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

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

10689 {
10690  return Segment_<typename T1::FType>( c1.getCenter(), c2.getCenter() );
10691 }
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()
9938 {
9939  return pl.getSegs();
9940 }
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()
10780 {
10781  return seg.getSegs();
10782 }
Segment seg
Definition: homog2d_test.cpp:4033
Here is the call graph for this function:

◆ getString() [1/3]

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

Returns stringified version of type()

949 {
950  const char* s=0;
951  switch( t )
952  {
953  case Type::Line2d: s="Line2d"; break;
954  case Type::Point2d: s="Point2d"; break;
955  case Type::Segment: s="Segment"; break;
956  case Type::OSegment: s="OSegment"; break;
957  case Type::FRect: s="FRect"; break;
958  case Type::Circle: s="Circle"; break;
959  case Type::Ellipse: s="Ellipse"; break;
960  case Type::OPolyline: s="OPolyline"; break;
961  case Type::CPolyline: s="CPolyline"; break;
962  assert(0);
963  }
964  return s;
965 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12399
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12395
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12392
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12376
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12389
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12402
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12398
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
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
4833 {
4834  const char* s=0;
4835  switch( t )
4836  {
4837  case PointSide::Left: s="Left"; break;
4838  case PointSide::Right: s="Right"; break;
4839  case PointSide::Neither: s="Neither"; break;
4840  assert(0);
4841  }
4842  return s;
4843 }

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

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

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

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

◆ getX()

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

◆ getY()

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

◆ height()

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

Free function.

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

◆ intersectArea()

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

Free function, see FRect_::intersectArea()

9878 {
9879  return r1.intersectArea(r2);
9880 }
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)

9857 {
9858  auto ia = intersectArea( r1, r2 );
9859  if( ia() )
9860  return ia.get().area() / unionArea( r1, r2 ).area();
9861  return 0.;
9862 }
CPolyline_< FPT1 > unionArea(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Free function, see FRect_::unionArea()
Definition: homog2d.hpp:9868
detail::RectArea< FPT1 > intersectArea(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Free function, see FRect_::intersectArea()
Definition: homog2d.hpp:9877
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()
11057 {
11058  return ell.isCircle( thres );
11059 }
Ellipse ell
Definition: homog2d_test.cpp:4037
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isConvex()

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

Returns true if polygon is convex (free function)

See also
PolylineBase::isConvex()
9918 {
9919  return poly.isConvex();
9920 }
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()
9908 {
9909  return pl.isSimple();
9910 }
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.

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

◆ moveTo() [2/2]

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

Move primitive to other location (free function)

Calls the member function. Type checking is done there.

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

◆ 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()
9928 {
9929  return pl.nbSegs();
9930 }
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.

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

3631 {
3632 #ifndef HOMOG2D_NOCHECKS
3633  if( lhs == rhs )
3634  HOMOG2D_THROW_ERROR_1( "points are identical, unable to compute product:" << lhs );
3635 #endif
3636  Line2d_<FPT> line = detail::crossProduct<typ::IsLine,typ::IsPoint,FPT>(lhs, rhs);
3637  line.p_normalizePL();
3638  return line;
3639 }
#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.

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

◆ operator*() [6/14]

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

◆ operator*() [7/14]

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

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

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

9644 {
9645  return lhs.getLine() * rhs.getLine();
9646 }
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.

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

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

◆ operator*() [11/14]

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

Apply homography to a Polyline.

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

◆ operator*() [12/14]

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

Apply homography to a Ellipse, produces an Ellipse.

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

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

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

◆ operator*() [14/14]

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

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

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

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

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

8401 {
8402  f << "std::pair (" << getString(pr.first.type()) << "-" << getString(pr.second.type())
8403  << "):\n -first=" << pr.first
8404  << "\n -second=" << pr.second
8405  << ' ';
8406  return f;
8407 }
const char * getString(PointSide t)
Definition: homog2d.hpp:4832
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 
)
8412 {
8413  f << "pt1: " << r._ptR1 << " pt2: " << r._ptR2;
8414  return f;
8415 }

◆ operator<<() [4/5]

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

◆ operator<<() [5/5]

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

◆ radius() [1/2]

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

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

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

◆ radius() [2/2]

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

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

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

◆ rotate() [1/2]

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

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

9947 {
9948  prim.rotate( rot );
9949 }
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.

9956 {
9957  prim.rotate( rot, refpt );
9958 }
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.

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

◆ split() [1/2]

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

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

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

◆ split() [2/2]

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

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

Note
: can only be used on oriented segments
See also
Segment_::split( T )
10660 {
10662  return seg.split( dist );
10663 }
Segment seg
Definition: homog2d_test.cpp:4033
HOMOG2D_INUMTYPE dist(const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2)
Free function, distance between points.
Definition: homog2d.hpp:9847
#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.

11016 {
11017  prim.translate( dx, dy );
11018 }
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.

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

◆ unionArea()

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

Free function, see FRect_::unionArea()

9869 {
9870  return r1.unionArea(r2);
9871 }
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.

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