29 #if defined(CDLR_NAIVEROTATION_RECURSES)
30 #error Recursive header files inclusion detected in RDSL.h
33 #define CDLR_NAIVEROTATION_RECURSES
35 #if !defined CDLR_NAIVEROTATION_h
37 #define CDLR_NAIVEROTATION_h
39 #include "DGtal/base/Common.h"
40 #include <DGtal/images/RigidTransformation2D.h>
41 #include "PointUtils.h"
42 #include "DigitizedReflection.h"
47 template <
typename TSpace,
typename TInputValue =
typename TSpace::Po
int,
typename TOutputValue =
typename TSpace::Po
int>
50 inline int X(
int y,
const double a,
const double b,
const int k)
const {
51 return std::ceil((2.0*k-1)/2.0 - (a/b)*(y));
54 TOutputValue
reflect(
const double angle, TOutputValue
center,
const TInputValue& p )
const{
55 double a = std::sin(angle/2.0);
56 double b = std::cos(angle/2.0);
57 TOutputValue pcentered = p;
59 int k = std::floor(pcentered[0] + (a/b)*pcentered[1] + 0.5);
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));
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]);
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]);
73 return TOutputValue(
X(X1[1]+X2[1]-pcentered[1],a,b,k),X1[1]+X2[1]-pcentered[1]);
109 TOutputValue
rotate(
const TInputValue& p )
const {
137 #undef CDLR_NAIVEROTATION_RECURSES
DGtal is the top-level namespace which contains all DGtal functions and types.
double my_angle
The angle of rotation.
TOutputValue operator()(const TInputValue &p) const
double startingAngle() const
void set_startingAngle(const double new_startingAngle)
set the starting angle not the rotation angle
int X(int y, const double a, const double b, const int k) const
TOutputValue center() const
TOutputValue reflect(const double angle, TOutputValue center, const TInputValue &p) const
void set_angle(const double new_angle)
set the angle of rotation and call the composition of reflections solver.
TOutputValue rotate(const TInputValue &p) const
CDLR_naiverotation(double ang=0., TOutputValue ptCenter=TOutputValue(0, 0), double starting_angle=0.)
TOutputValue my_center
The center of rotation.