2 #ifndef vgl_ellipse_scan_iterator_hxx_ 3 #define vgl_ellipse_scan_iterator_hxx_ 8 # include <vcl_msvc_warnings.h> 13 template <
class T>
inline T my_max( T x, T y ) {
return x<y ? y : x; }
36 if ( std::sin( theta_ ) == 0.0 ) {
40 T t = std::atan2( std::sqrt(ry_) , std::sqrt(rx_) * std::tan( theta_ ) );
41 y0 = std::sqrt(rx_) * std::cos( t ) * std::sin( theta_ ) + std::sqrt(ry_) * std::sin( t ) * std::cos( theta_ );
43 if ( y0 < 0 ) y0 = -y0;
45 y_ = int( std::floor( yc_ + y0 ) ) + 1;
46 min_y_ = int( std::ceil( yc_ - y0 ) );
53 if ( y_ < min_y_ )
return false;
55 T st = std::sin( -theta_ );
56 T ct = std::cos( -theta_ );
57 T A = rx_ * st * st + ry_ * ct * ct;
64 T B = (rx_ - ry_) * (y_-yc_) * ct*st;
66 T D = rx_*ry_*(rx_*st*st + ry_*ct*ct - (y_-yc_)*(y_-yc_));
69 x0 = (-B + std::sqrt( D )) / A;
70 x1 = (-B - std::sqrt( D )) / A;
75 x0 = std::sqrt( my_max(rx_,ry_) );
79 start_x_= int( std::ceil( xc_ + x1 - 1e-9 ) );
80 end_x_ = int( std::floor( xc_ + x0 + 1e-9 ) );
82 if ( start_x_ > end_x_ ) {
91 #undef VGL_ELLIPSE_SCAN_ITERATOR_INSTANTIATE 92 #define VGL_ELLIPSE_SCAN_ITERATOR_INSTANTIATE(T) \ 93 template class vgl_ellipse_scan_iterator<T > 95 #endif // vgl_ellipse_scan_iterator_hxx_ vgl_ellipse_scan_iterator(T xc, T yc, T rx, T ry, T theta)
Constructor.
~vgl_ellipse_scan_iterator() override
Destructor.
void reset() override
Resets the scan iterator to before the first scan line.
bool next() override
Tries to moves to the next scan line.