homog2d library
Public Types | Public Member Functions | Friends | List of all members
h2d::Ellipse_< FPT > Class Template Reference

Ellipse as a conic in matrix form. More...

#include <homog2d.hpp>

Inheritance diagram for h2d::Ellipse_< FPT >:
Inheritance graph
[legend]
Collaboration diagram for h2d::Ellipse_< FPT >:
Collaboration graph
[legend]

Public Types

using FType = FPT
 
using SType = typ::T_Ellipse
 

Public Member Functions

HOMOG2D_INUMTYPE area () const
 Area of ellipse. More...
 
void draw (img::Image< cv::Mat > &, img::DrawParams dp=img::DrawParams()) const
 Draw Ellipse (Opencv implementation) More...
 
void draw (img::Image< img::SvgImage > &, img::DrawParams dp=img::DrawParams()) const
 Draw Ellipse (SVG implementation) More...
 
std::pair< Line2d_< FPT >, Line2d_< FPT > > getAxisLines () const
 Returns pair of axis lines of ellipse. More...
 
HOMOG2D_INUMTYPE length () const
 Returns (approximate) perimeter of ellipse using the Ramanujan second formulae. More...
 
template<typename TX , typename TY >
void moveTo (TX x, TY y)
 Move Ellipse to new location. More...
 
template<typename T1 >
void moveTo (const Point2d_< T1 > &new_org)
 Move Ellipse to new location, given by new_org. More...
 
bool operator!= (const Ellipse_ &e) const
 Comparison operator. Does normalization if required. More...
 
bool operator== (const Ellipse_ &h) const
 Comparison operator. Does normalization if required. More...
 
template<typename FPT2 >
bool pointIsInside (const Point2d_< FPT2 > &) const
 Returns true if point is inside ellipse. More...
 
template<typename TX , typename TY >
void translate (TX dx, TY dy)
 Translate Ellipse. More...
 
template<typename T1 , typename T2 >
void translate (const std::pair< T1, T2 > &ppt)
 Translate Ellipse. More...
 
Type type () const
 
Constructors
 Ellipse_ ()
 Default constructor: centered at (0,0), major=2, minor=1. More...
 
template<typename T1 , typename T2 = double, typename T3 = double>
 Ellipse_ (const Point2d_< T1 > &pt, T2 major=2., T2 minor=1., T3 angle=0.)
 Constructor 1. More...
 
template<typename T1 , typename T2 = double, typename T3 = double>
 Ellipse_ (T1 x, T1 y, T2 major=2., T2 minor=1., T3 angle=0.)
 Constructor 2. More...
 
 Ellipse_ (const Circle_< FPT > &cir)
 Constructor 3, import from circle. More...
 
template<typename FPT2 >
 Ellipse_ (const Ellipse_< FPT2 > &other)
 Copy-Constructor. More...
 
attributes of ellipse
constexpr size_t size () const
 Returns 1. More...
 
bool isCircle (HOMOG2D_INUMTYPE thres=1.E-10) const
 Returns true if ellipse is a circle. More...
 
Point2d_< FPT > getCenter () const
 Returns center of ellipse. More...
 
CPolyline_< FPT > getOBB () const
 Returns oriented bounding box of ellipse as a closed Polyline. More...
 
auto getBB () const
 Returns axis-aligned bounding box of ellipse. More...
 
HOMOG2D_INUMTYPE angle () const
 Returns angle of ellipse. More...
 
std::pair< HOMOG2D_INUMTYPE, HOMOG2D_INUMTYPEgetMajMin () const
 
- Public Member Functions inherited from h2d::detail::Matrix_< FPT >
HOMOG2D_INUMTYPE determ () const
 Return determinant of matrix. More...
 
matrix_t< FPT > & getRaw ()
 
const matrix_t< FPT > & getRaw () const
 
Matrix_inverse ()
 Inverse matrix. More...
 
bool isNormalized () const
 
 Matrix_ ()
 Constructor. More...
 
template<typename FPT2 >
 Matrix_ (const Matrix_< FPT2 > &other)
 Copy-Constructor. More...
 
template<typename T >
void set (size_t r, size_t c, T v)
 
Matrix_transpose ()
 Transpose and return matrix. More...
 
const FPT & value (size_t r, size_t c) const
 
FPT & value (size_t r, size_t c)
 
- Public Member Functions inherited from h2d::detail::Common< FPT >
std::pair< int, int > dsize () const
 Get data size expressed as number of bits for, respectively, mantissa and exponent. More...
 
Dtype dtype () const
 Get numerical data type as a Dtype value, can be stringified with h2d::getString(Dtype) More...
 
template<typename T >
constexpr bool isInside (const Common< T > &) const
 This function is a fallback for all sub-classes that do not provide such a method. More...
 
size_t size () const
 
- Public Member Functions inherited from h2d::rtp::Root
virtual ~Root ()
 

Friends

template<typename T >
class Ellipse_
 
template<typename FPT1 , typename FPT2 >
Ellipse_< FPT1 > operator* (const Homogr_< FPT2 > &, const Circle_< FPT1 > &)
 Apply homography to a Circle, produces an Ellipse. More...
 
template<typename FPT1 , typename FPT2 >
Ellipse_< FPT1 > operator* (const Homogr_< FPT2 > &, const Ellipse_< FPT1 > &)
 Apply homography to a Ellipse, produces an Ellipse. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &f, const Ellipse_< T > &ell)
 

Additional Inherited Members

- Protected Member Functions inherited from h2d::detail::Matrix_< FPT >
template<typename FPT2 >
void p_divideAll (detail::Matrix_< FPT > &mat, FPT2 value) const
 Divide all elements of mat by value. More...
 
void p_divideBy (size_t r, size_t c) const
 Divide all elements by the value at (r,c), used for normalization. More...
 
void p_fillEye ()
 
template<typename T >
void p_fillWith (const T &in)
 
void p_fillZero ()
 
void p_normalizeMat (int r, int c) const
 
- Protected Attributes inherited from h2d::detail::Matrix_< FPT >
bool _isNormalized = false
 
matrix_t< FPT > _mdata
 

Detailed Description

template<typename FPT>
class h2d::Ellipse_< FPT >

Ellipse as a conic in matrix form.

This enables its projection using homography

See:

General equation of an ellipse:

\[ A x^2 + B x y + C y^2 + D x + E y + F = 0 \]

It can be written as a 3 x 3 matrix:

\[ \begin{bmatrix} A & B/2 & D/2 \\ B/2 & C & E/2 \\ D/2 & E/2 & F \end{bmatrix} \]

Matrix coefficients computed from center x0,y0, major and minor distances (a,b) and angle theta:

\[ \begin{aligned} A &= a^2 \sin^2\theta + b^2 \cos^2\theta \\ B &= 2\left(b^2 - a^2\right) \sin\theta \cos\theta \\ C &= a^2 \cos^2\theta + b^2 \sin^2\theta \\ D &= -2A x_\circ - B y_\circ \\ E &= - B x_\circ - 2C y_\circ \\ F &= A x_\circ^2 + B x_\circ y_\circ + C y_\circ^2 - a^2 b^2 \end{aligned} \]

Homography projection: https://math.stackexchange.com/a/2320082/133647

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

Member Typedef Documentation

◆ FType

template<typename FPT>
using h2d::Ellipse_< FPT >::FType = FPT

◆ SType

template<typename FPT>
using h2d::Ellipse_< FPT >::SType = typ::T_Ellipse

Constructor & Destructor Documentation

◆ Ellipse_() [1/5]

template<typename FPT>
h2d::Ellipse_< FPT >::Ellipse_ ( )
inline

Default constructor: centered at (0,0), major=2, minor=1.

2215  : Ellipse_( 0., 0., 2., 1., 0. )
2216  {}
Ellipse_()
Default constructor: centered at (0,0), major=2, minor=1.
Definition: homog2d.hpp:2215

◆ Ellipse_() [2/5]

template<typename FPT>
template<typename T1 , typename T2 = double, typename T3 = double>
h2d::Ellipse_< FPT >::Ellipse_ ( const Point2d_< T1 > &  pt,
T2  major = 2.,
T2  minor = 1.,
T3  angle = 0. 
)
inline

Constructor 1.

2221  : Ellipse_( pt.getX(), pt.getY(), major, minor, angle )
2222  {}
HOMOG2D_INUMTYPE angle() const
Returns angle of ellipse.
Definition: homog2d.hpp:8601
Ellipse_()
Default constructor: centered at (0,0), major=2, minor=1.
Definition: homog2d.hpp:2215
Point2d pt
Definition: homog2d_test.cpp:4034

◆ Ellipse_() [3/5]

template<typename FPT>
template<typename T1 , typename T2 = double, typename T3 = double>
h2d::Ellipse_< FPT >::Ellipse_ ( T1  x,
T1  y,
T2  major = 2.,
T2  minor = 1.,
T3  angle = 0. 
)
inlineexplicit

Constructor 2.

2227  {
2231  if( major<minor )
2232  std::swap( major, minor );
2233  p_init( x, y, major, minor, angle );
2234  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
HOMOG2D_INUMTYPE angle() const
Returns angle of ellipse.
Definition: homog2d.hpp:8601

◆ Ellipse_() [4/5]

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

Constructor 3, import from circle.

2238  {
2239  p_init( cir.center().getX(), cir.center().getY(), cir.radius(), cir.radius(), 0. );
2240  }
Circle cir
Definition: homog2d_test.cpp:4036

◆ Ellipse_() [5/5]

template<typename FPT>
template<typename FPT2 >
h2d::Ellipse_< FPT >::Ellipse_ ( const Ellipse_< FPT2 > &  other)
inline

Copy-Constructor.

2245  : detail::Matrix_<FPT>( other )
2246  {}

Member Function Documentation

◆ angle()

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

Returns angle of ellipse.

See also
angle( const Ellipse_& )
8602 {
8603  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8604  return par.theta;
8605 }
Here is the caller graph for this function:

◆ area()

template<typename FPT>
HOMOG2D_INUMTYPE h2d::Ellipse_< FPT >::area ( ) const
inlinevirtual

Area of ellipse.

Implements h2d::rtp::Root.

2302  {
2303  auto par = p_getParams<HOMOG2D_INUMTYPE>();
2304  return M_PI * par.a * par.b;
2305  }
#define M_PI
Definition: homog2d.hpp:235

◆ draw() [1/2]

template<typename FPT >
void h2d::Ellipse_< FPT >::draw ( img::Image< cv::Mat > &  im,
img::DrawParams  dp = img::DrawParams() 
) const
virtual

Draw Ellipse (Opencv implementation)

Implements h2d::rtp::Root.

11930 {
11931  auto par = p_getParams<HOMOG2D_INUMTYPE>();
11932  cv::ellipse(
11933  im.getReal(),
11934  cv::Point( par.x0,par.y0 ),
11935  cv::Size( par.a, par.b ),
11936  par.theta*180./M_PI,
11937  0., 360.,
11938  dp.cvColor(),
11939  dp._dpValues._lineThickness,
11940  dp._dpValues._lineType==1?cv::LINE_AA:cv::LINE_8
11941  );
11942 }
#define M_PI
Definition: homog2d.hpp:235
img::Image< img::SvgImage > im(300, 400)
Here is the caller graph for this function:

◆ draw() [2/2]

template<typename FPT >
void h2d::Ellipse_< FPT >::draw ( img::Image< img::SvgImage > &  im,
img::DrawParams  dp = img::DrawParams() 
) const
virtual

Draw Ellipse (SVG implementation)

Implements h2d::rtp::Root.

12091 {
12092  im.getReal()._svgString << "<ellipse cx=\""
12093  << getCenter().getX()
12094  << "\" cy=\""
12095  << getCenter().getY()
12096  << "\" rx=\""
12097  << getMajMin().first
12098  << "\" ry=\""
12099  << getMajMin().second
12100  << "\" stroke=\""
12101  << dp.getSvgRgbColor()
12102  << "\" stroke-width=\"" << dp._dpValues._lineThickness << "\" ";
12103  if( !dp.holdsFill() )
12104  im.getReal()._svgString << "fill=\"none\" ";
12105  im.getReal()._svgString << dp.getAttrString()
12106  << "transform=\"rotate(" << angle()*180./M_PI << ',' << getCenter().getX() << ',' << getCenter().getY()
12107  << ")\" />\n";
12108 }
Point2d_< FPT > getCenter() const
Returns center of ellipse.
Definition: homog2d.hpp:8581
#define M_PI
Definition: homog2d.hpp:235
std::pair< HOMOG2D_INUMTYPE, HOMOG2D_INUMTYPE > getMajMin() const
Definition: homog2d.hpp:8590
img::Image< img::SvgImage > im(300, 400)
HOMOG2D_INUMTYPE angle() const
Returns angle of ellipse.
Definition: homog2d.hpp:8601

◆ getAxisLines()

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

Returns pair of axis lines of ellipse.

8629 {
8630  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8631  auto dy = static_cast<HOMOG2D_INUMTYPE>(par.sint) * par.a;
8632  auto dx = static_cast<HOMOG2D_INUMTYPE>(par.cost) * par.a;
8633  Point2d_<HOMOG2D_INUMTYPE> ptA(
8634  par.x0 + dx,
8635  par.y0 + dy
8636  );
8637  auto pt0 = Point2d_<HOMOG2D_INUMTYPE>( par.x0, par.y0 );
8638  auto li_H = ptA * pt0;
8639  HOMOG2D_LOG( std::scientific << "ptA=" << ptA << " pt0=" << pt0 << " li_H=" << li_H );
8640 
8641  auto li_V = li_H.getOrthogLine( pt0 );
8642  return std::make_pair( li_H, li_V );
8643 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define HOMOG2D_LOG(a)
Definition: homog2d.hpp:115
Here is the caller graph for this function:

◆ getBB()

template<typename FPT >
auto h2d::Ellipse_< FPT >::getBB ( ) const

Returns axis-aligned bounding box of ellipse.

8653 {
8654  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8655  auto vx = par.a2 * par.cost * par.cost + par.b2 * par.sint * par.sint;
8656  auto vy = par.a2 * par.sint * par.sint + par.b2 * par.cost * par.cost;
8657  auto vx_sq = homog2d_sqrt( vx );
8658  auto vy_sq = homog2d_sqrt( vy );
8659  return FRect_<HOMOG2D_INUMTYPE>(
8660  Point2d_<HOMOG2D_INUMTYPE>( par.x0 - vx_sq, par.y0 - vy_sq ),
8661  Point2d_<HOMOG2D_INUMTYPE>( par.x0 + vx_sq, par.y0 + vy_sq )
8662  );
8663 }
#define homog2d_sqrt
Definition: homog2d.hpp:75
Here is the caller graph for this function:

◆ getCenter()

template<typename FPT >
Point2d_< FPT > h2d::Ellipse_< FPT >::getCenter ( ) const

Returns center of ellipse.

See also
center( const T& )
8582 {
8583  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8584  return Point2d_<FPT>( par.x0, par.y0 );
8585 }
Here is the caller graph for this function:

◆ getMajMin()

template<typename FPT >
std::pair< HOMOG2D_INUMTYPE, HOMOG2D_INUMTYPE > h2d::Ellipse_< FPT >::getMajMin ( ) const
8591 {
8592  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8593  return std::make_pair( par.a, par.b );
8594 }
Here is the caller graph for this function:

◆ getOBB()

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

Returns oriented bounding box of ellipse as a closed Polyline.

Algorithm:

  • build line liH going through major axis, by using center point and point on semi-major axis, intersecting ellipse
  • get opposite point ptB, lying on line and at distance a
  • get the two parallel lines to liH, at a distance b
  • get the two orthogonal lines at ptA and ptB
Todo:
20240330: unclear, the text above does not match what is done below (or does it?). Clarify that, and build a gif showing how this is done.
8681 {
8682 // step 1: build ptA using angle
8683  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8684  auto dy = par.sint * par.a;
8685  auto dx = par.cost * par.a;
8686  Point2d_<FPT> ptA(
8687  par.x0 + dx,
8688  par.y0 + dy
8689  );
8690  auto pt0 = Point2d_<HOMOG2D_INUMTYPE>( par.x0, par.y0 );
8691 
8692 // step 2: build main-axis line, going through center and ptA
8693  auto li_H = ptA * pt0;
8694 
8695 // step 3: get ptB, using line and distance
8696  auto ppts = li_H.getPoints( pt0, par.a );
8697  auto ptB = ppts.first;
8698  if( ptB == ptA )
8699  ptB = ppts.second;
8700 
8701  auto para = getParallelLines( li_H, par.b );
8702  auto li_V1 = li_H.getOrthogLine( ptA );
8703  auto li_V2 = li_H.getOrthogLine( ptB );
8704 
8705  CPolyline_<FPT> out;
8706 #ifndef HOMOG2D_DEBUGMODE
8707  out.p_addPoint( para.first * li_V1 );
8708  out.p_addPoint( para.second * li_V1 );
8709  out.p_addPoint( para.second * li_V2 );
8710  out.p_addPoint( para.first * li_V2 );
8711 #else
8712  auto p1 = para.first * li_V1;
8713  auto p2 = para.second * li_V1;
8714  auto p3 = para.second * li_V2;
8715  auto p4 = para.first * li_V2;
8717  ( p2!=p1 && p3!=p2 && p4!=p3 ),
8718  "p1=" << p1 << " p2=" << p2 << " p3=" << p3 << " p4=" << p4
8719  << "\n para.1=" << para.first
8720  << "\n li_V1=" << li_V1
8721  << "\n ptA=" << ptA
8722  << "\n ptB=" << ptB
8723  << "\n " << ppts
8724  );
8725  out.p_addPoint( p1 );
8726  out.p_addPoint( p2 );
8727  out.p_addPoint( p3 );
8728  out.p_addPoint( p4 );
8729 #endif
8730  return out;
8731 }
#define HOMOG2D_DEBUG_ASSERT(a, b)
Assert debug macro, used internally if HOMOG2D_DEBUGMODE is defined.
Definition: homog2d.hpp:126
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)
Definition: homog2d.hpp:8469
Here is the caller graph for this function:

◆ isCircle()

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

Returns true if ellipse is a circle.

Using the matrix representation, if A = C and B = 0, then the ellipse is a circle

You can provide the 0 threshold as and argument

8565 {
8566  const auto& m = detail::Matrix_<FPT>::_mdata;
8567  HOMOG2D_INUMTYPE A = m[0][0];
8568  HOMOG2D_INUMTYPE C = m[1][1];
8569  HOMOG2D_INUMTYPE B2 = m[0][1];
8570  if( homog2d_abs(A-C) < thres )
8571  if( homog2d_abs(B2)*2. < thres )
8572  return true;
8573  return false;
8574 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
matrix_t< FPT > _mdata
Definition: homog2d.hpp:1441
#define homog2d_abs
Definition: homog2d.hpp:69
Here is the caller graph for this function:

◆ length()

template<typename FPT >
HOMOG2D_INUMTYPE h2d::Ellipse_< FPT >::length ( ) const
virtual

Returns (approximate) perimeter of ellipse using the Ramanujan second formulae.

See https://en.wikipedia.org/wiki/Ellipse#Circumference

Implements h2d::rtp::Root.

8615 {
8616  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8617  auto ab_sum = par.a + par.b;
8618  auto ab_diff = par.a - par.b;
8619  auto h = ab_diff * ab_diff / (ab_sum * ab_sum);
8620  auto denom = (HOMOG2D_INUMTYPE)10. + homog2d_sqrt(4. - 3. * h);
8621  return (par.a + par.b) * M_PI * ( 1. + 3. * h / denom );
8622 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
#define M_PI
Definition: homog2d.hpp:235
#define homog2d_sqrt
Definition: homog2d.hpp:75

◆ moveTo() [1/2]

template<typename FPT>
template<typename TX , typename TY >
void h2d::Ellipse_< FPT >::moveTo ( TX  x,
TY  y 
)
inline

Move Ellipse to new location.

2268  {
2271  auto par = p_getParams<HOMOG2D_INUMTYPE>();
2272  p_init( x, y, par.a, par.b, par.theta );
2273  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144

◆ moveTo() [2/2]

template<typename FPT>
template<typename T1 >
void h2d::Ellipse_< FPT >::moveTo ( const Point2d_< T1 > &  new_org)
inline

Move Ellipse to new location, given by new_org.

2278  {
2279  this->moveTo( new_org.getX(), new_org.getY() );
2280  }
void moveTo(TX x, TY y)
Move Ellipse to new location.
Definition: homog2d.hpp:2267

◆ operator!=()

template<typename FPT>
bool h2d::Ellipse_< FPT >::operator!= ( const Ellipse_< FPT > &  e) const
inline

Comparison operator. Does normalization if required.

2344  {
2345  return !(*this == e);
2346  }

◆ operator==()

template<typename FPT>
bool h2d::Ellipse_< FPT >::operator== ( const Ellipse_< FPT > &  h) const
inline

Comparison operator. Does normalization if required.

2324  {
2325  auto& data = detail::Matrix_<FPT>::_mdata;
2326 
2329  if( !h.isNormalized() )
2330  h.p_normalizeMat(2,2);
2331 
2332  for( int i=0; i<3; i++ )
2333  for( int j=0; j<3; j++ )
2334  if( std::fabs(
2335  static_cast<HOMOG2D_INUMTYPE>( data[i][j] ) - h.value(i,j) )
2336  >= thr::nullDeter()
2337  )
2338  return false;
2339  return true;
2340  }
void p_normalizeMat(int r, int c) const
Definition: homog2d.hpp:1528
matrix_t< FPT > _mdata
Definition: homog2d.hpp:1441
bool isNormalized() const
Definition: homog2d.hpp:1525
static HOMOG2D_INUMTYPE & nullDeter()
Definition: homog2d.hpp:1217

◆ pointIsInside()

template<typename FPT >
template<typename FPT2 >
bool h2d::Ellipse_< FPT >::pointIsInside ( const Point2d_< FPT2 > &  pt) const

Returns true if point is inside ellipse.

taken from https://stackoverflow.com/a/16814494/193789

8742 {
8743  HOMOG2D_INUMTYPE x = pt.getX();
8744  HOMOG2D_INUMTYPE y = pt.getY();
8745 
8746  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8747  const auto& x0 = par.x0;
8748  const auto& y0 = par.y0;
8749 
8750  auto v1 = par.cost * (x-x0) + par.sint * (y-y0);
8751  HOMOG2D_INUMTYPE sum = v1*v1 / par.a2;
8752 
8753  auto v2 = par.sint * (x-x0) - par.cost * (y-y0);
8754  sum += v2*v2 / par.b2;
8755  if( sum < 1. )
8756  return true;
8757  return false;
8758 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the caller graph for this function:

◆ size()

template<typename FPT>
constexpr size_t h2d::Ellipse_< FPT >::size ( ) const
inlinevirtual

Returns 1.

Implements h2d::rtp::Root.

2287  {
2288  return 1;
2289  }

◆ translate() [1/2]

template<typename FPT>
template<typename TX , typename TY >
void h2d::Ellipse_< FPT >::translate ( TX  dx,
TY  dy 
)
inline

Translate Ellipse.

2252  {
2255  auto par = p_getParams<HOMOG2D_INUMTYPE>();
2256  p_init( par.x0+dx, par.y0+dy, par.a, par.b, par.theta );
2257  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144

◆ translate() [2/2]

template<typename FPT>
template<typename T1 , typename T2 >
void h2d::Ellipse_< FPT >::translate ( const std::pair< T1, T2 > &  ppt)
inline

Translate Ellipse.

2261  {
2262  this->translate( ppt.first, ppt.second );
2263  }
void translate(TX dx, TY dy)
Translate Ellipse.
Definition: homog2d.hpp:2251

◆ type()

template<typename FPT>
Type h2d::Ellipse_< FPT >::type ( ) const
inlinevirtual

Implements h2d::rtp::Root.

2196  {
2197  return Type::Ellipse;
2198  }

Friends And Related Function Documentation

◆ Ellipse_

template<typename FPT>
template<typename T >
friend class Ellipse_
friend

◆ operator* [1/2]

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

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* [2/2]

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

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 }

◆ operator<<

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

The documentation for this class was generated from the following file: