Commit d204408f authored by Davis King's avatar Davis King

Added member functions to point_rotator and point_transform to allow

a user to read the state of these objects.
parent c4942358
......@@ -37,6 +37,15 @@ namespace dlib
return dlib::vector<double,2>(x,y);
}
const matrix<double,2,2> get_m(
) const
{
matrix<double,2,2> temp;
temp = cos_angle, -sin_angle,
sin_angle, cos_angle;
return temp;
}
private:
double sin_angle;
double cos_angle;
......@@ -68,6 +77,18 @@ namespace dlib
return dlib::vector<double,2>(x,y) + translate;
}
const matrix<double,2,2> get_m(
) const
{
matrix<double,2,2> temp;
temp = cos_angle, -sin_angle,
sin_angle, cos_angle;
return temp;
}
const dlib::vector<double,2> get_b(
) const { return translate; }
private:
double sin_angle;
double cos_angle;
......
......@@ -112,8 +112,24 @@ namespace dlib
) const;
/*!
ensures
- rotates p, then translates it and returns the result
- rotates p, then translates it and returns the result. The output
of this function is therefore equal to get_m()*p + get_b().
!*/
const matrix<double,2,2> get_m(
) const;
/*!
ensures
- returns the transformation matrix used by this object.
!*/
const dlib::vector<double,2> get_b(
) const;
/*!
ensures
- returns the offset vector used by this object.
!*/
};
// ----------------------------------------------------------------------------------------
......@@ -145,7 +161,15 @@ namespace dlib
) const;
/*!
ensures
- rotates p and returns the result
- rotates p and returns the result. The output of this function is
therefore equal to get_m()*p.
!*/
const matrix<double,2,2> get_m(
) const;
/*!
ensures
- returns the transformation matrix used by this object.
!*/
};
......
......@@ -294,6 +294,8 @@ namespace
point_rotator rot(pi/2);
DLIB_TEST(rot(point(1,0)) == point(0,1));
DLIB_TEST(rot(point(0,1)) == point(-1,0));
DLIB_TEST(point(rot.get_m()*(dlib::vector<double,2>(1,0))) == point(0,1));
DLIB_TEST(point(rot.get_m()*(dlib::vector<double,2>(0,1))) == point(-1,0));
}
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment