mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added member functions to point_rotator and point_transform to allow
a user to read the state of these objects.
This commit is contained in:
parent
c494235850
commit
d204408f82
@ -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));
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user