Commit f8e91c4f authored by Davis King's avatar Davis King

Made it so you can multiply 2d and 3d point transforms together.

parent 0a4fa534
......@@ -682,6 +682,21 @@ namespace dlib
dlib::vector<double,3> b;
};
// ----------------------------------------------------------------------------------------
inline point_transform_affine3d operator* (
const point_transform_affine3d& lhs,
const point_transform_affine& rhs
)
{
matrix<double,3,3> m;
m = 0;
set_subm(m, get_rect(rhs.get_m())) = rhs.get_m();
vector<double,3> b = rhs.get_b();
return point_transform_affine3d(lhs.get_m()*m, lhs.get_m()*b+lhs.get_b());
}
// ----------------------------------------------------------------------------------------
inline point_transform_affine3d operator* (
......
......@@ -482,7 +482,19 @@ namespace dlib
is, for all valid x: TFORM(x) == lhs(rhs(x)).
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
point_transform_affine3d operator* (
const point_transform_affine3d& lhs,
const point_transform_affine& rhs
);
/*!
ensures
- returns a transformation TFORM(x) that is equivalent to lhs(rhs(x)). That
is, for all valid x: TFORM(x) == lhs(rhs(x)).
!*/
// ----------------------------------------------------------------------------------------
point_transform_affine3d inv (
const point_transform_affine3d& trans
......
......@@ -831,6 +831,11 @@ namespace
tform = rotate_around_x(pi/2)*rotate_around_z(pi/2)*translate_point(x);
DLIB_TEST(length(tform(dlib::vector<double>())-z) < 1e-12);
DLIB_TEST(length(inv(tform)(z)) < 1e-12);
point_transform_affine tform2;
tform = tform*tform2;// the default tform is the identity mapping so this shouldn't do anything different
DLIB_TEST(length(tform(dlib::vector<double>())-z) < 1e-12);
DLIB_TEST(length(inv(tform)(z)) < 1e-12);
}
// ----------------------------------------------------------------------------------------
......
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