Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxBSplineInterval Class Reference

Class definition for HxBSplineInterval to facilitate manipulation of path intervals in open and closed curves. More...

#include <HxBSplineInterval.h>

List of all members.

Public Methods

 HxBSplineInterval ()
 Default constructor. More...

 HxBSplineInterval (double b, double e, double min, double max, HxBSplineType type)
 Construct interval [b,e) in a curve with total path from [min,max) and given type. More...

 HxBSplineInterval (double b, double e, double min, double max, int closed)
 Construct interval [b,e) in a curve with total path from [min,max) and given type. More...

 ~HxBSplineInterval ()
 Destructor. More...

double begin () const
 first t in interval. More...

double end () const
 last t in interval. More...

int contains (double t) const
 Determine if the path parameter t is inside this interval. More...

double next (double t, double delta) const
 returns t+delta, with wrapping for closed intervals. More...

double prev (double t, double delta) const
 returns t-delta, with wrapping for closed intervals. More...

double length () const
 path lenght of interval. More...

double middle () const
 middle t of interval. More...

double ratio (double r) const
 t corresponding to given proportion of interval. More...

int isClosed () const
 1 if interval is wrapped. More...

HxBSplineInterval cropBegin (double t) const
 cut begin of interval: [t,e). More...

HxBSplineInterval cropEnd (double t) const
 cut end of interval: [b,t). More...

HxBSplineInterval part (double t1, double t2) const
 get subinterval [t1,t2). More...


Detailed Description

Class definition for HxBSplineInterval to facilitate manipulation of path intervals in open and closed curves.

path interval (oriented). interval = [first, second). For open paths, first < second (always). For closed paths, first > second indicates wrap around t=min, max.


Constructor & Destructor Documentation

HxBSplineInterval::HxBSplineInterval   [inline]
 

Default constructor.

00099                                      : pair<double,double>() 
00100 {
00101     _min = 0;
00102     _max = 0;
00103     _wrap = 0;
00104 }

HxBSplineInterval::HxBSplineInterval double    b,
double    e,
double    min,
double    max,
HxBSplineType    type
[inline]
 

Construct interval [b,e) in a curve with total path from [min,max) and given type.

00109     : pair<double,double>(b,e) 
00110 {
00111     _min = min;
00112     _max = max;
00113     _wrap = (type == closed);
00114 }

HxBSplineInterval::HxBSplineInterval double    b,
double    e,
double    min,
double    max,
int    wrap
[inline]
 

Construct interval [b,e) in a curve with total path from [min,max) and given type.

00119     : pair<double,double>(b,e) 
00120 {
00121     _min = min;
00122     _max = max;
00123     _wrap = wrap;
00124 }

HxBSplineInterval::~HxBSplineInterval   [inline]
 

Destructor.

00128 {
00129 }


Member Function Documentation

double HxBSplineInterval::begin   const [inline]
 

first t in interval.

00133 {
00134     return first;
00135 }

double HxBSplineInterval::end   const [inline]
 

last t in interval.

00139 {
00140     return second;
00141 }

int HxBSplineInterval::contains double    t const [inline]
 

Determine if the path parameter t is inside this interval.

Consider wrapping for closed curves. interval = [first, second)

00145 {
00146     if ( first == second )      // special case?
00147         return (t >= _min && t < _max);
00148     if ( first > second )       // is wrapped?
00149         return (t >= first && t < _max) || (t >= _min && t < second);
00150     else    return (t >= first && t < second);
00151 }

double HxBSplineInterval::next double    t,
double    delta
const [inline]
 

returns t+delta, with wrapping for closed intervals.

00155 {
00156     t += delta;
00157     if ( t >= _max && _wrap )
00158         t = _min + (t - _max);
00159     return t;
00160 }

double HxBSplineInterval::prev double    t,
double    delta
const [inline]
 

returns t-delta, with wrapping for closed intervals.

00164 {
00165     t -= delta;
00166     if ( t <  _min && _wrap )
00167         t = _max - (_min - t);
00168     return t;
00169 }

double HxBSplineInterval::length   const [inline]
 

path lenght of interval.

00173 {
00174     double tmp = second - first;
00175     if ( tmp < 0 && _wrap ) 
00176         return (_max - EPS - first) + (second - _min);
00177     else    if ( tmp < EPS )
00178             return EPS;
00179         else    return tmp - EPS;
00180 }

double HxBSplineInterval::middle   const [inline]
 

middle t of interval.

00184 {
00185     return ratio(0.5);
00186 }

double HxBSplineInterval::ratio double    r const [inline]
 

t corresponding to given proportion of interval.

00190 {
00191     double t = length() * r + first;
00192     if ( t >= _max )
00193         t = _min + (t - _max);
00194     return t;
00195 }

int HxBSplineInterval::isClosed   const [inline]
 

1 if interval is wrapped.

00199 {
00200     return _wrap;
00201 }

HxBSplineInterval HxBSplineInterval::cropBegin double    t const [inline]
 

cut begin of interval: [t,e).

00205 {
00206     HxBSplineInterval tmp(t, second, _min, _max, _wrap);
00207     return tmp;
00208 }

HxBSplineInterval HxBSplineInterval::cropEnd double    t const [inline]
 

cut end of interval: [b,t).

00212 {
00213     HxBSplineInterval tmp(first, t, _min, _max, _wrap);
00214     return tmp;
00215 }

HxBSplineInterval HxBSplineInterval::part double    t1,
double    t2
const [inline]
 

get subinterval [t1,t2).

00219 {
00220     HxBSplineInterval tmp(t1, t2, _min, _max, closed);
00221     tmp._wrap = _wrap;
00222     return tmp;
00223 }


The documentation for this class was generated from the following file:
Generated on Tue Feb 3 14:18:54 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001