DGtal  1.5.beta
DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue > Struct Template Reference

#include <DGtal/images/bijectiveRotations/CDLR_naiverotation.h>

Inheritance diagram for DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >:
[legend]

Public Member Functions

int X (int y, const double a, const double b, const int k) const
 
TOutputValue reflect (const double angle, TOutputValue center, const TInputValue &p) const
 
 CDLR_naiverotation (double ang=0., TOutputValue ptCenter=TOutputValue(0, 0), double starting_angle=0.)
 
double angle () const
 
double startingAngle () const
 
void set_angle (const double new_angle)
 set the angle of rotation and call the composition of reflections solver. More...
 
void set_startingAngle (const double new_startingAngle)
 set the starting angle not the rotation angle More...
 
TOutputValue center () const
 
TOutputValue & center ()
 
TOutputValue rotate (const TInputValue &p) const
 
TOutputValue operator() (const TInputValue &p) const
 

Protected Attributes

double my_angle
 The angle of rotation. More...
 
double my_startingAngle
 
TOutputValue my_center
 The center of rotation. More...
 

Detailed Description

template<typename TSpace, typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
struct DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >

Definition at line 48 of file CDLR_naiverotation.h.

Constructor & Destructor Documentation

◆ CDLR_naiverotation()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::CDLR_naiverotation ( double  ang = 0.,
TOutputValue  ptCenter = TOutputValue(0,0),
double  starting_angle = 0. 
)
inline

Definition at line 83 of file CDLR_naiverotation.h.

83  :my_angle(ang),my_center(ptCenter),my_startingAngle(starting_angle) {
84  }
double my_angle
The angle of rotation.
TOutputValue my_center
The center of rotation.

Member Function Documentation

◆ angle()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::angle ( ) const
inline
Returns
the angle of rotation.

Definition at line 87 of file CDLR_naiverotation.h.

87 {return my_angle;};

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_angle.

◆ center() [1/2]

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue& DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::center ( )
inline
Returns
a reference to the centre of rotation

Definition at line 104 of file CDLR_naiverotation.h.

104 {return my_center;};

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_center.

◆ center() [2/2]

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::center ( ) const
inline
Returns
the centre of rotation

Definition at line 102 of file CDLR_naiverotation.h.

102 {return my_center;};

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_center.

◆ operator()()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::operator() ( const TInputValue &  p) const
inline

Definition at line 114 of file CDLR_naiverotation.h.

114  {
115  return rotate(p);
116  }
TOutputValue rotate(const TInputValue &p) const

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::rotate().

◆ reflect()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::reflect ( const double  angle,
TOutputValue  center,
const TInputValue &  p 
) const
inline

Definition at line 54 of file CDLR_naiverotation.h.

54  {
55  double a = std::sin(angle/2.0);
56  double b = std::cos(angle/2.0);
57  TOutputValue pcentered = p;
58 
59  int k = std::floor(pcentered[0] + (a/b)*pcentered[1] + 0.5);
60 
61  TOutputValue X1 = TOutputValue(X(std::ceil(a*b*k),a,b,k),std::ceil(a*b*k));
62  TOutputValue X2 = TOutputValue(X(std::floor(a*b*k),a,b,k),std::floor(a*b*k));
63 
64  const double line2 = a*X1[0]-b*X1[1];
65  if(line2<b/2 && line2 >(-b/2)){
66  return TOutputValue(X(2*X1[1]-pcentered[1],a,b,k),2*X1[1]-pcentered[1]);
67  }else{
68  const double line3 = a*X2[0]-b*X2[1];
69  if(line3<b/2 && line3 >(-b/2)){
70  return TOutputValue(X(2*X2[1]-pcentered[1],a,b,k),2*X2[1]-pcentered[1]);
71  }
72  else{
73  return TOutputValue(X(X1[1]+X2[1]-pcentered[1],a,b,k),X1[1]+X2[1]-pcentered[1]);
74  }
75  }
76 
77 
78  }
int X(int y, const double a, const double b, const int k) const

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::X().

Referenced by DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::rotate().

◆ rotate()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::rotate ( const TInputValue &  p) const
inline

◆ set_angle()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
void DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::set_angle ( const double  new_angle)
inline

set the angle of rotation and call the composition of reflections solver.

Definition at line 93 of file CDLR_naiverotation.h.

93 {my_angle=new_angle;}

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_angle.

◆ set_startingAngle()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
void DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::set_startingAngle ( const double  new_startingAngle)
inline

set the starting angle not the rotation angle

Definition at line 96 of file CDLR_naiverotation.h.

96 {my_startingAngle=new_startingAngle;}

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_startingAngle.

◆ startingAngle()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::startingAngle ( ) const
inline
Returns
the starting angle.

Definition at line 90 of file CDLR_naiverotation.h.

90 {return my_startingAngle;};

References DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_startingAngle.

◆ X()

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
int DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::X ( int  y,
const double  a,
const double  b,
const int  k 
) const
inline

Definition at line 50 of file CDLR_naiverotation.h.

50  {
51  return std::ceil((2.0*k-1)/2.0 - (a/b)*(y)); // a = sin(theta) ; b=cos(theta)
52  }

Referenced by DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::reflect().

Field Documentation

◆ my_angle

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_angle
protected

◆ my_center

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
TOutputValue DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_center
protected

◆ my_startingAngle

template<typename TSpace , typename TInputValue = typename TSpace::Point, typename TOutputValue = typename TSpace::Point>
double DGtal::CDLR_naiverotation< TSpace, TInputValue, TOutputValue >::my_startingAngle
protected

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