41     double x_cx = 0, x_cy = 0;
    42     double y_cx = 0, y_cy = 0;
    44     for (
int i = 0; i < 
zarray_size(correspondences); i++) {
    65     for (
int i = 0; i < 
zarray_size(correspondences); i++) {
    70         double worldx = c[0] - x_cx;
    71         double worldy = c[1] - x_cy;
    72         double imagex = c[2] - y_cx;
    73         double imagey = c[3] - y_cy;
    78         double a06 = worldx*imagey;
    79         double a07 = worldy*imagey;
   107         double a16 = -worldx*imagex;
   108         double a17 = -worldy*imagex;
   109         double a18 = -imagex;
   133         double a20 = -worldx*imagey;
   134         double a21 = -worldy*imagey;
   135         double a22 = -imagey;
   136         double a23 = worldx*imagex;
   137         double a24 = worldy*imagex;
   164     for (
int i = 0; i < 9; i++)
   165         for (
int j = i+1; j < 9; j++)
   177             for (
int i = 0; i < 9; i++)
   181             for (
int i = 0; i < 3; i++)
   182                 for (
int j = 0; j < 3; j++)
   188             matd_t *b = 
matd_create_data(9, 1, (
double[]) { 1, 0, 0, 0, 0, 0, 0, 0, 0 });
   203             for (
int i = 0; i < 9; i++)
   207             for (
int i = 0; i < 3; i++)
   208                 for (
int j = 0; j < 3; j++)
   219         for (
int i = 0; i < 3; i++)
   220             for (
int j = 0; j < 3; j++)
   281     double R00 = (
MATD_EL(H, 0, 0) - cx*R20) / fx;
   282     double R01 = (
MATD_EL(H, 0, 1) - cx*R21) / fx;
   283     double TX  = (
MATD_EL(H, 0, 2) - cx*TZ)  / fx;
   284     double R10 = (
MATD_EL(H, 1, 0) - cy*R20) / fy;
   285     double R11 = (
MATD_EL(H, 1, 1) - cy*R21) / fy;
   286     double TY  = (
MATD_EL(H, 1, 2) - cy*TZ)  / fy;
   290     double length1 = sqrtf(R00*R00 + R10*R10 + R20*R20);
   291     double length2 = sqrtf(R01*R01 + R11*R11 + R21*R21);
   292     double s = 1.0 / sqrtf(length1 * length2);
   310     double R02 = R10*R21 - R20*R11;
   311     double R12 = R20*R01 - R00*R21;
   312     double R22 = R00*R11 - R10*R01;
   327         R = 
matd_op(
"M*M'", svd.U, svd.V);
   363     double R20 = -
MATD_EL(H, 2, 0);
   364     double R21 = -
MATD_EL(H, 2, 1);
   366     double R00 = (
MATD_EL(H, 0, 0) - A*R20) / F;
   367     double R01 = (
MATD_EL(H, 0, 1) - A*R21) / F;
   368     double TX  = (
MATD_EL(H, 0, 2) - A*TZ)  / F;
   369     double R10 = (
MATD_EL(H, 1, 0) - B*R20) / G;
   370     double R11 = (
MATD_EL(H, 1, 1) - B*R21) / G;
   371     double TY  = (
MATD_EL(H, 1, 2) - B*TZ)  / G;
   375     double length1 = sqrtf(R00*R00 + R10*R10 + R20*R20);
   376     double length2 = sqrtf(R01*R01 + R11*R11 + R21*R21);
   377     double s = 1.0 / sqrtf(length1 * length2);
   395     double R02 = R10*R21 - R20*R11;
   396     double R12 = R20*R01 - R00*R21;
   397     double R22 = R00*R11 - R10*R01;
   466     double w = q[0], x = q[1], y = q[2], z = q[3];
   468     MATD_EL(M, 0, 0) = w*w + x*x - y*y - z*z;
   469     MATD_EL(M, 0, 1) = 2*x*y - 2*w*z;
   470     MATD_EL(M, 0, 2) = 2*x*z + 2*w*y;
   472     MATD_EL(M, 1, 0) = 2*x*y + 2*w*z;
   473     MATD_EL(M, 1, 1) = w*w - x*x + y*y - z*z;
   474     MATD_EL(M, 1, 2) = 2*y*z - 2*w*x;
   476     MATD_EL(M, 2, 0) = 2*x*z - 2*w*y;
   477     MATD_EL(M, 2, 1) = 2*y*z + 2*w*x;
   478     MATD_EL(M, 2, 2) = w*w - x*x - y*y + z*z;
 matd_svd_t matd_svd_flags(matd_t *A, int flags)
static void zarray_get_volatile(const zarray_t *za, int idx, void *p)
matd_plu_t * matd_plu(const matd_t *a)
void quat_to_matrix(const double q[4], matd_t *M)
#define MATD_SVD_NO_WARNINGS
void matd_chol_destroy(matd_chol_t *chol)
static int zarray_size(const zarray_t *za)
matd_t * matd_chol_solve(const matd_chol_t *chol, const matd_t *b)
#define MATD_EL(m, row, col)
matd_svd_t matd_svd(matd_t *A)
matd_t * homography_compute(zarray_t *correspondences, int flags)
matd_chol_t * matd_chol(matd_t *A)
#define HOMOGRAPHY_COMPUTE_FLAG_INVERSE
static double sq(double v)
matd_t * matd_create_data(int rows, int cols, const TYPE *data)
matd_t * homography_to_pose(const matd_t *H, double fx, double fy, double cx, double cy)
void matd_destroy(matd_t *m)
matd_t * matd_identity(int dim)
matd_t * matd_create(int rows, int cols)
matd_t * matd_plu_solve(const matd_plu_t *mlu, const matd_t *b)
matd_t * matd_inverse(const matd_t *x)
matd_t * matd_op(const char *expr,...)
matd_t * homography_to_model_view(const matd_t *H, double F, double G, double A, double B, double C, double D)
void matd_plu_destroy(matd_plu_t *mlu)