10 Eigen::MatrixXf get_2D_to_3D(
int width,
int height) {
11 Eigen::MatrixXf A1(4,3);
12 A1 << 1, 0, -1*(float)width/2,
13 0, 1, -1*(
float)height/2,
19 Eigen::MatrixXf get_rotation(
float theta,
float phi,
float gamma) {
20 Eigen::Matrix4f Rx, Ry, Rz, R;
22 0, std::cos(theta), -1*std::sin(theta), 0,
23 0, std::sin(theta), std::cos(theta), 0,
25 Ry << std::cos(phi), 0, -1*std::sin(phi), 0,
27 std::sin(phi), 0, std::cos(phi), 0,
29 Rz << std::cos(gamma), -1*std::sin(gamma), 0, 0,
30 std::sin(gamma), std::cos(gamma), 0, 0,
37 Eigen::MatrixXf get_translation(
int dx,
int dy,
int dz) {
46 Eigen::MatrixXf get_3D_to_2D(
float focal,
int width,
int height) {
47 Eigen::MatrixXf A2(3,4);
48 A2 << focal, 0, (float)width/2, 0,
49 0, focal, (
float)height/2, 0,
54 Eigen::Matrix<float, 3, 3> get_transformation_matrix(
55 int width,
int height,
56 float theta,
float phi,
float gamma,
57 int dx,
int dy,
int dz,
59 Eigen::MatrixXf A1 = get_2D_to_3D(width, height);
60 Eigen::Matrix4f R = get_rotation(theta, phi, gamma);
61 Eigen::Matrix4f T = get_translation(dx, dy, dz);
62 Eigen::MatrixXf A2 = get_3D_to_2D(focal, width, height);
63 return (A2 * (T * (R * A1)));
double gamma(const double alpha=double(1))