MCPcopy Create free account
hub / github.com/davisking/dlib / test_affine3d

Function test_affine3d

dlib/test/geometry.cpp:845–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843// ----------------------------------------------------------------------------------------
844
845 void test_affine3d()
846 {
847 const dlib::vector<double> x(1,0,0);
848 const dlib::vector<double> y(0,1,0);
849 const dlib::vector<double> z(0,0,1);
850 const dlib::vector<double> e(1,1,1);
851 const dlib::vector<double> ex(-1,1,1);
852 const dlib::vector<double> ey(1,-1,1);
853 const dlib::vector<double> ez(1,1,-1);
854
855 dlib::vector<double> w;
856
857 w = rotate_around_z(pi/2)(x);
858 DLIB_TEST(length(w-y) < 1e-12);
859 w = rotate_around_z(pi/2)(e);
860 DLIB_TEST(length(w-ex) < 1e-12);
861
862 w = rotate_around_y(-pi/2)(x);
863 DLIB_TEST(length(w-z) < 1e-12);
864 w = rotate_around_y(pi/2)(e);
865 DLIB_TEST(length(w-ez) < 1e-12);
866
867 w = rotate_around_x(pi/2)(y);
868 DLIB_TEST(length(w-z) < 1e-12);
869 w = rotate_around_x(pi/2)(e);
870 DLIB_TEST(length(w-ey) < 1e-12);
871
872 w = translate_point(x)(y);
873 DLIB_TEST(length(w-x-y) < 1e-12);
874
875 point_transform_affine3d tform;
876 tform = rotate_around_x(pi/2)*rotate_around_z(pi/2)*translate_point(x);
877 DLIB_TEST(length(tform(dlib::vector<double>())-z) < 1e-12);
878 DLIB_TEST(length(inv(tform)(z)) < 1e-12);
879
880 point_transform_affine tform2;
881 tform = tform*tform2;// the default tform is the identity mapping so this shouldn't do anything different
882 DLIB_TEST(length(tform(dlib::vector<double>())-z) < 1e-12);
883 DLIB_TEST(length(inv(tform)(z)) < 1e-12);
884 }
885
886// ----------------------------------------------------------------------------------------
887

Callers 1

perform_testMethod · 0.85

Calls 6

rotate_around_zFunction · 0.85
rotate_around_yFunction · 0.85
rotate_around_xFunction · 0.85
translate_pointFunction · 0.85
lengthFunction · 0.50
invFunction · 0.50

Tested by

no test coverage detected