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.

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

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

2255  : Ellipse_( pt.getX(), pt.getY(), major, minor, angle )
2256  {}
HOMOG2D_INUMTYPE angle() const
Returns angle of ellipse.
Definition: homog2d.hpp:8602
Ellipse_()
Default constructor: centered at (0,0), major=2, minor=1.
Definition: homog2d.hpp:2249
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.

2261  {
2265  if( major<minor )
2266  std::swap( major, minor );
2267  p_init( x, y, major, minor, angle );
2268  }
#define HOMOG2D_CHECK_IS_NUMBER(T)
Definition: homog2d.hpp:144
HOMOG2D_INUMTYPE angle() const
Returns angle of ellipse.
Definition: homog2d.hpp:8602

◆ Ellipse_() [4/5]

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

Constructor 3, import from circle.

2272  {
2273  p_init( cir.center().getX(), cir.center().getY(), cir.radius(), cir.radius(), 0. );
2274  }
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.

2279  : detail::Matrix_<FPT>( other )
2280  {}

Member Function Documentation

◆ angle()

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

Returns angle of ellipse.

See also
angle( const Ellipse_& )
8603 {
8604  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8605  return par.theta;
8606 }
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.

2336  {
2337  auto par = p_getParams<HOMOG2D_INUMTYPE>();
2338  return M_PI * par.a * par.b;
2339  }
#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.

11931 {
11932  auto par = p_getParams<HOMOG2D_INUMTYPE>();
11933  cv::ellipse(
11934  im.getReal(),
11935  cv::Point( par.x0,par.y0 ),
11936  cv::Size( par.a, par.b ),
11937  par.theta*180./M_PI,
11938  0., 360.,
11939  dp.cvColor(),
11940  dp._dpValues._lineThickness,
11941  dp._dpValues._lineType==1?cv::LINE_AA:cv::LINE_8
11942  );
11943 }
#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.

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

◆ getAxisLines()

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

Returns pair of axis lines of ellipse.

8630 {
8631  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8632  auto dy = static_cast<HOMOG2D_INUMTYPE>(par.sint) * par.a;
8633  auto dx = static_cast<HOMOG2D_INUMTYPE>(par.cost) * par.a;
8634  Point2d_<HOMOG2D_INUMTYPE> ptA(
8635  par.x0 + dx,
8636  par.y0 + dy
8637  );
8638  auto pt0 = Point2d_<HOMOG2D_INUMTYPE>( par.x0, par.y0 );
8639  auto li_H = ptA * pt0;
8640  HOMOG2D_LOG( std::scientific << "ptA=" << ptA << " pt0=" << pt0 << " li_H=" << li_H );
8641 
8642  auto li_V = li_H.getOrthogLine( pt0 );
8643  return std::make_pair( li_H, li_V );
8644 }
#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.

8654 {
8655  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8656  auto vx = par.a2 * par.cost * par.cost + par.b2 * par.sint * par.sint;
8657  auto vy = par.a2 * par.sint * par.sint + par.b2 * par.cost * par.cost;
8658  auto vx_sq = homog2d_sqrt( vx );
8659  auto vy_sq = homog2d_sqrt( vy );
8660  return FRect_<HOMOG2D_INUMTYPE>(
8661  Point2d_<HOMOG2D_INUMTYPE>( par.x0 - vx_sq, par.y0 - vy_sq ),
8662  Point2d_<HOMOG2D_INUMTYPE>( par.x0 + vx_sq, par.y0 + vy_sq )
8663  );
8664 }
#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& )
8583 {
8584  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8585  return Point2d_<FPT>( par.x0, par.y0 );
8586 }
Here is the caller graph for this function:

◆ getMajMin()

template<typename FPT >
std::pair< HOMOG2D_INUMTYPE, HOMOG2D_INUMTYPE > h2d::Ellipse_< FPT >::getMajMin ( ) const
8592 {
8593  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8594  return std::make_pair( par.a, par.b );
8595 }
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.
8682 {
8683 // step 1: build ptA using angle
8684  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8685  auto dy = par.sint * par.a;
8686  auto dx = par.cost * par.a;
8687  Point2d_<FPT> ptA(
8688  par.x0 + dx,
8689  par.y0 + dy
8690  );
8691  auto pt0 = Point2d_<HOMOG2D_INUMTYPE>( par.x0, par.y0 );
8692 
8693 // step 2: build main-axis line, going through center and ptA
8694  auto li_H = ptA * pt0;
8695 
8696 // step 3: get ptB, using line and distance
8697  auto ppts = li_H.getPoints( pt0, par.a );
8698  auto ptB = ppts.first;
8699  if( ptB == ptA )
8700  ptB = ppts.second;
8701 
8702  auto para = getParallelLines( li_H, par.b );
8703  auto li_V1 = li_H.getOrthogLine( ptA );
8704  auto li_V2 = li_H.getOrthogLine( ptB );
8705 
8706  CPolyline_<FPT> out;
8707 #ifndef HOMOG2D_DEBUGMODE
8708  out.p_addPoint( para.first * li_V1 );
8709  out.p_addPoint( para.second * li_V1 );
8710  out.p_addPoint( para.second * li_V2 );
8711  out.p_addPoint( para.first * li_V2 );
8712 #else
8713  auto p1 = para.first * li_V1;
8714  auto p2 = para.second * li_V1;
8715  auto p3 = para.second * li_V2;
8716  auto p4 = para.first * li_V2;
8718  ( p2!=p1 && p3!=p2 && p4!=p3 ),
8719  "p1=" << p1 << " p2=" << p2 << " p3=" << p3 << " p4=" << p4
8720  << "\n para.1=" << para.first
8721  << "\n li_V1=" << li_V1
8722  << "\n ptA=" << ptA
8723  << "\n ptB=" << ptB
8724  << "\n " << ppts
8725  );
8726  out.p_addPoint( p1 );
8727  out.p_addPoint( p2 );
8728  out.p_addPoint( p3 );
8729  out.p_addPoint( p4 );
8730 #endif
8731  return out;
8732 }
#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:8470
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

8566 {
8567  const auto& m = detail::Matrix_<FPT>::_mdata;
8568  HOMOG2D_INUMTYPE A = m[0][0];
8569  HOMOG2D_INUMTYPE C = m[1][1];
8570  HOMOG2D_INUMTYPE B2 = m[0][1];
8571  if( homog2d_abs(A-C) < thres )
8572  if( homog2d_abs(B2)*2. < thres )
8573  return true;
8574  return false;
8575 }
#define HOMOG2D_INUMTYPE
Definition: homog2d.hpp:66
matrix_t< FPT > _mdata
Definition: homog2d.hpp:1475
#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.

8616 {
8617  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8618  auto ab_sum = par.a + par.b;
8619  auto ab_diff = par.a - par.b;
8620  auto h = ab_diff * ab_diff / (ab_sum * ab_sum);
8621  auto denom = (HOMOG2D_INUMTYPE)10. + homog2d_sqrt(4. - 3. * h);
8622  return (par.a + par.b) * M_PI * ( 1. + 3. * h / denom );
8623 }
#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.

2302  {
2305  auto par = p_getParams<HOMOG2D_INUMTYPE>();
2306  p_init( x, y, par.a, par.b, par.theta );
2307  }
#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.

2312  {
2313  this->moveTo( new_org.getX(), new_org.getY() );
2314  }
void moveTo(TX x, TY y)
Move Ellipse to new location.
Definition: homog2d.hpp:2301

◆ operator!=()

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

Comparison operator. Does normalization if required.

2378  {
2379  return !(*this == e);
2380  }

◆ operator==()

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

Comparison operator. Does normalization if required.

2358  {
2359  auto& data = detail::Matrix_<FPT>::_mdata;
2360 
2363  if( !h.isNormalized() )
2364  h.p_normalizeMat(2,2);
2365 
2366  for( int i=0; i<3; i++ )
2367  for( int j=0; j<3; j++ )
2368  if( std::fabs(
2369  static_cast<HOMOG2D_INUMTYPE>( data[i][j] ) - h.value(i,j) )
2370  >= thr::nullDeter()
2371  )
2372  return false;
2373  return true;
2374  }
void p_normalizeMat(int r, int c) const
Definition: homog2d.hpp:1562
matrix_t< FPT > _mdata
Definition: homog2d.hpp:1475
bool isNormalized() const
Definition: homog2d.hpp:1559
static HOMOG2D_INUMTYPE & nullDeter()
Definition: homog2d.hpp:1251

◆ 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

8743 {
8744  HOMOG2D_INUMTYPE x = pt.getX();
8745  HOMOG2D_INUMTYPE y = pt.getY();
8746 
8747  auto par = p_getParams<HOMOG2D_INUMTYPE>();
8748  const auto& x0 = par.x0;
8749  const auto& y0 = par.y0;
8750 
8751  auto v1 = par.cost * (x-x0) + par.sint * (y-y0);
8752  HOMOG2D_INUMTYPE sum = v1*v1 / par.a2;
8753 
8754  auto v2 = par.sint * (x-x0) - par.cost * (y-y0);
8755  sum += v2*v2 / par.b2;
8756  if( sum < 1. )
8757  return true;
8758  return false;
8759 }
#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.

2321  {
2322  return 1;
2323  }

◆ translate() [1/2]

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

Translate Ellipse.

2286  {
2289  auto par = p_getParams<HOMOG2D_INUMTYPE>();
2290  p_init( par.x0+dx, par.y0+dy, par.a, par.b, par.theta );
2291  }
#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.

2295  {
2296  this->translate( ppt.first, ppt.second );
2297  }
void translate(TX dx, TY dy)
Translate Ellipse.
Definition: homog2d.hpp:2285

◆ type()

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

Implements h2d::rtp::Root.

2230  {
2231  return Type::Ellipse;
2232  }

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

9758 {
9759  Ellipse_<FPT1> ell_in( cir );
9760  return h * ell_in;
9761 }
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} \]

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

◆ operator<<

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

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