TINA  4
TINAmachinevisionlibraries
Functions
geomfuncs.h File Reference

Go to the source code of this file.

Functions

Vec2 vec2_midpoint (Vec2 q1, Vec2 q2)
Vec2 vec2_projperp (Vec2 u, Vec2 v)
Vec2 vec2_projpar (Vec2 u, Vec2 v)
Vec2 vec2_proj_on_line (Vec2 q, Vec2 l, Vec2 v)
Vec2 vec2_inter_lines (Vec2 l1, Vec2 v1, Vec2 l2, Vec2 v2)
void vec2_join_2_points (Vec2 q1, Vec2 q2, Vec2 *l, Vec2 *v)
double vec2_dist_point_line (Vec2 q, Vec2 l, Vec2 v)
void vec2_circ_3_points (Vec2 p1, Vec2 p2, Vec2 p3, Vec2 *centre, double *radius)
Vec2vec2_inter_par_test (Vec2 p, Vec2 v1, Vec2 q, Vec2 v2, double parallel)
Vec3 vec3_midpoint (Vec3 q1, Vec3 q2)
Vec3 vec3_projperp (Vec3 u, Vec3 v)
Vec3 vec3_projpar (Vec3 u, Vec3 v)
Vec3 vec3_proj_on_line (Vec3 q, Vec3 l, Vec3 v)
Vec3 vec3_proj_on_plane (Vec3 q, Vec3 p, Vec3 n)
Vec3 vec3_closest_lines (Vec3 l1, Vec3 v1, Vec3 l2, Vec3 v2)
Vec3 vec3_inter_lines (Vec3 l1, Vec3 v1, Vec3 l2, Vec3 v2)
Vec3 vec3_inter_line_plane (Vec3 l, Vec3 v, Vec3 p, Vec3 n)
void vec3_inter_planes (Vec3 p1, Vec3 n1, Vec3 p2, Vec3 n2, Vec3 *l, Vec3 *v)
void vec3_join_2_points (Vec3 q1, Vec3 q2, Vec3 *l, Vec3 *v)
void vec3_join_3_points (Vec3 q1, Vec3 q2, Vec3 q3, Vec3 *p, Vec3 *n)
void vec3_join_point_line (Vec3 q, Vec3 l, Vec3 v, Vec3 *p, Vec3 *n)
void vec3_join_lines (Vec3 l1, Vec3 v1, Vec3 l2, Vec3 v2, Vec3 *p, Vec3 *n)
double vec3_dist_point_plane (Vec3 q, Vec3 p, Vec3 n)
double vec3_dist_point_line (Vec3 q, Vec3 l, Vec3 v)
double vec3_dist_lines (Vec3 l1, Vec3 v1, Vec3 l2, Vec3 v2)
void vec3_circ_3_points (Vec3 p1, Vec3 p2, Vec3 p3, Vec3 *centre, Vec3 *normal, double *radius)
Bool vec3_collinear (Vec3 p1, Vec3 p2, Vec3 q1, Vec3 q2, double dotth1, double dotth2)
double vec3_closest_app (Vec3 p1, Vec3 v1, Vec3 p2, Vec3 v2, Vec3 *c1, Vec3 *c2)
Bool vec3_parallel (Vec3 v1, Vec3 v2, double dotthres)
void vec2_extend_hull (Vec2 *vmin, Vec2 *vmax, Vec2 v)
void vec3_extend_hull (Vec3 *vmin, Vec3 *vmax, Vec3 v)
Iposipos_alloc (void)
Iposipos_make (int x, int y)
void ipos_free (void *pos)
Bool ipos_equal (Ipos pos1, Ipos pos2)
Ipos ipos (int x, int y)
Ipos ipos_zero (void)
Ipos ipos_ex (void)
Ipos ipos_ey (void)
void ipos_comps (Ipos pos, int *x, int *y)
Ipos ipos_sum (Ipos pos1, Ipos pos2)
Ipos ipos_sum3 (Ipos pos0, Ipos pos1, Ipos pos2)
Ipos ipos_sum4 (Ipos pos0, Ipos pos1, Ipos pos2, Ipos pos3)
Ipos ipos_minus (Ipos pos)
Ipos ipos_diff (Ipos pos1, Ipos pos2)
Ipos ipos_times (double k, Ipos pos)
int ipos_dot (Ipos pos1, Ipos pos2)
int ipos_cross (Ipos pos1, Ipos pos2)
double ipos_mod (Ipos pos)
double ipos_sqrmod (Ipos pos)
double ipos_dist (Ipos pos1, Ipos pos2)
int ipos_manhattan (Ipos pos1, Ipos pos2)
int ipos_maxabs (Ipos pos1, Ipos pos2)
double ipos_sqrdist (Ipos pos1, Ipos pos2)
double ipos_dist_seg (Ipos p, Ipos e1, Ipos e2)
Ipos ipos_midpoint (Ipos p1, Ipos p2)
Ipos ipos_read (FILE *fp)
void ipos_print (FILE *fp, Ipos pos)
void ipos_pprint (FILE *fp, char *msg, Ipos pos)
void * mat2_alloc (void)
void * mat2_make (Mat2 n)
void mat2_free (void *m)
Mat2 mat2 (double mxx, double mxy, double myx, double myy)
Mat2 mat2_unit (void)
Mat2 mat2_zero (void)
void mat2_comps (Mat2 m, float *mxx, float *mxy, float *myx, float *myy)
Vec2 mat2_rowx (Mat2 m)
Vec2 mat2_rowy (Mat2 m)
Vec2 mat2_colx (Mat2 m)
Vec2 mat2_coly (Mat2 m)
Mat2 mat2_of_rows (Vec2 rx, Vec2 ry)
Mat2 mat2_of_cols (Vec2 cx, Vec2 cy)
Mat2 mat2_sum (Mat2 m, Mat2 n)
Mat2 mat2_diff (Mat2 m, Mat2 n)
Mat2 mat2_minus (Mat2 m)
Mat2 mat2_times (double k, Mat2 m)
Mat2 mat2_prod (Mat2 m, Mat2 n)
Mat2 mat2_inverse (Mat2 m)
Mat2 mat2_transpose (Mat2 m)
Mat2 mat2_sym (Mat2 m)
double mat2_trace (Mat2 m)
double mat2_det (Mat2 m)
Bool mat2_posdef (Mat2 m)
Vec2 mat2_vprod (Mat2 m, Vec2 v)
double mat2_sprod (Vec2 v, Mat2 m, Vec2 w)
Mat2 mat2_tensor (Vec2 v, Vec2 w)
Mat2 mat2_read (FILE *fp)
void mat2_print (FILE *fp, Mat2 m)
void mat2_pprint (FILE *fp, char *msg, Mat2 m)
void mat2_format (Mat2 m)
void mat2_sym_eigen (Mat2 m, double *theta, double *lambda1, double *lambda2)
Mat3mat3_alloc (void)
Mat3mat3_make (Mat3 n)
void mat3_free (Mat3 *m)
double mat3_get_xx (Mat3 m)
double mat3_get_xy (Mat3 m)
double mat3_get_xz (Mat3 m)
double mat3_get_yx (Mat3 m)
double mat3_get_yy (Mat3 m)
double mat3_get_yz (Mat3 m)
double mat3_get_zx (Mat3 m)
double mat3_get_zy (Mat3 m)
double mat3_get_zz (Mat3 m)
Mat3 mat3 (double mxx, double mxy, double mxz, double myx, double myy, double myz, double mzx, double mzy, double mzz)
Mat3 mat3_unit (void)
Mat3 mat3_zero (void)
Mat3 mat3_diag (double mxx, double myy, double mzz)
void mat3_comps (Mat3 m, float *mxx, float *mxy, float *mxz, float *myx, float *myy, float *myz, float *mzx, float *mzy, float *mzz)
Vec3 mat3_rowx (Mat3 m)
Vec3 mat3_rowy (Mat3 m)
Vec3 mat3_rowz (Mat3 m)
Vec3 mat3_colx (Mat3 m)
Vec3 mat3_coly (Mat3 m)
Vec3 mat3_colz (Mat3 m)
Mat3 mat3_of_cols (Vec3 cx, Vec3 cy, Vec3 cz)
Mat3 mat3_of_rows (Vec3 rx, Vec3 ry, Vec3 rz)
Mat3 mat3_sum (Mat3 m, Mat3 n)
Mat3 mat3_sum3 (Mat3 l, Mat3 m, Mat3 n)
Mat3 mat3_diff (Mat3 m, Mat3 n)
Mat3 mat3_minus (Mat3 m)
Mat3 mat3_times (double k, Mat3 m)
Mat3 mat3_prod (Mat3 m, Mat3 n)
Mat3 mat3_inverse (Mat3 m)
Mat3 mat3_transpose (Mat3 m)
double mat3_trace (Mat3 m)
double mat3_det (Mat3 m)
Bool mat3_posdef (Mat3 m)
Vec3 mat3_vprod (Mat3 m, Vec3 v)
Vec3 mat3_transpose_vprod (Mat3 m, Vec3 v)
double mat3_sprod (Vec3 v, Mat3 m, Vec3 w)
Mat3 mat3_tensor (Vec3 v, Vec3 w)
Mat3 mat3_sum_tensor (Mat3 m, Vec3 v, Vec3 w)
Mat3 mat3_read (FILE *fp)
void mat3_print (FILE *fp, Mat3 m)
void mat3_pprint (FILE *fp, char *msg, Mat3 m)
void mat3_format (Mat3 m)
void mat3_eigen (Mat3 m, double *eval, Vec3 *evec)
Mat4mat4_alloc (void)
Mat4mat4_make (Mat4 n)
void mat4_free (Mat4 *m)
double mat4_get_xx (Mat4 m)
double mat4_get_xy (Mat4 m)
double mat4_get_xz (Mat4 m)
double mat4_get_xw (Mat4 m)
double mat4_get_yx (Mat4 m)
double mat4_get_yy (Mat4 m)
double mat4_get_yz (Mat4 m)
double mat4_get_yw (Mat4 m)
double mat4_get_zx (Mat4 m)
double mat4_get_zy (Mat4 m)
double mat4_get_zz (Mat4 m)
double mat4_get_zw (Mat4 m)
double mat4_get_wx (Mat4 m)
double mat4_get_wy (Mat4 m)
double mat4_get_wz (Mat4 m)
double mat4_get_ww (Mat4 m)
Mat4 mat4 (double mxx, double mxy, double mxz, double mxw, double myx, double myy, double myz, double myw, double mzx, double mzy, double mzz, double mzw, double mwx, double mwy, double mwz, double mww)
Mat4 mat4_unit (void)
Mat4 mat4_zero (void)
void mat4_comps (Mat4 m, double *mxx, double *mxy, double *mxz, double *mxw, double *myx, double *myy, double *myz, double *myw, double *mzx, double *mzy, double *mzz, double *mzw, double *mwx, double *mwy, double *mwz, double *mww)
Vec4 mat4_rowx (Mat4 m)
Vec4 mat4_rowy (Mat4 m)
Vec4 mat4_rowz (Mat4 m)
Vec4 mat4_roww (Mat4 m)
Vec4 mat4_colx (Mat4 m)
Vec4 mat4_coly (Mat4 m)
Vec4 mat4_colz (Mat4 m)
Vec4 mat4_colw (Mat4 m)
Mat4 mat4_of_cols (Vec4 cx, Vec4 cy, Vec4 cz, Vec4 cw)
Mat4 mat4_of_rows (Vec4 rx, Vec4 ry, Vec4 rz, Vec4 rw)
Mat4 mat4_sum (Mat4 m, Mat4 n)
Mat4 mat4_diff (Mat4 m, Mat4 n)
Mat4 mat4_minus (Mat4 m)
Mat4 mat4_times (double k, Mat4 m)
Mat4 mat4_prod (Mat4 m, Mat4 n)
Mat4 mat4_inverse (Mat4 m)
Mat4 mat4_transpose (Mat4 m)
double mat4_trace (Mat4 m)
Vec4 mat4_vprod (Mat4 m, Vec4 v)
Vec4 mat4_transpose_vprod (Mat4 m, Vec4 v)
double mat4_sprod (Vec4 v, Mat4 m, Vec4 w)
Mat4 mat4_tensor (Vec4 v, Vec4 w)
Mat4 mat4_read (FILE *fp)
void mat4_print (FILE *fp, Mat4 m)
void mat4_pprint (FILE *fp, char *msg, Mat4 m)
void mat4_format (Mat4 m)
void mat4_eigen (Mat4 m, double *eval, Vec4 *evec)
Vec2 vec2_of_proj2 (Vec3 v)
Vec3 proj2_of_vec2 (Vec2 v)
Vec3 proj2_rectify (Mat3 m, Vec3 v)
Vec2 vec2_rectify (Mat3 m, Vec2 v)
Vec3 proj2_join (Vec3 p, Vec3 q)
Vec3 proj2_intersect (Vec3 p, Vec3 q)
Mat3 proj2_to_frame (Vec3 p00, Vec3 p10, Vec3 p01, Vec3 p11)
Mat3 proj2_between (Vec2 p00, Vec2 p10, Vec2 p01, Vec2 p11, Vec2 q00, Vec2 q10, Vec2 q01, Vec2 q11)
Mat3 proj2_between_proj2 (Vec3 p00, Vec3 p10, Vec3 p01, Vec3 p11, Vec3 q00, Vec3 q10, Vec3 q01, Vec3 q11)
Mat3 proj_x1 (int n, Vec3 *p, Vec3 *q, double *badness)
Mat3 proj_y1 (int n, Vec3 *p, Vec3 *q, double *badness)
Mat3 proj_z1 (int n, Vec3 *p, Vec3 *q, double *badness)
Mat3 proj_between_ls (int n, Vec3 *p, Vec3 *q)
Vec4 proj3_rectify (Mat4 m, Vec4 v)
Vec3 vec3_rectify (Mat4 m, Vec3 v)
Vec2vec2_alloc (void)
Vec2vec2_copy (Vec2 *vec2)
Vec2vec2_make (Vec2 u)
void vec2_free (void *v)
Vec2 vec2 (double x, double y)
Vec2 vec2_zero (void)
Vec2 vec2_ex (void)
Vec2 vec2_ey (void)
void vec2_comps (Vec2 v, float *x, float *y)
double vec2_get_x (Vec2 *v)
double vec2_get_y (Vec2 *v)
Vec2 vec2_sum (Vec2 v, Vec2 w)
Vec2 vec2_sum3 (Vec2 u, Vec2 v, Vec2 w)
Vec2 vec2_sum4 (Vec2 u, Vec2 v, Vec2 w, Vec2 x)
Vec2 vec2_minus (Vec2 v)
Vec2 vec2_diff (Vec2 v, Vec2 w)
Vec2 vec2_times (double k, Vec2 v)
Vec2 vec2_interp (double k, Vec2 v1, Vec2 v2)
double vec2_dot (Vec2 v, Vec2 w)
double vec2_cross (Vec2 v, Vec2 w)
double vec2_mod (Vec2 v)
double vec2_sqrmod (Vec2 v)
double vec2_modunit (Vec2 v, Vec2 *e)
Vec2 vec2_unit (Vec2 v)
void vec2_to_polar (Vec2 v, double *r, double *theta)
Vec2 vec2_of_polar (double r, double theta)
Vec2 vec2_rand_circle (Vec2 centre, double radius)
double vec2_dist (Vec2 v, Vec2 w)
double vec2_sqrdist (Vec2 v, Vec2 w)
double vec2_angle (Vec2 v, Vec2 w)
Vec2 vec2_perp (Vec2 v)
double vec2_perp_dist (Vec2 p, Vec2 v, Vec2 d)
void vec2_basis (Vec2 up, Vec2 *ex, Vec2 *ey)
int vec2_parallel (Vec2 v1, Vec2 v2, double dotthres)
Vec2 vec2_read (FILE *fp)
void vec2_print (FILE *fp, Vec2 v)
void vec2_pprint (FILE *fp, char *msg, Vec2 v)
void vec2_format (Vec2 v)
Vec2 vec2_less (Vec2 v1, Vec2 v2)
Vec2 vec2_greater (Vec2 v1, Vec2 v2)
void vec2_ranges (Vec2 *v1, Vec2 *v2, Vec2 vec)
Vec3vec3_alloc (void)
Vec3vec3_make (Vec3 u)
Vec3vec3_copy (Vec3 *u)
void vec3_free (void *v)
Vec3 vec3 (double x, double y, double z)
Vec3 vec3_zero (void)
Vec3 vec3_ex (void)
Vec3 vec3_ey (void)
Vec3 vec3_ez (void)
void vec3_comps (Vec3 v, float *x, float *y, float *z)
double vec3_get_x (Vec3 v)
double vec3_get_y (Vec3 v)
double vec3_get_z (Vec3 v)
Vec3 vec3_sum (Vec3 v, Vec3 w)
Vec3 vec3_sum3 (Vec3 u, Vec3 v, Vec3 w)
Vec3 vec3_sum4 (Vec3 u, Vec3 v, Vec3 w, Vec3 x)
Vec3 vec3_minus (Vec3 v)
Vec3 vec3_diff (Vec3 v, Vec3 w)
Vec3 vec3_times (double k, Vec3 v)
Vec3 vec3_interp (double k, Vec3 v1, Vec3 v2)
double vec3_dot (Vec3 v, Vec3 w)
Vec3 vec3_cross (Vec3 v, Vec3 w)
Vec3 vec3_unitcross (Vec3 v, Vec3 w)
double vec3_mod (Vec3 v)
double vec3_sqrmod (Vec3 v)
double vec3_modunit (Vec3 v, Vec3 *e)
Vec3 vec3_unit (Vec3 v)
double vec3_dist (Vec3 v, Vec3 w)
double vec3_sqrdist (Vec3 v, Vec3 w)
double vec3_angle (Vec3 v, Vec3 w)
Vec3 vec3_perp (Vec3 v)
void vec3_basis (Vec3 aim, Vec3 down, Vec3 *ex, Vec3 *ey, Vec3 *ez)
Vec3 vec3_read (FILE *fp)
void vec3_print (FILE *fp, Vec3 v)
void vec3_pprint (FILE *fp, char *msg, Vec3 v)
void vec3_format (Vec3 v)
Vec3 vec3_rand_sphere (Vec3 c, double r)
Vec4vec4_alloc (void)
Vec4vec4_make (Vec4 u)
void vec4_free (void *v)
Vec4 vec4 (double x, double y, double z, double w)
Vec4 vec4_zero (void)
Vec4 vec4_ex (void)
Vec4 vec4_ey (void)
Vec4 vec4_ez (void)
Vec4 vec4_ew (void)
void vec4_comps (Vec4 v, float *x, float *y, float *z, float *w)
double vec4_get_x (Vec4 v)
double vec4_get_y (Vec4 v)
double vec4_get_z (Vec4 v)
double vec4_get_w (Vec4 v)
Vec4 vec4_sum (Vec4 v, Vec4 w)
Vec4 vec4_sum3 (Vec4 u, Vec4 v, Vec4 w)
Vec4 vec4_sum4 (Vec4 u, Vec4 v, Vec4 w, Vec4 x)
Vec4 vec4_minus (Vec4 v)
Vec4 vec4_diff (Vec4 v, Vec4 w)
Vec4 vec4_times (double k, Vec4 v)
Vec4 vec4_interp (double k, Vec4 v1, Vec4 v2)
double vec4_dot (Vec4 v, Vec4 w)
Mat4 vec4_cross (Vec4 v, Vec4 w)
double vec4_mod (Vec4 v)
double vec4_sqrmod (Vec4 v)
double vec4_modunit (Vec4 v, Vec4 *e)
Vec4 vec4_unit (Vec4 v)
double vec4_dist (Vec4 v, Vec4 w)
double vec4_sqrdist (Vec4 v, Vec4 w)
double vec4_angle (Vec4 v, Vec4 w)
Vec4 vec4_read (FILE *fp)
void vec4_print (FILE *fp, Vec4 v)
void vec4_pprint (FILE *fp, char *msg, Vec4 v)
void vec4_format (Vec4 v)

Function Documentation

Ipos ipos ( int  x,
int  y 
)

Definition at line 44 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

{
    Ipos    pos = {Ipos_id};

    pos.x = x;
    pos.y = y;
    return (pos);
}
Ipos* ipos_alloc ( void  )

@(#)Ipos handling. Ipos is {int x; int y;} for use with list utilities

Definition at line 14 of file ipos.c.

References ts_ralloc, ipos::x, and ipos::y.

Referenced by tv_polyline2(), and tv_polyline3().

{
    Ipos   *pos = ts_ralloc(Ipos);

    pos->x = 0;
    pos->y = 0;
    return (pos);
}

Here is the caller graph for this function:

void ipos_comps ( Ipos  pos,
int *  x,
int *  y 
)

Definition at line 68 of file ipos.c.

References ipos::x, and ipos::y.

{
    *x = pos.x;
    *y = pos.y;
}
int ipos_cross ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 133 of file ipos.c.

References ipos::x, and ipos::y.

{
    return (pos1.x * pos2.y - pos1.y * pos2.x);
}
Ipos ipos_diff ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 110 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

Referenced by curve_section_draw(), draw_triangle3_fill(), pick_conic2_dist(), pick_conic3_dist(), tv_terrain_fill3(), and tv_terrain_hidden2().

{
    Ipos    diff = {Ipos_id};

    diff.x = pos1.x - pos2.x;
    diff.y = pos1.y - pos2.y;
    return (diff);
}

Here is the caller graph for this function:

double ipos_dist ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 152 of file ipos.c.

References sqrt(), ipos::x, and ipos::y.

Referenced by pick_plane_dist(), pick_point2_dist(), and pick_point3_dist().

{
    double  dx = pos1.x - pos2.x;
    double  dy = pos1.y - pos2.y;

    return (sqrt(dx * dx + dy * dy));
}

Here is the call graph for this function:

Here is the caller graph for this function:

double ipos_dist_seg ( Ipos  p,
Ipos  e1,
Ipos  e2 
)

Definition at line 181 of file ipos.c.

References ipos_x, ipos_y, sqr(), sqrt(), and t.

{
    double  x = ipos_x(p);
    double  y = ipos_y(p);
    double  x1 = ipos_x(e1);
    double  y1 = ipos_y(e1);
    double  x2 = ipos_x(e2);
    double  y2 = ipos_y(e2);
    double  dx, dy, dx1, dy1, l, t, d;

    dx = x2 - x1;
    dy = y2 - y1;
    dx1 = x - x1;
    dy1 = y - y1;
    l = sqrt(dx * dx + dy * dy);
    t = (dx1 * dx + dy1 * dy) / l;
    if (t < 0.0)
        d = sqrt(dx1 * dx1 + dy1 * dy1);
    else if (t > l)
        d = sqrt(sqr(x - x2) + sqr(y - y2));
    else
        d = fabs(dx1 * dy - dy1 * dx) / l;

    return (d);
}

Here is the call graph for this function:

int ipos_dot ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 128 of file ipos.c.

References ipos::x, and ipos::y.

{
    return (pos1.x * pos2.x + pos1.y * pos2.y);
}
Bool ipos_equal ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 37 of file ipos.c.

References ipos_x, and ipos_y.

Referenced by tv_fillpixel2(), tv_pixel2(), and wx_add_str2().

{
    return ((Bool) ((ipos_x(pos1) == ipos_x(pos2)) &&
                    (ipos_y(pos1) == ipos_y(pos2))));
}

Here is the caller graph for this function:

Ipos ipos_ex ( void  )

Definition at line 58 of file ipos.c.

References ipos().

{
    return (ipos(1, 0));
}

Here is the call graph for this function:

Ipos ipos_ey ( void  )

Definition at line 63 of file ipos.c.

References ipos().

{
    return (ipos(0, 1));
}

Here is the call graph for this function:

void ipos_free ( void *  pos)

Definition at line 32 of file ipos.c.

References rfree().

{
    rfree((void *) pos);
}

Here is the call graph for this function:

Ipos* ipos_make ( int  x,
int  y 
)

Definition at line 23 of file ipos.c.

References ts_ralloc, ipos::x, and ipos::y.

{
    Ipos   *pos = ts_ralloc(Ipos);

    pos->x = x;
    pos->y = y;
    return (pos);
}
int ipos_manhattan ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 160 of file ipos.c.

References ipos::x, and ipos::y.

Referenced by tv_zbuff_patch().

{
    return (abs(pos1.x - pos2.x) + abs(pos1.y - pos2.y));
}

Here is the caller graph for this function:

int ipos_maxabs ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 165 of file ipos.c.

References MAX, ipos::x, and ipos::y.

Referenced by tv_zbuff_patch(), and tv_zbuff_seg3().

{
    int     dx = abs(pos1.x - pos2.x);
    int     dy = abs(pos1.y - pos2.y);

    return (MAX(dx, dy));
}

Here is the caller graph for this function:

Ipos ipos_midpoint ( Ipos  p1,
Ipos  p2 
)

Definition at line 207 of file ipos.c.

References ipos(), ipos::x, and ipos::y.

Referenced by tv_zbuff_patch().

{
    return (ipos((p1.x + p2.x) / 2, (p1.y + p2.y) / 2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Ipos ipos_minus ( Ipos  pos)

Definition at line 101 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

{
    Ipos    minus = {Ipos_id};

    minus.x = -pos.x;
    minus.y = -pos.y;
    return (minus);
}
double ipos_mod ( Ipos  pos)

Definition at line 138 of file ipos.c.

References sqrt(), ipos::x, and ipos::y.

Referenced by curve_section_draw(), pick_conic2_dist(), and pick_conic3_dist().

{
    double  vx = pos.x, vy = pos.y;

    return (sqrt(vx * vx + vy * vy));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ipos_pprint ( FILE fp,
char *  msg,
Ipos  pos 
)

Definition at line 225 of file ipos.c.

References ipos::x, and ipos::y.

{
    (void) fprintf(fp, "%s(%15d%15d)\n", msg, pos.x, pos.y);
}
void ipos_print ( FILE fp,
Ipos  pos 
)

Definition at line 220 of file ipos.c.

References ipos::x, and ipos::y.

{
    (void) fprintf(fp, "%d %d ", pos.x, pos.y);
}
Ipos ipos_read ( FILE fp)

Definition at line 212 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

{
    Ipos    pos = {Ipos_id};

    (void) fscanf(fp, "%d %d", &pos.x, &pos.y);
    return (pos);
}
double ipos_sqrdist ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 173 of file ipos.c.

References ipos::x, and ipos::y.

{
    double  dx = pos1.x - pos2.x;
    double  dy = pos1.y - pos2.y;

    return (dx * dx + dy * dy);
}
double ipos_sqrmod ( Ipos  pos)

Definition at line 145 of file ipos.c.

References ipos::x, and ipos::y.

{
    double  vx = pos.x, vy = pos.y;

    return (vx * vx + vy * vy);
}
Ipos ipos_sum ( Ipos  pos1,
Ipos  pos2 
)

Definition at line 74 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

Referenced by tv_vector().

{
    Ipos    sum = {Ipos_id};

    sum.x = pos1.x + pos2.x;
    sum.y = pos1.y + pos2.y;
    return (sum);
}

Here is the caller graph for this function:

Ipos ipos_sum3 ( Ipos  pos0,
Ipos  pos1,
Ipos  pos2 
)

Definition at line 83 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

{
    Ipos    sum = {Ipos_id};

    sum.x = pos0.x + pos1.x + pos2.x;
    sum.y = pos0.y + pos1.y + pos2.y;
    return (sum);
}
Ipos ipos_sum4 ( Ipos  pos0,
Ipos  pos1,
Ipos  pos2,
Ipos  pos3 
)

Definition at line 92 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

{
    Ipos    sum = {Ipos_id};

    sum.x = pos0.x + pos1.x + pos2.x + pos3.x;
    sum.y = pos0.y + pos1.y + pos2.y + pos3.y;
    return (sum);
}
Ipos ipos_times ( double  k,
Ipos  pos 
)

Definition at line 119 of file ipos.c.

References Ipos_id, ipos::x, and ipos::y.

{
    Ipos    prod = {Ipos_id};

    prod.x = (int) k * pos.x;
    prod.y = (int) k * pos.y;
    return (prod);
}
Ipos ipos_zero ( void  )

Definition at line 53 of file ipos.c.

References ipos().

Referenced by patch_make().

{
    return (ipos(0, 0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat2 mat2 ( double  mxx,
double  mxy,
double  myx,
double  myy 
)

Definition at line 38 of file mat2.c.

References mat2::el, and Mat2_id.

Referenced by hough2_plot_points(), im_hess_mat2(), mat2_inverse(), mat2_sym(), mat2_unit(), rot2(), and rot2_with_scale().

{
    Mat2    m = {Mat2_id};

    m.el[0][0] = mxx;
    m.el[0][1] = mxy;
    m.el[1][0] = myx;
    m.el[1][1] = myy;
    return (m);
}

Here is the caller graph for this function:

void* mat2_alloc ( void  )

Definition at line 14 of file mat2.c.

References mat2::el, and ts_ralloc.

Referenced by hough2_locate_peaks().

{
    Mat2   *m = ts_ralloc(Mat2);

    m->el[0][0] = 0.0;
    m->el[0][1] = 0.0;
    m->el[1][0] = 0.0;
    m->el[1][1] = 0.0;
    return ((void *) m);
}

Here is the caller graph for this function:

Vec2 mat2_colx ( Mat2  m)

Definition at line 78 of file mat2.c.

References mat2::el, and vec2().

{
    return (vec2(m.el[0][0], m.el[1][0]));
}

Here is the call graph for this function:

Vec2 mat2_coly ( Mat2  m)

Definition at line 83 of file mat2.c.

References mat2::el, and vec2().

{
    return (vec2(m.el[0][1], m.el[1][1]));
}

Here is the call graph for this function:

void mat2_comps ( Mat2  m,
float *  mxx,
float *  mxy,
float *  myx,
float *  myy 
)

Definition at line 60 of file mat2.c.

References mat2::el.

Referenced by mat2_inverse().

{
    *mxx = m.el[0][0];
    *mxy = m.el[0][1];
    *myx = m.el[1][0];
    *myy = m.el[1][1];
}

Here is the caller graph for this function:

double mat2_det ( Mat2  m)

Definition at line 212 of file mat2.c.

References mat2_xx, mat2_xy, mat2_yx, and mat2_yy.

Referenced by mat2_posdef(), and pmat2_det().

{
    return (mat2_xx(m) * mat2_yy(m) - mat2_xy(m) * mat2_yx(m));
}

Here is the caller graph for this function:

Mat2 mat2_diff ( Mat2  m,
Mat2  n 
)

Definition at line 121 of file mat2.c.

References mat2::el, and Mat2_id.

{
    Mat2    diff = {Mat2_id};
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            diff.el[i][j] = m.el[i][j] - n.el[i][j];
    return (diff);
}
void mat2_format ( Mat2  m)

Definition at line 295 of file mat2.c.

References mat2::el, and format().

Referenced by trans2_format().

{
    int     i;

    for (i = 0; i < 2; ++i)
        format("%f %f \n", m.el[i][0], m.el[i][1]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mat2_free ( void *  m)

Definition at line 33 of file mat2.c.

References rfree().

Referenced by hough2_locate_peaks().

{
    rfree((void *) m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat2 mat2_inverse ( Mat2  m)

Definition at line 171 of file mat2.c.

References mat2(), mat2_comps(), and mat2_unit().

Referenced by pmat2_inverse().

{
    double  det, k;
    float   mxx, mxy, myx, myy;

    mat2_comps(m, &mxx, &mxy, &myx, &myy);
    det = mxx * myy - mxy * myx;
    if (det == 0.0)
        return (mat2_unit());
    k = 1.0 / det;
    return (mat2(k * myy, -k * mxy,
                 -k * myx, k * mxx));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* mat2_make ( Mat2  n)

Definition at line 25 of file mat2.c.

References ts_ralloc.

Referenced by pmat2_inverse(), pmat2_of_cols(), and pmat2_of_rows().

{
    Mat2   *m = ts_ralloc(Mat2);

    *m = n;
    return ((void *) m);
}

Here is the caller graph for this function:

Mat2 mat2_minus ( Mat2  m)

Definition at line 132 of file mat2.c.

References mat2::el, and Mat2_id.

{
    Mat2    minus = {Mat2_id};
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            minus.el[i][j] = -m.el[i][j];
    return (minus);
}
Mat2 mat2_of_cols ( Vec2  cx,
Vec2  cy 
)

Definition at line 99 of file mat2.c.

References vec2::el, mat2::el, and Mat2_id.

Referenced by pmat2_of_cols().

{
    Mat2    m = {Mat2_id};

    m.el[0][0] = cx.el[0];
    m.el[0][1] = cx.el[1];
    m.el[1][0] = cy.el[0];
    m.el[1][1] = cy.el[1];
    return (m);
}

Here is the caller graph for this function:

Mat2 mat2_of_rows ( Vec2  rx,
Vec2  ry 
)

Definition at line 88 of file mat2.c.

References vec2::el, mat2::el, and Mat2_id.

Referenced by pmat2_of_rows().

{
    Mat2    m = {Mat2_id};

    m.el[0][0] = rx.el[0];
    m.el[1][0] = rx.el[1];
    m.el[0][1] = ry.el[0];
    m.el[1][1] = ry.el[1];
    return (m);
}

Here is the caller graph for this function:

Bool mat2_posdef ( Mat2  m)

Definition at line 217 of file mat2.c.

References mat2_det(), and mat2_xx.

{
    if (mat2_xx(m) <= 0.0)
        return (false);
    else if (mat2_det(m) <= 0.0)
        return (false);
    else
        return (true);
}

Here is the call graph for this function:

void mat2_pprint ( FILE fp,
char *  msg,
Mat2  m 
)

Definition at line 283 of file mat2.c.

References mat2::el.

{
    int     i, n;

    n = strlen(msg);
    (void) fprintf(fp, "%s", msg);
    (void) fprintf(fp, "|%15.6f%15.6f|\n", m.el[0][0], m.el[0][1]);
    for (i = 0; i < n; ++i)
        (void) fputc(' ', stderr);
    (void) fprintf(fp, "|%15.6f%15.6f|\n", m.el[1][0], m.el[1][1]);
}
void mat2_print ( FILE fp,
Mat2  m 
)

Definition at line 275 of file mat2.c.

References mat2::el.

Referenced by trans2_print().

{
    int     i;

    for (i = 0; i < 2; ++i)
        (void) fprintf(fp, "%f %f\n", m.el[i][0], m.el[i][1]);
}

Here is the caller graph for this function:

Mat2 mat2_prod ( Mat2  m,
Mat2  n 
)

Definition at line 154 of file mat2.c.

References mat2::el, and Mat2_id.

Referenced by hough2_plot_points(), scale_from_loc(), and trans2_prod().

{
    Mat2    prod = {Mat2_id};
    int     i, j, k;
    double  sum;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
        {
            sum = 0.0;
            for (k = 0; k < 2; ++k)
                sum += m.el[i][k] * n.el[k][j];
            prod.el[i][j] = sum;
        }
    return (prod);
}

Here is the caller graph for this function:

Mat2 mat2_read ( FILE fp)

Definition at line 265 of file mat2.c.

References mat2::el, Mat2_id, and temp.

{
    Mat2    temp = {Mat2_id};
    int     i;

    for (i = 0; i < 2; ++i)
        (void) fscanf(fp, "%f %f", &temp.el[i][0], &temp.el[i][1]);
    return (temp);
}
Vec2 mat2_rowx ( Mat2  m)

Definition at line 68 of file mat2.c.

References mat2::el, and vec2().

{
    return (vec2(m.el[0][0], m.el[0][1]));
}

Here is the call graph for this function:

Vec2 mat2_rowy ( Mat2  m)

Definition at line 73 of file mat2.c.

References mat2::el, and vec2().

{
    return (vec2(m.el[1][0], m.el[1][1]));
}

Here is the call graph for this function:

double mat2_sprod ( Vec2  v,
Mat2  m,
Vec2  w 
)

Definition at line 243 of file mat2.c.

References vec2::el, and mat2::el.

{
    double  sum = 0.0;
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            sum += v.el[i] * m.el[i][j] * w.el[j];
    return (sum);
}
Mat2 mat2_sum ( Mat2  m,
Mat2  n 
)

Definition at line 110 of file mat2.c.

References mat2::el, and Mat2_id.

Referenced by hough2_plot_points(), and str2_eigen().

{
    Mat2    sum = {Mat2_id};
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            sum.el[i][j] = m.el[i][j] + n.el[i][j];
    return (sum);
}

Here is the caller graph for this function:

Mat2 mat2_sym ( Mat2  m)

Definition at line 196 of file mat2.c.

References mat2(), mat2_xx, mat2_xy, mat2_yx, and mat2_yy.

{
    double  mxx = mat2_xx(m);
    double  mxy = mat2_xy(m);
    double  myx = mat2_yx(m);
    double  myy = mat2_yy(m);

    mxy = 0.5 * (mxy + myx);
    return (mat2(mxx, mxy, mxy, myy));
}

Here is the call graph for this function:

void mat2_sym_eigen ( Mat2  m,
double *  theta,
double *  lambda1,
double *  lambda2 
)

eigendirection and eigenvalues of symmetric 2by2 matrix |a b| |b c|

Definition at line 309 of file mat2.c.

References a, c, mat2_xx, mat2_xy, mat2_yx, mat2_yy, p, and sqrt().

Referenced by str2_eigen().

{
    double  a, b, c, p, q, r;

    a = mat2_xx(m);
    b = 0.5 * (mat2_xy(m) + mat2_yx(m));
    c = mat2_yy(m);
    p = (a + c) / 2.0;
    q = (a - c) / 2.0;
    r = sqrt(q * q + b * b);
    if (b == 0.0 && q == 0.0)
        *theta = 0.0;
    else
        *theta = 0.5 * atan2(b, q);
    *lambda1 = p + r;
    *lambda2 = p - r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat2 mat2_tensor ( Vec2  v,
Vec2  w 
)

Definition at line 254 of file mat2.c.

References vec2::el, mat2::el, and Mat2_id.

Referenced by str2_eigen().

{
    Mat2    prod = {Mat2_id};
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            prod.el[i][j] = v.el[i] * w.el[j];
    return (prod);
}

Here is the caller graph for this function:

Mat2 mat2_times ( double  k,
Mat2  m 
)

Definition at line 143 of file mat2.c.

References mat2::el, and Mat2_id.

{
    Mat2    prod = {Mat2_id};
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            prod.el[i][j] = k * m.el[i][j];
    return (prod);
}
double mat2_trace ( Mat2  m)

Definition at line 207 of file mat2.c.

References mat2::el.

{
    return (m.el[0][0] + m.el[1][1]);
}
Mat2 mat2_transpose ( Mat2  m)

Definition at line 185 of file mat2.c.

References mat2::el, and Mat2_id.

Referenced by hough2_plot_points(), scale_from_loc(), and trans2_inverse().

{
    Mat2    trans = {Mat2_id};
    int     i, j;

    for (i = 0; i < 2; ++i)
        for (j = 0; j < 2; ++j)
            trans.el[i][j] = m.el[j][i];
    return (trans);
}

Here is the caller graph for this function:

Mat2 mat2_unit ( void  )

Definition at line 49 of file mat2.c.

References mat2().

Referenced by mat2_inverse(), and trans2_alloc().

{
    return (mat2(1.0, 0.0,
                 0.0, 1.0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec2 mat2_vprod ( Mat2  m,
Vec2  v 
)

Definition at line 227 of file mat2.c.

References vec2::el, mat2::el, and Vec2_id.

Referenced by i_position(), im_rotate(), line_to_model(), locate_using_long_lines(), locate_using_points(), locate_using_short_lines(), mirror_matched_model(), notv_snake_zoom_drag(), origin1_from_match(), origin2_from_match(), pmat2_vprod(), poly_rotate(), poly_rotate_and_scale(), position(), rts_get(), snake_hessian_forces(), snake_rot_step(), snake_zoom_drag(), spline2_rts(), str2_align(), str2_rts(), trans2_inverse(), trans2_pos(), trans2_prod(), trans2_rot_about(), trans2_vec(), tv_rot(), and tv_rot2().

{
    Vec2    prod = {Vec2_id};
    int     i, j;
    double  sum;

    for (i = 0; i < 2; ++i)
    {
        sum = 0.0;
        for (j = 0; j < 2; ++j)
            sum += m.el[i][j] * v.el[j];
        prod.el[i] = sum;
    }
    return (prod);
}

Here is the caller graph for this function:

Mat2 mat2_zero ( void  )

Definition at line 55 of file mat2.c.

Referenced by str2_eigen().

{
    return (mat2_0);
}

Here is the caller graph for this function:

Mat3 mat3 ( double  mxx,
double  mxy,
double  mxz,
double  myx,
double  myy,
double  myz,
double  mzx,
double  mzy,
double  mzz 
)

Definition at line 90 of file mat3.c.

References mat3::el, and Mat3_id.

Referenced by cam_cal_tsai(), cam_comp_default_rects(), conic_make(), conic_proj(), conic_rectify(), mat3_diag(), mat3_unit(), parcam_make(), parcam_scaled_make(), rot3(), rot3_1(), store_camera_ext(), and store_camera_rel().

{
    Mat3    m = {Mat3_id};

    m.el[0][0] = mxx;
    m.el[0][1] = mxy;
    m.el[0][2] = mxz;
    m.el[1][0] = myx;
    m.el[1][1] = myy;
    m.el[1][2] = myz;
    m.el[2][0] = mzx;
    m.el[2][1] = mzy;
    m.el[2][2] = mzz;
    return (m);
}

Here is the caller graph for this function:

Mat3* mat3_alloc ( void  )

Definition at line 14 of file mat3.c.

References mat3::el, and ts_ralloc.

Referenced by store_rot_init().

{
    Mat3   *m = ts_ralloc(Mat3);

    m->el[0][0] = 0.0;
    m->el[0][1] = 0.0;
    m->el[0][2] = 0.0;
    m->el[1][0] = 0.0;
    m->el[1][1] = 0.0;
    m->el[1][2] = 0.0;
    m->el[2][0] = 0.0;
    m->el[2][1] = 0.0;
    m->el[2][2] = 0.0;
    return (m);
}

Here is the caller graph for this function:

Vec3 mat3_colx ( Mat3  m)

Definition at line 153 of file mat3.c.

References mat3::el, and vec3().

Referenced by trans3_get_frame1in2().

{
    return (vec3(m.el[0][0], m.el[1][0], m.el[2][0]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 mat3_coly ( Mat3  m)

Definition at line 158 of file mat3.c.

References mat3::el, and vec3().

Referenced by trans3_get_frame1in2().

{
    return (vec3(m.el[0][1], m.el[1][1], m.el[2][1]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 mat3_colz ( Mat3  m)

Definition at line 163 of file mat3.c.

References mat3::el, and vec3().

Referenced by trans3_get_frame1in2().

{
    return (vec3(m.el[0][2], m.el[1][2], m.el[2][2]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mat3_comps ( Mat3  m,
float *  mxx,
float *  mxy,
float *  mxz,
float *  myx,
float *  myy,
float *  myz,
float *  mzx,
float *  mzy,
float *  mzz 
)

Definition at line 125 of file mat3.c.

References mat3::el.

Referenced by mat3_det().

{
    *mxx = m.el[0][0];
    *mxy = m.el[0][1];
    *mxz = m.el[0][2];
    *myx = m.el[1][0];
    *myy = m.el[1][1];
    *myz = m.el[1][2];
    *mzx = m.el[2][0];
    *mzy = m.el[2][1];
    *mzz = m.el[2][2];
}

Here is the caller graph for this function:

double mat3_det ( Mat3  m)

Definition at line 352 of file mat3.c.

References mat3_comps().

Referenced by mat3_posdef().

{
    float   mxx, mxy, mxz, myx, myy, myz, mzx, mzy, mzz;

    mat3_comps(m, &mxx, &mxy, &mxz, &myx, &myy, &myz, &mzx, &mzy, &mzz);
    return (mxx * myy * mzz + mxy * myz * mzx + mxz * myx * mzy
            - mxx * myz * mzy - mxy * myx * mzz - mxz * myy * mzx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat3 mat3_diag ( double  mxx,
double  myy,
double  mzz 
)

Definition at line 118 of file mat3.c.

References mat3().

{
    return (mat3(mxx, 0.0, 0.0,
                 0.0, myy, 0.0,
                 0.0, 0.0, mzz));
}

Here is the call graph for this function:

Mat3 mat3_diff ( Mat3  m,
Mat3  n 
)

Definition at line 222 of file mat3.c.

References mat3::el, and Mat3_id.

{
    Mat3    diff = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            diff.el[i][j] = m.el[i][j] - n.el[i][j];
    return (diff);
}
void mat3_eigen ( Mat3  m,
double *  eval,
Vec3 evec 
)

copy mat3 into matrix

get vector of eigenvals and matrix of column eigenvecs

copy into eval and evec

Definition at line 601 of file mat3.c.

References a, double_v, mat3::el, matrix_alloc(), matrix_eigen_sym(), matrix_free(), matrix_full, matrix_getf(), matrix_putf(), v, vector_alloc(), vector_free(), and vector_getf().

{
    int     i, j;
    Matrix *a = matrix_alloc(3, 3, matrix_full, double_v);
    Matrix *b = matrix_alloc(3, 3, matrix_full, double_v);
    Vector *v = vector_alloc(3, double_v);

    /** copy mat3 into matrix **/
    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
            matrix_putf(m.el[i][j], a, i, j);

    /** get vector of eigenvals and matrix of column eigenvecs **/
    (void) matrix_eigen_sym(a, v, b);

    /** copy into eval and evec **/
    for (i = 0; i < 3; i++)
        eval[i] = vector_getf(v, i);
    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
            evec[i].el[j] = matrix_getf(b, j, i);
    matrix_free(a);
    matrix_free(b);
    vector_free(v);
}

Here is the call graph for this function:

void mat3_format ( Mat3  m)

Definition at line 475 of file mat3.c.

References mat3::el, and format().

Referenced by trans3_format().

{
    int     i;

    for (i = 0; i < 3; ++i)
        format("%f %f %f\n", m.el[i][0], m.el[i][1], m.el[i][2]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mat3_free ( Mat3 m)

Definition at line 38 of file mat3.c.

References rfree().

Referenced by store_rot_reset().

{
    rfree((void *) m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double mat3_get_xx ( Mat3  m)

function versions of component macros

Definition at line 45 of file mat3.c.

References mat3_xx.

{
    return (mat3_xx(m));
}
double mat3_get_xy ( Mat3  m)

Definition at line 50 of file mat3.c.

References mat3_xy.

{
    return (mat3_xy(m));
}
double mat3_get_xz ( Mat3  m)

Definition at line 55 of file mat3.c.

References mat3_xz.

{
    return (mat3_xz(m));
}
double mat3_get_yx ( Mat3  m)

Definition at line 60 of file mat3.c.

References mat3_yx.

{
    return (mat3_yx(m));
}
double mat3_get_yy ( Mat3  m)

Definition at line 65 of file mat3.c.

References mat3_yy.

{
    return (mat3_yy(m));
}
double mat3_get_yz ( Mat3  m)

Definition at line 70 of file mat3.c.

References mat3_yz.

{
    return (mat3_yz(m));
}
double mat3_get_zx ( Mat3  m)

Definition at line 75 of file mat3.c.

References mat3_zx.

{
    return (mat3_zx(m));
}
double mat3_get_zy ( Mat3  m)

Definition at line 80 of file mat3.c.

References mat3_zy.

{
    return (mat3_zy(m));
}
double mat3_get_zz ( Mat3  m)

Definition at line 85 of file mat3.c.

References mat3_zz.

{
    return (mat3_zz(m));
}
Mat3 mat3_inverse ( Mat3  m)

Definition at line 272 of file mat3.c.

References a, mat3::el, Mat3_id, mat3_unit(), and p.

Referenced by conic_make(), conic_proj(), conic_rectify(), im_rectify(), parcam_make(), parcam_scaled_make(), proj2_between(), proj2_between_proj2(), quadric_make(), solve(), and store_rot_init().

{
    Mat3    inv = {Mat3_id};
    double  a[3][3];
    int     i, j, k, p[3];
    double  h, q, s, sup, pivot;

    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
            a[i][j] = m.el[i][j];

    for (k = 0; k < 3; k++)
    {
        sup = 0.0;
        p[k] = 0;
        for (i = k; i < 3; i++)
        {
            s = 0.0;
            for (j = k; j < 3; j++)
                s += fabs(a[i][j]);
            q = fabs(a[i][k]) / s;
            if (sup < q)
            {
                sup = q;
                p[k] = i;
            }
        }
        if (sup == 0.0)
            return (mat3_unit());
        if (p[k] != k)
            for (j = 0; j < 3; j++)
            {
                h = a[k][j];
                a[k][j] = a[p[k]][j];
                a[p[k]][j] = h;
            }
        pivot = a[k][k];
        for (j = 0; j < 3; j++)
            if (j != k)
            {
                a[k][j] = -a[k][j] / pivot;
                for (i = 0; i < 3; i++)
                    if (i != k)
                        a[i][j] += a[i][k] * a[k][j];
            }
        for (i = 0; i < 3; i++)
            a[i][k] = a[i][k] / pivot;
        a[k][k] = 1.0 / pivot;
    }
    for (k = 3 - 1; k >= 0; k--)
        if (p[k] != k)
            for (i = 0; i < 3; i++)
            {
                h = a[i][k];
                a[i][k] = a[i][p[k]];
                a[i][p[k]] = h;
            }

    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
            inv.el[i][j] = a[i][j];
    return (inv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat3* mat3_make ( Mat3  n)

Definition at line 30 of file mat3.c.

References ts_ralloc.

{
    Mat3   *m = ts_ralloc(Mat3);

    *m = n;
    return (m);
}
Mat3 mat3_minus ( Mat3  m)

Definition at line 233 of file mat3.c.

References mat3::el, and Mat3_id.

{
    Mat3    minus = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            minus.el[i][j] = -m.el[i][j];
    return (minus);
}
Mat3 mat3_of_cols ( Vec3  cx,
Vec3  cy,
Vec3  cz 
)

Definition at line 168 of file mat3.c.

References vec3::el, mat3::el, and Mat3_id.

Referenced by proj2_to_frame(), and trans3_from_frame().

{
    Mat3    m = {Mat3_id};

    m.el[0][0] = cx.el[0];
    m.el[1][0] = cx.el[1];
    m.el[2][0] = cx.el[2];
    m.el[0][1] = cy.el[0];
    m.el[1][1] = cy.el[1];
    m.el[2][1] = cy.el[2];
    m.el[0][2] = cz.el[0];
    m.el[1][2] = cz.el[1];
    m.el[2][2] = cz.el[2];
    return (m);
}

Here is the caller graph for this function:

Mat3 mat3_of_rows ( Vec3  rx,
Vec3  ry,
Vec3  rz 
)

Definition at line 184 of file mat3.c.

References vec3::el, mat3::el, and Mat3_id.

Referenced by rect_image_to_cam().

{
    Mat3    m = {Mat3_id};

    m.el[0][0] = rx.el[0];
    m.el[0][1] = rx.el[1];
    m.el[0][2] = rx.el[2];
    m.el[1][0] = ry.el[0];
    m.el[1][1] = ry.el[1];
    m.el[1][2] = ry.el[2];
    m.el[2][0] = rz.el[0];
    m.el[2][1] = rz.el[1];
    m.el[2][2] = rz.el[2];
    return (m);
}

Here is the caller graph for this function:

Bool mat3_posdef ( Mat3  m)

Definition at line 361 of file mat3.c.

References mat3::el, and mat3_det().

{
    if (m.el[0][0] <= 0.0)
        return (false);
    else if (m.el[0][0] * m.el[1][1] - m.el[0][1] * m.el[1][0] <= 0.0)
        return (false);
    else if (mat3_det(m) <= 0.0)
        return (false);
    else
        return (true);
}

Here is the call graph for this function:

void mat3_pprint ( FILE fp,
char *  msg,
Mat3  m 
)

Definition at line 457 of file mat3.c.

References mat3::el.

{
    int     i, n;

    n = strlen(msg);
    (void) fprintf(fp, "%s", msg);
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f|\n",
                   m.el[0][0], m.el[0][1], m.el[0][2]);
    for (i = 0; i < n; ++i)
        (void) fprintf(fp, " ");
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f|\n",
                   m.el[1][0], m.el[1][1], m.el[1][2]);
    for (i = 0; i < n; ++i)
        (void) fprintf(fp, " ");
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f|\n",
                   m.el[2][0], m.el[2][1], m.el[2][2]);
}
void mat3_print ( FILE fp,
Mat3  m 
)

Definition at line 449 of file mat3.c.

References mat3::el.

Referenced by trans3_print().

{
    int     i;

    for (i = 0; i < 3; ++i)
        (void) fprintf(fp, "%f %f %f\n", m.el[i][0], m.el[i][1], m.el[i][2]);
}

Here is the caller graph for this function:

Mat3 mat3_prod ( Mat3  m,
Mat3  n 
)

Definition at line 255 of file mat3.c.

References mat3::el, and Mat3_id.

Referenced by conic_make(), conic_proj(), conic_rectify(), coreg_get_vec(), coreg_set_vec(), parcam_make(), parcam_scaled_make(), proj2_between(), proj2_between_proj2(), rot3_euler(), trans3_prod(), and triv_camerror().

{
    Mat3    prod = {Mat3_id};
    double  sum;
    int     i, j, k;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
        {
            sum = 0.0;
            for (k = 0; k < 3; ++k)
                sum += m.el[i][k] * n.el[k][j];
            prod.el[i][j] = sum;
        }
    return (prod);
}

Here is the caller graph for this function:

Mat3 mat3_read ( FILE fp)

Definition at line 438 of file mat3.c.

References mat3::el, Mat3_id, and temp.

{
    Mat3    temp = {Mat3_id};
    int     i;

    for (i = 0; i < 3; ++i)
        (void) fscanf(fp, "%f %f %f",
                      &temp.el[i][0], &temp.el[i][1], &temp.el[i][2]);
    return (temp);
}
Vec3 mat3_rowx ( Mat3  m)

Definition at line 138 of file mat3.c.

References mat3::el, and vec3().

Referenced by trans3_get_frame2in1().

{
    return (vec3(m.el[0][0], m.el[0][1], m.el[0][2]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 mat3_rowy ( Mat3  m)

Definition at line 143 of file mat3.c.

References mat3::el, and vec3().

Referenced by trans3_get_frame2in1().

{
    return (vec3(m.el[1][0], m.el[1][1], m.el[1][2]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 mat3_rowz ( Mat3  m)

Definition at line 148 of file mat3.c.

References mat3::el, and vec3().

Referenced by trans3_get_frame2in1().

{
    return (vec3(m.el[2][0], m.el[2][1], m.el[2][2]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

double mat3_sprod ( Vec3  v,
Mat3  m,
Vec3  w 
)

Definition at line 405 of file mat3.c.

References vec3::el, and mat3::el.

{
    double  sum = 0.0;
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            sum += v.el[i] * m.el[i][j] * w.el[j];
    return (sum);
}
Mat3 mat3_sum ( Mat3  m,
Mat3  n 
)

Definition at line 200 of file mat3.c.

References mat3::el, and Mat3_id.

Referenced by mlist_comp_translate_all(), and mlist_comp_translate_vec3().

{
    Mat3    sum = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            sum.el[i][j] = m.el[i][j] + n.el[i][j];
    return (sum);
}

Here is the caller graph for this function:

Mat3 mat3_sum3 ( Mat3  l,
Mat3  m,
Mat3  n 
)

Definition at line 211 of file mat3.c.

References mat3::el, and Mat3_id.

{
    Mat3    sum = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            sum.el[i][j] = l.el[i][j] + m.el[i][j] + n.el[i][j];
    return (sum);
}
Mat3 mat3_sum_tensor ( Mat3  m,
Vec3  v,
Vec3  w 
)

Definition at line 427 of file mat3.c.

References vec3::el, mat3::el, and Mat3_id.

{
    Mat3    sum = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            sum.el[i][j] = m.el[i][j]+v.el[i] * w.el[j];
    return (sum);
}
Mat3 mat3_tensor ( Vec3  v,
Vec3  w 
)

Definition at line 416 of file mat3.c.

References vec3::el, mat3::el, and Mat3_id.

{
    Mat3    prod = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            prod.el[i][j] = v.el[i] * w.el[j];
    return (prod);
}
Mat3 mat3_times ( double  k,
Mat3  m 
)

Definition at line 244 of file mat3.c.

References mat3::el, and Mat3_id.

Referenced by tv_zbuff_sphere().

{
    Mat3    prod = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            prod.el[i][j] = k * m.el[i][j];
    return (prod);
}

Here is the caller graph for this function:

double mat3_trace ( Mat3  m)

Definition at line 347 of file mat3.c.

References mat3::el.

Referenced by rot3_angle_axis().

{
    return (m.el[0][0] + m.el[1][1] + m.el[2][2]);
}

Here is the caller graph for this function:

Mat3 mat3_transpose ( Mat3  m)

Definition at line 336 of file mat3.c.

References mat3::el, and Mat3_id.

Referenced by conic_make(), conic_proj(), conic_rectify(), parcam_make(), parcam_scaled_make(), quadric_make(), and trans3_inverse().

{
    Mat3    trans = {Mat3_id};
    int     i, j;

    for (i = 0; i < 3; ++i)
        for (j = 0; j < 3; ++j)
            trans.el[i][j] = m.el[j][i];
    return (trans);
}

Here is the caller graph for this function:

Vec3 mat3_transpose_vprod ( Mat3  m,
Vec3  v 
)

Definition at line 389 of file mat3.c.

References vec3::el, mat3::el, and Vec3_id.

Referenced by trans3_get_frame2in1(), trans3_get_origin2in1(), trans3_inverse_pos(), trans3_inverse_vec(), and triv_camerror().

{
    Vec3    prod = {Vec3_id};
    double  sum;
    int     i, j;

    for (i = 0; i < 3; ++i)
    {
        sum = 0.0;
        for (j = 0; j < 3; ++j)
            sum += m.el[j][i] * v.el[j];
        prod.el[i] = sum;
    }
    return (prod);
}

Here is the caller graph for this function:

Mat3 mat3_unit ( void  )

Definition at line 106 of file mat3.c.

References mat3().

Referenced by mat3_inverse(), match_pair_transform_vec3(), mlist_best_transform_vec3(), mlist_transform_vec3(), parcam_alloc(), rot3(), rot3_1(), rot3_quat(), rot_compute(), trans3_alloc(), trans3_unit(), and tv_zbuff_sphere().

{
    return (mat3(1.0, 0.0, 0.0,
                 0.0, 1.0, 0.0,
                 0.0, 0.0, 1.0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 mat3_vprod ( Mat3  m,
Vec3  v 
)

Definition at line 373 of file mat3.c.

References vec3::el, mat3::el, and Vec3_id.

Referenced by line3_transf(), mlist_comp_transform_pos3(), mlist_comp_translate_all(), mlist_comp_translate_pos3(), mlist_comp_translate_vec3(), proj2_rectify(), quadric_normal(), quadric_point(), rectify_pos(), solve(), trans3_inverse(), trans3_pos(), trans3_prod(), trans3_rot_about(), trans3_vec(), triv_camerror(), tv_rot(), tv_rot3(), tv_twist(), and vec2_rectify().

{
    Vec3    prod = {Vec3_id};
    double  sum;
    int     i, j;

    for (i = 0; i < 3; ++i)
    {
        sum = 0.0;
        for (j = 0; j < 3; ++j)
            sum += m.el[i][j] * v.el[j];
        prod.el[i] = sum;
    }
    return (prod);
}

Here is the caller graph for this function:

Mat3 mat3_zero ( void  )

Definition at line 113 of file mat3.c.

Referenced by mlist_comp_translate_all(), mlist_comp_translate_vec3(), proj_x1(), proj_y1(), and proj_z1().

{
    return (mat3_0);
}

Here is the caller graph for this function:

Mat4 mat4 ( double  mxx,
double  mxy,
double  mxz,
double  mxw,
double  myx,
double  myy,
double  myz,
double  myw,
double  mzx,
double  mzy,
double  mzz,
double  mzw,
double  mwx,
double  mwy,
double  mwz,
double  mww 
)

Definition at line 132 of file mat4.c.

References mat4::el, and Mat4_id.

Referenced by mat4_unit().

{
    Mat4    m = {Mat4_id};

    m.el[0][0] = mxx;
    m.el[0][1] = mxy;
    m.el[0][2] = mxz;
    m.el[0][3] = mxw;
    m.el[1][0] = myx;
    m.el[1][1] = myy;
    m.el[1][2] = myz;
    m.el[1][3] = myw;
    m.el[2][0] = mzx;
    m.el[2][1] = mzy;
    m.el[2][2] = mzz;
    m.el[2][3] = mzw;
    m.el[3][0] = mwx;
    m.el[3][1] = mwy;
    m.el[3][2] = mwz;
    m.el[3][3] = mww;
    return (m);
}

Here is the caller graph for this function:

Mat4* mat4_alloc ( void  )

Definition at line 14 of file mat4.c.

References mat4::el, and ts_ralloc.

{
    Mat4   *m = ts_ralloc(Mat4);

    m->el[0][0] = 0.0;
    m->el[0][1] = 0.0;
    m->el[0][2] = 0.0;
    m->el[0][3] = 0.0;
    m->el[1][0] = 0.0;
    m->el[1][1] = 0.0;
    m->el[1][2] = 0.0;
    m->el[1][3] = 0.0;
    m->el[2][0] = 0.0;
    m->el[2][1] = 0.0;
    m->el[2][2] = 0.0;
    m->el[2][3] = 0.0;
    m->el[3][0] = 0.0;
    m->el[3][1] = 0.0;
    m->el[3][2] = 0.0;
    m->el[3][3] = 0.0;
    return (m);
}
Vec4 mat4_colw ( Mat4  m)

Definition at line 223 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[0][3], m.el[1][3], m.el[2][3], m.el[3][3]));
}

Here is the call graph for this function:

Vec4 mat4_colx ( Mat4  m)

Definition at line 208 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[0][0], m.el[1][0], m.el[2][0], m.el[3][0]));
}

Here is the call graph for this function:

Vec4 mat4_coly ( Mat4  m)

Definition at line 213 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[0][1], m.el[1][1], m.el[2][1], m.el[3][1]));
}

Here is the call graph for this function:

Vec4 mat4_colz ( Mat4  m)

Definition at line 218 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[0][2], m.el[1][2], m.el[2][2], m.el[3][2]));
}

Here is the call graph for this function:

void mat4_comps ( Mat4  m,
double *  mxx,
double *  mxy,
double *  mxz,
double *  mxw,
double *  myx,
double *  myy,
double *  myz,
double *  myw,
double *  mzx,
double *  mzy,
double *  mzz,
double *  mzw,
double *  mwx,
double *  mwy,
double *  mwz,
double *  mww 
)

Definition at line 168 of file mat4.c.

References mat4::el.

{
    *mxx = m.el[0][0];
    *mxy = m.el[0][1];
    *mxz = m.el[0][2];
    *mxw = m.el[0][3];
    *myx = m.el[1][0];
    *myy = m.el[1][1];
    *myz = m.el[1][2];
    *myw = m.el[1][3];
    *mzx = m.el[2][0];
    *mzy = m.el[2][1];
    *mzz = m.el[2][2];
    *mzw = m.el[2][3];
    *mwx = m.el[3][0];
    *mwy = m.el[3][1];
    *mwz = m.el[3][2];
    *mww = m.el[3][3];
}
Mat4 mat4_diff ( Mat4  m,
Mat4  n 
)

Definition at line 285 of file mat4.c.

References mat4::el, and Mat4_id.

{
    Mat4    diff = {Mat4_id};
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            diff.el[i][j] = m.el[i][j] - n.el[i][j];
    return (diff);
}
void mat4_eigen ( Mat4  m,
double *  eval,
Vec4 evec 
)

copy mat4 into matrix

get vector of eigenvals and matrix of column eigenvecs

copy into eval and evec

Definition at line 518 of file mat4.c.

References a, double_v, mat4::el, matrix_alloc(), matrix_eigen_sym(), matrix_free(), matrix_full, matrix_getf(), matrix_putf(), v, vector_alloc(), vector_free(), and vector_getf().

{
    int     i, j;
    Matrix *a = matrix_alloc(4, 4, matrix_full, double_v);
    Matrix *b = matrix_alloc(4, 4, matrix_full, double_v);
    Vector *v = vector_alloc(4, double_v);

    /** copy mat4 into matrix **/
    for (i = 0; i < 4; i++)
        for (j = 0; j < 4; j++)
            matrix_putf(m.el[i][j], a, i, j);

    /** get vector of eigenvals and matrix of column eigenvecs **/
    (void) matrix_eigen_sym(a, v, b);

    /** copy into eval and evec **/
    for (i = 0; i < 4; i++)
        eval[i] = vector_getf(v, i);
    for (i = 0; i < 4; i++)
        for (j = 0; j < 4; j++)
            evec[i].el[j] = matrix_getf(b, j, i);
    matrix_free(a);
    matrix_free(b);
    vector_free(v);
}

Here is the call graph for this function:

void mat4_format ( Mat4  m)

Definition at line 510 of file mat4.c.

References mat4::el, and format().

{
    int     i;

    for (i = 0; i < 4; ++i)
        format("%f %f %f %f\n", m.el[i][0], m.el[i][1], m.el[i][2], m.el[i][3]);
}

Here is the call graph for this function:

void mat4_free ( Mat4 m)

Definition at line 45 of file mat4.c.

References rfree().

{
    rfree((void *) m);
}

Here is the call graph for this function:

double mat4_get_ww ( Mat4  m)

Definition at line 127 of file mat4.c.

References mat4_ww.

{
    return (mat4_ww(m));
}
double mat4_get_wx ( Mat4  m)

Definition at line 112 of file mat4.c.

References mat4_wx.

{
    return (mat4_wx(m));
}
double mat4_get_wy ( Mat4  m)

Definition at line 117 of file mat4.c.

References mat4_wy.

{
    return (mat4_wy(m));
}
double mat4_get_wz ( Mat4  m)

Definition at line 122 of file mat4.c.

References mat4_wz.

{
    return (mat4_wz(m));
}
double mat4_get_xw ( Mat4  m)

Definition at line 67 of file mat4.c.

References mat4_xw.

{
    return (mat4_xw(m));
}
double mat4_get_xx ( Mat4  m)

function versions of component macros

Definition at line 52 of file mat4.c.

References mat4_xx.

{
    return (mat4_xx(m));
}
double mat4_get_xy ( Mat4  m)

Definition at line 57 of file mat4.c.

References mat4_xy.

{
    return (mat4_xy(m));
}
double mat4_get_xz ( Mat4  m)

Definition at line 62 of file mat4.c.

References mat4_xz.

{
    return (mat4_xz(m));
}
double mat4_get_yw ( Mat4  m)

Definition at line 87 of file mat4.c.

References mat4_yw.

{
    return (mat4_yw(m));
}
double mat4_get_yx ( Mat4  m)

Definition at line 72 of file mat4.c.

References mat4_yx.

{
    return (mat4_yx(m));
}
double mat4_get_yy ( Mat4  m)

Definition at line 77 of file mat4.c.

References mat4_yy.

{
    return (mat4_yy(m));
}
double mat4_get_yz ( Mat4  m)

Definition at line 82 of file mat4.c.

References mat4_yz.

{
    return (mat4_yz(m));
}
double mat4_get_zw ( Mat4  m)

Definition at line 107 of file mat4.c.

References mat4_zw.

{
    return (mat4_zw(m));
}
double mat4_get_zx ( Mat4  m)

Definition at line 92 of file mat4.c.

References mat4_zx.

{
    return (mat4_zx(m));
}
double mat4_get_zy ( Mat4  m)

Definition at line 97 of file mat4.c.

References mat4_zy.

{
    return (mat4_zy(m));
}
double mat4_get_zz ( Mat4  m)

Definition at line 102 of file mat4.c.

References mat4_zz.

{
    return (mat4_zz(m));
}
Mat4 mat4_inverse ( Mat4  m)

Definition at line 335 of file mat4.c.

References a, mat4::el, Mat4_id, mat4_unit(), and p.

{
    Mat4    inv = {Mat4_id};
    double  a[4][4];
    int     i, j, k, p[4];
    double  h, q, s, sup, pivot;

    for (i = 0; i < 4; i++)
        for (j = 0; j < 4; j++)
            a[i][j] = m.el[i][j];

    for (k = 0; k < 4; k++)
    {
        sup = 0.0;
        p[k] = 0;
        for (i = k; i < 4; i++)
        {
            s = 0.0;
            for (j = k; j < 4; j++)
                s += fabs(a[i][j]);
            q = fabs(a[i][k]) / s;
            if (sup < q)
            {
                sup = q;
                p[k] = i;
            }
        }
        if (sup == 0.0)
            return (mat4_unit());
        if (p[k] != k)
            for (j = 0; j < 4; j++)
            {
                h = a[k][j];
                a[k][j] = a[p[k]][j];
                a[p[k]][j] = h;
            }
        pivot = a[k][k];
        for (j = 0; j < 4; j++)
            if (j != k)
            {
                a[k][j] = -a[k][j] / pivot;
                for (i = 0; i < 4; i++)
                    if (i != k)
                        a[i][j] += a[i][k] * a[k][j];
            }
        for (i = 0; i < 4; i++)
            a[i][k] = a[i][k] / pivot;
        a[k][k] = 1.0 / pivot;
    }
    for (k = 4 - 1; k >= 0; k--)
        if (p[k] != k)
            for (i = 0; i < 4; i++)
            {
                h = a[i][k];
                a[i][k] = a[i][p[k]];
                a[i][p[k]] = h;
            }

    for (i = 0; i < 4; i++)
        for (j = 0; j < 4; j++)
            inv.el[i][j] = a[i][j];
    return (inv);
}

Here is the call graph for this function:

Mat4* mat4_make ( Mat4  n)

Definition at line 37 of file mat4.c.

References ts_ralloc.

{
    Mat4   *m = ts_ralloc(Mat4);

    *m = n;
    return (m);
}
Mat4 mat4_minus ( Mat4  m)

Definition at line 296 of file mat4.c.

References mat4::el, and Mat4_id.

{
    Mat4    minus = {Mat4_id};
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            minus.el[i][j] = -m.el[i][j];
    return (minus);
}
Mat4 mat4_of_cols ( Vec4  cx,
Vec4  cy,
Vec4  cz,
Vec4  cw 
)

Definition at line 228 of file mat4.c.

References vec4::el, mat4::el, and Mat4_id.

{
    Mat4    m = {Mat4_id};

    m.el[0][0] = cx.el[0];
    m.el[1][0] = cx.el[1];
    m.el[2][0] = cx.el[2];
    m.el[3][0] = cx.el[3];
    m.el[0][1] = cy.el[0];
    m.el[1][1] = cy.el[1];
    m.el[2][1] = cy.el[2];
    m.el[3][1] = cy.el[3];
    m.el[0][2] = cz.el[0];
    m.el[1][2] = cz.el[1];
    m.el[2][2] = cz.el[2];
    m.el[3][2] = cz.el[3];
    m.el[0][3] = cw.el[0];
    m.el[1][3] = cw.el[1];
    m.el[2][3] = cw.el[2];
    m.el[3][3] = cw.el[3];
    return (m);
}
Mat4 mat4_of_rows ( Vec4  rx,
Vec4  ry,
Vec4  rz,
Vec4  rw 
)

Definition at line 251 of file mat4.c.

References vec4::el, mat4::el, and Mat4_id.

{
    Mat4    m = {Mat4_id};

    m.el[0][0] = rx.el[0];
    m.el[0][1] = rx.el[1];
    m.el[0][2] = rx.el[2];
    m.el[0][3] = rx.el[3];
    m.el[1][0] = ry.el[0];
    m.el[1][1] = ry.el[1];
    m.el[1][2] = ry.el[2];
    m.el[1][3] = ry.el[3];
    m.el[2][0] = rz.el[0];
    m.el[2][1] = rz.el[1];
    m.el[2][2] = rz.el[2];
    m.el[2][3] = rz.el[3];
    m.el[3][0] = rw.el[0];
    m.el[3][1] = rw.el[1];
    m.el[3][2] = rw.el[2];
    m.el[3][3] = rw.el[3];
    return (m);
}
void mat4_pprint ( FILE fp,
char *  msg,
Mat4  m 
)

Definition at line 488 of file mat4.c.

References mat4::el.

{
    int     i, n;

    n = strlen(msg);
    (void) fprintf(fp, "%s", msg);
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f%15.6f|\n",
                   m.el[0][0], m.el[0][1], m.el[0][2], m.el[0][3]);
    for (i = 0; i < n; ++i)
        (void) fputc(' ', stderr);
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f%15.6f|\n",
                   m.el[1][0], m.el[1][1], m.el[1][2], m.el[1][3]);
    for (i = 0; i < n; ++i)
        (void) fputc(' ', stderr);
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f%15.6f|\n",
                   m.el[2][0], m.el[2][1], m.el[2][2], m.el[2][3]);
    for (i = 0; i < n; ++i)
        (void) fputc(' ', stderr);
    (void) fprintf(fp, "|%15.6f%15.6f%15.6f%15.6f|\n",
                   m.el[3][0], m.el[3][1], m.el[3][2], m.el[3][3]);
}
void mat4_print ( FILE fp,
Mat4  m 
)

Definition at line 480 of file mat4.c.

References mat4::el.

{
    int     i;

    for (i = 0; i < 4; ++i)
        (void) fprintf(fp, "%f %f %f %f\n", m.el[i][0], m.el[i][1], m.el[i][2], m.el[i][3]);
}
Mat4 mat4_prod ( Mat4  m,
Mat4  n 
)

Definition at line 318 of file mat4.c.

References mat4::el, and Mat4_id.

{
    Mat4    prod = {Mat4_id};
    double  sum;
    int     i, j, k;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
        {
            sum = 0.0;
            for (k = 0; k < 4; ++k)
                sum += m.el[i][k] * n.el[k][j];
            prod.el[i][j] = sum;
        }
    return (prod);
}
Mat4 mat4_read ( FILE fp)

Definition at line 469 of file mat4.c.

References mat4::el, Mat4_id, and temp.

{
    Mat4    temp = {Mat4_id};
    int     i;

    for (i = 0; i < 4; ++i)
        (void) fscanf(fp, "%f %f %f %f",
                      &temp.el[i][0], &temp.el[i][1], &temp.el[i][2], &temp.el[i][3]);
    return (temp);
}
Vec4 mat4_roww ( Mat4  m)

Definition at line 203 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[3][0], m.el[3][1], m.el[3][2], m.el[3][3]));
}

Here is the call graph for this function:

Vec4 mat4_rowx ( Mat4  m)

Definition at line 188 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[0][0], m.el[0][1], m.el[0][2], m.el[0][3]));
}

Here is the call graph for this function:

Vec4 mat4_rowy ( Mat4  m)

Definition at line 193 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[1][0], m.el[1][1], m.el[1][2], m.el[1][3]));
}

Here is the call graph for this function:

Vec4 mat4_rowz ( Mat4  m)

Definition at line 198 of file mat4.c.

References mat4::el, and vec4().

{
    return (vec4(m.el[2][0], m.el[2][1], m.el[2][2], m.el[2][3]));
}

Here is the call graph for this function:

double mat4_sprod ( Vec4  v,
Mat4  m,
Vec4  w 
)

Definition at line 447 of file mat4.c.

References vec4::el, and mat4::el.

{
    double  sum = 0.0;
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            sum += v.el[i] * m.el[i][j] * w.el[j];
    return (sum);
}
Mat4 mat4_sum ( Mat4  m,
Mat4  n 
)

Definition at line 274 of file mat4.c.

References mat4::el, and Mat4_id.

{
    Mat4    sum = {Mat4_id};
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            sum.el[i][j] = m.el[i][j] + n.el[i][j];
    return (sum);
}
Mat4 mat4_tensor ( Vec4  v,
Vec4  w 
)

Definition at line 458 of file mat4.c.

References vec4::el, mat4::el, and Mat4_id.

{
    Mat4    prod = {Mat4_id};
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            prod.el[i][j] = v.el[i] * w.el[j];
    return (prod);
}
Mat4 mat4_times ( double  k,
Mat4  m 
)

Definition at line 307 of file mat4.c.

References mat4::el, and Mat4_id.

{
    Mat4    prod = {Mat4_id};
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            prod.el[i][j] = k * m.el[i][j];
    return (prod);
}
double mat4_trace ( Mat4  m)

Definition at line 410 of file mat4.c.

References mat4::el.

{
    return (m.el[0][0] + m.el[1][1] + m.el[2][2] + m.el[3][3]);
}
Mat4 mat4_transpose ( Mat4  m)

Definition at line 399 of file mat4.c.

References mat4::el, and Mat4_id.

{
    Mat4    trans = {Mat4_id};
    int     i, j;

    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            trans.el[i][j] = m.el[j][i];
    return (trans);
}
Vec4 mat4_transpose_vprod ( Mat4  m,
Vec4  v 
)

Definition at line 431 of file mat4.c.

References vec4::el, mat4::el, and Vec4_id.

{
    Vec4    prod = {Vec4_id};
    double  sum;
    int     i, j;

    for (i = 0; i < 4; ++i)
    {
        sum = 0.0;
        for (j = 0; j < 4; ++j)
            sum += m.el[j][i] * v.el[j];
        prod.el[i] = sum;
    }
    return (prod);
}
Mat4 mat4_unit ( void  )

Definition at line 155 of file mat4.c.

References mat4().

Referenced by mat4_inverse().

{
    return (mat4(1.0, 0.0, 0.0, 0.0,
                 0.0, 1.0, 0.0, 0.0,
                 0.0, 0.0, 1.0, 0.0,
                 0.0, 0.0, 0.0, 1.0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec4 mat4_vprod ( Mat4  m,
Vec4  v 
)

Definition at line 415 of file mat4.c.

References vec4::el, mat4::el, and Vec4_id.

Referenced by proj3_rectify(), and vec3_rectify().

{
    Vec4    prod = {Vec4_id};
    double  sum;
    int     i, j;

    for (i = 0; i < 4; ++i)
    {
        sum = 0.0;
        for (j = 0; j < 4; ++j)
            sum += m.el[i][j] * v.el[j];
        prod.el[i] = sum;
    }
    return (prod);
}

Here is the caller graph for this function:

Mat4 mat4_zero ( void  )

Definition at line 163 of file mat4.c.

{
    return (mat4_0);
}
Mat3 proj2_between ( Vec2  p00,
Vec2  p10,
Vec2  p01,
Vec2  p11,
Vec2  q00,
Vec2  q10,
Vec2  q01,
Vec2  q11 
)

Definition at line 88 of file proj2.c.

References Mat3_id, mat3_inverse(), mat3_prod(), proj2_of_vec2(), proj2_to_frame(), and Vec3_id.

{
    Mat3    mr = {Mat3_id};
    Mat3    ms = {Mat3_id};
    Mat3    mrs = {Mat3_id};
    Vec3    r00 = {Vec3_id};
    Vec3    r10 = {Vec3_id};
    Vec3    r01 = {Vec3_id};
    Vec3    r11 = {Vec3_id};
    Vec3    s00 = {Vec3_id};
    Vec3    s10 = {Vec3_id};
    Vec3    s01 = {Vec3_id};
    Vec3    s11 = {Vec3_id};

    r00 = proj2_of_vec2(p00);
    r10 = proj2_of_vec2(p10);
    r01 = proj2_of_vec2(p01);
    r11 = proj2_of_vec2(p11);

    s00 = proj2_of_vec2(q00);
    s10 = proj2_of_vec2(q10);
    s01 = proj2_of_vec2(q01);
    s11 = proj2_of_vec2(q11);

    mr = proj2_to_frame(r00, r10, r01, r11);
    ms = proj2_to_frame(s00, s10, s01, s11);
    mrs = mat3_prod(ms, mat3_inverse(mr));
    return (mrs);
}

Here is the call graph for this function:

Mat3 proj2_between_proj2 ( Vec3  p00,
Vec3  p10,
Vec3  p01,
Vec3  p11,
Vec3  q00,
Vec3  q10,
Vec3  q01,
Vec3  q11 
)

Definition at line 118 of file proj2.c.

References Mat3_id, mat3_inverse(), mat3_prod(), and proj2_to_frame().

{
    Mat3    mp = {Mat3_id};
    Mat3    mq = {Mat3_id};

    mp = proj2_to_frame(p00, p10, p01, p11);
    mq = proj2_to_frame(q00, q10, q01, q11);
    return (mat3_prod(mq, mat3_inverse(mp)));
}

Here is the call graph for this function:

Vec3 proj2_intersect ( Vec3  p,
Vec3  q 
)

projective coordinates of intersection of two lines

Definition at line 46 of file proj2.c.

References vec3_unitcross().

Referenced by proj2_to_frame().

{
    return (vec3_unitcross(p, q));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 proj2_join ( Vec3  p,
Vec3  q 
)

projective coordinates of projective line joining two points

Definition at line 40 of file proj2.c.

References vec3_unitcross().

Referenced by proj2_to_frame().

{
    return (vec3_unitcross(p, q));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 proj2_of_vec2 ( Vec2  v)

(unit) projective point corresponding to image point

Definition at line 19 of file proj2.c.

References vec2_x, vec2_y, and vec3().

Referenced by proj2_between().

{
    return (vec3(vec2_x(v), vec2_y(v), 1.0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec3 proj2_rectify ( Mat3  m,
Vec3  v 
)

result of applying projective transform to projective point

Definition at line 25 of file proj2.c.

References mat3_vprod(), and vec3_unit().

{
    return (vec3_unit(mat3_vprod(m, v)));
}

Here is the call graph for this function:

Mat3 proj2_to_frame ( Vec3  p00,
Vec3  p10,
Vec3  p01,
Vec3  p11 
)

for stability

images of (1 0 0), (0 1 0), and (0 0 1)

found m up to scale factor on each column

now make (1 1 1) go to p11

Definition at line 57 of file proj2.c.

References Mat3_id, mat3_of_cols(), proj2_intersect(), proj2_join(), solve(), v, Vec3_id, vec3_times(), vec3_unit(), vec3_x, vec3_y, and vec3_z.

Referenced by proj2_between(), and proj2_between_proj2().

{
    Mat3    m = {Mat3_id};
    Vec3    px = {Vec3_id};
    Vec3    py = {Vec3_id};
    Vec3    pz = {Vec3_id};
    Vec3    v = {Vec3_id};

    /** for stability **/
    p00 = vec3_unit(p00);
    p01 = vec3_unit(p01);
    p10 = vec3_unit(p10);
    p11 = vec3_unit(p11);

    /** images of (1 0 0), (0 1 0), and (0 0 1) **/
    px = proj2_intersect(proj2_join(p00, p10), proj2_join(p01, p11));
    py = proj2_intersect(proj2_join(p00, p01), proj2_join(p10, p11));
    pz = vec3_unit(p00);

    /** found m up to scale factor on each column **/
    m = mat3_of_cols(px, py, pz);

    /** now make (1 1 1) go to p11 **/
    v = vec3_unit(solve(m, p11));
    m = mat3_of_cols(vec3_times(vec3_x(v), px),
                     vec3_times(vec3_y(v), py),
                     vec3_times(vec3_z(v), pz));

    return (m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec4 proj3_rectify ( Mat4  m,
Vec4  v 
)

result of applying projective transform to projective point

Definition at line 25 of file proj3.c.

References mat4_vprod(), and vec4_unit().

{
    return (vec4_unit(mat4_vprod(m, v)));
}

Here is the call graph for this function:

Mat3 proj_between_ls ( int  n,
Vec3 p,
Vec3 q 
)

Definition at line 294 of file proj2.c.

References Mat3_id, MIN3, proj_x1(), proj_y1(), and proj_z1().

{
    Mat3    mx = {Mat3_id};
    Mat3    my = {Mat3_id};
    Mat3    mz = {Mat3_id};
    double  bx, by, bz, b;

    mx = proj_x1(n, p, q, &bx);
    my = proj_y1(n, p, q, &by);
    mz = proj_z1(n, p, q, &bz);

    b = MIN3(bx, by, bz);
    if (b == bz)
        return (mz);
    if (b == by)
        return (my);
    return (mx);
}

Here is the call graph for this function:

Mat3 proj_x1 ( int  n,
Vec3 p,
Vec3 q,
double *  badness 
)

least squares replacement for geometrical method above proj_between_x1 is unstable if zx compoment of projection is small use proj_between_ls below which does all three and gets best

Definition at line 138 of file proj2.c.

References a, c, double_v, Mat3_id, mat3_xx, mat3_xy, mat3_xz, mat3_yx, mat3_yy, mat3_yz, mat3_zero(), mat3_zx, mat3_zy, mat3_zz, matrix_alloc(), matrix_cholesky_least_square(), matrix_free(), matrix_full, matrix_putf(), MAX, NULL, vec3_x, vec3_y, vec3_z, vector_alloc(), vector_free(), vector_getf(), and vector_putf().

Referenced by proj_between_ls().

{
    Mat3    m = {Mat3_id};
    Matrix *a = matrix_alloc(2 * n, 8, matrix_full, double_v);
    Vector *b = vector_alloc(2 * n, double_v);
    Vector *c;
    int     i;

    for (i = 0; i < n; i++)
    {
        double  xp = vec3_x(p[i]), xq = vec3_x(q[i]);
        double  yp = vec3_y(p[i]), yq = vec3_y(q[i]);
        double  zp = vec3_z(p[i]), zq = vec3_z(q[i]);

        matrix_putf(zq * yp, a, 2 * i, 0);
        matrix_putf(zq * zp, a, 2 * i, 1);
        matrix_putf(zq * xp, a, 2 * i, 2);
        matrix_putf(-xq * yp, a, 2 * i, 6);
        matrix_putf(-xq * zp, a, 2 * i, 7);
        vector_putf(xq * xp, b, 2 * i);

        matrix_putf(zq * yp, a, 2 * i + 1, 3);
        matrix_putf(zq * zp, a, 2 * i + 1, 4);
        matrix_putf(zq * xp, a, 2 * i + 1, 5);
        matrix_putf(-yq * yp, a, 2 * i + 1, 6);
        matrix_putf(-yq * zp, a, 2 * i + 1, 7);
        vector_putf(yq * xp, b, 2 * i + 1);
    }

    if ((c = matrix_cholesky_least_square(a, b)) == NULL)
    {
        *badness = 1e10;
        return (mat3_zero());
    }
    mat3_xy(m) = vector_getf(c, 0);
    mat3_xz(m) = vector_getf(c, 1);
    mat3_xx(m) = vector_getf(c, 2);
    mat3_yy(m) = vector_getf(c, 3);
    mat3_yz(m) = vector_getf(c, 4);
    mat3_yx(m) = vector_getf(c, 5);
    mat3_zy(m) = vector_getf(c, 6);
    mat3_zz(m) = vector_getf(c, 7);
    mat3_zx(m) = 1.0;

    matrix_free(a);
    vector_free(b);
    vector_free(c);

    *badness = MAX(fabs(mat3_zy(m)), fabs(mat3_zz(m)));
    return (m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat3 proj_y1 ( int  n,
Vec3 p,
Vec3 q,
double *  badness 
)

Definition at line 190 of file proj2.c.

References a, c, double_v, Mat3_id, mat3_xx, mat3_xy, mat3_xz, mat3_yx, mat3_yy, mat3_yz, mat3_zero(), mat3_zx, mat3_zy, mat3_zz, matrix_alloc(), matrix_cholesky_least_square(), matrix_free(), matrix_full, matrix_putf(), MAX, NULL, vec3_x, vec3_y, vec3_z, vector_alloc(), vector_free(), vector_getf(), and vector_putf().

Referenced by proj_between_ls().

{
    Mat3    m = {Mat3_id};
    Matrix *a = matrix_alloc(2 * n, 8, matrix_full, double_v);
    Vector *b = vector_alloc(2 * n, double_v);
    Vector *c;
    int     i;

    for (i = 0; i < n; i++)
    {
        double  xp = vec3_x(p[i]), xq = vec3_x(q[i]);
        double  yp = vec3_y(p[i]), yq = vec3_y(q[i]);
        double  zp = vec3_z(p[i]), zq = vec3_z(q[i]);

        matrix_putf(zq * zp, a, 2 * i, 0);
        matrix_putf(zq * xp, a, 2 * i, 1);
        matrix_putf(zq * yp, a, 2 * i, 2);
        matrix_putf(-xq * zp, a, 2 * i, 6);
        matrix_putf(-xq * xp, a, 2 * i, 7);
        vector_putf(xq * yp, b, 2 * i);

        matrix_putf(zq * zp, a, 2 * i + 1, 3);
        matrix_putf(zq * xp, a, 2 * i + 1, 4);
        matrix_putf(zq * yp, a, 2 * i + 1, 5);
        matrix_putf(-yq * zp, a, 2 * i + 1, 6);
        matrix_putf(-yq * xp, a, 2 * i + 1, 7);
        vector_putf(yq * yp, b, 2 * i + 1);
    }

    if ((c = matrix_cholesky_least_square(a, b)) == NULL)
    {
        *badness = 1e10;
        return (mat3_zero());
    }
    mat3_xz(m) = vector_getf(c, 0);
    mat3_xx(m) = vector_getf(c, 1);
    mat3_xy(m) = vector_getf(c, 2);
    mat3_yz(m) = vector_getf(c, 3);
    mat3_yx(m) = vector_getf(c, 4);
    mat3_yy(m) = vector_getf(c, 5);
    mat3_zz(m) = vector_getf(c, 6);
    mat3_zx(m) = vector_getf(c, 7);
    mat3_zy(m) = 1.0;

    matrix_free(a);
    vector_free(b);
    vector_free(c);

    *badness = MAX(fabs(mat3_zz(m)), fabs(mat3_zx(m)));
    return (m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Mat3 proj_z1 ( int  n,
Vec3 p,
Vec3 q,
double *  badness 
)

Definition at line 242 of file proj2.c.

References a, c, double_v, Mat3_id, mat3_xx, mat3_xy, mat3_xz, mat3_yx, mat3_yy, mat3_yz, mat3_zero(), mat3_zx, mat3_zy, mat3_zz, matrix_alloc(), matrix_cholesky_least_square(), matrix_free(), matrix_full, matrix_putf(), MAX, NULL, vec3_x, vec3_y, vec3_z, vector_alloc(), vector_free(), vector_getf(), and vector_putf().

Referenced by proj_between_ls().

{
    Mat3    m = {Mat3_id};
    Matrix *a = matrix_alloc(2 * n, 8, matrix_full, double_v);
    Vector *b = vector_alloc(2 * n, double_v);
    Vector *c;
    int     i;

    for (i = 0; i < n; i++)
    {
        double  xp = vec3_x(p[i]), xq = vec3_x(q[i]);
        double  yp = vec3_y(p[i]), yq = vec3_y(q[i]);
        double  zp = vec3_z(p[i]), zq = vec3_z(q[i]);

        matrix_putf(zq * xp, a, 2 * i, 0);
        matrix_putf(zq * yp, a, 2 * i, 1);
        matrix_putf(zq * zp, a, 2 * i, 2);
        matrix_putf(-xq * xp, a, 2 * i, 6);
        matrix_putf(-xq * yp, a, 2 * i, 7);
        vector_putf(xq * zp, b, 2 * i);

        matrix_putf(zq * xp, a, 2 * i + 1, 3);
        matrix_putf(zq * yp, a, 2 * i + 1, 4);
        matrix_putf(zq * zp, a, 2 * i + 1, 5);
        matrix_putf(-yq * xp, a, 2 * i + 1, 6);
        matrix_putf(-yq * yp, a, 2 * i + 1, 7);
        vector_putf(yq * zp, b, 2 * i + 1);
    }

    if ((c = matrix_cholesky_least_square(a, b)) == NULL)
    {
        *badness = 1e10;
        return (mat3_zero());
    }
    mat3_xx(m) = vector_getf(c, 0);
    mat3_xy(m) = vector_getf(c, 1);
    mat3_xz(m) = vector_getf(c, 2);
    mat3_yx(m) = vector_getf(c, 3);
    mat3_yy(m) = vector_getf(c, 4);
    mat3_yz(m) = vector_getf(c, 5);
    mat3_zx(m) = vector_getf(c, 6);
    mat3_zy(m) = vector_getf(c, 7);
    mat3_zz(m) = 1.0;

    matrix_free(a);
    vector_free(b);
    vector_free(c);

    *badness = MAX(fabs(mat3_zx(m)), fabs(mat3_zy(m)));
    return (m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec2 vec2 ( double  x,
double  y 
)

@(#)

Definition at line 46 of file vec2.c.

References vec2::el, v, and Vec2_id.

{
    Vec2    v = {Vec2_id};

    v.el[0] = x;
    v.el[1] = y;
    return (v);
}
Vec2* vec2_alloc ( void  )

for use with list utilities

Definition at line 15 of file vec2.c.

References vec2::el, ts_ralloc, and v.

Referenced by add_to_cal3d(), edge_add_corr_prop(), edge_add_rect_prop(), edge_save_pos_prop(), ss_make(), and vec2_inter_par_test().

{
    Vec2   *v = ts_ralloc(Vec2);

    v->el[0] = 0.0;
    v->el[1] = 0.0;
    return (Vec2 *) ((void *) v);
}

Here is the caller graph for this function:

double vec2_angle ( Vec2  v,
Vec2  w 
)
void vec2_basis ( Vec2  up,
Vec2 ex,
Vec2 ey 
)

Definition at line 269 of file vec2.c.

References vec2_ex(), vec2_ey(), vec2_mod(), vec2_perp(), and vec2_unit().

Referenced by line2_basis(), line2_correct(), tv_camera2(), and tv_orient2().

{
    if (vec2_mod(up) == 0.0)
    {
        *ex = vec2_ex();
        *ey = vec2_ey();
        return;
    }
    *ey = vec2_unit(up);
    *ex = vec2_perp(*ey);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vec2_circ_3_points ( Vec2  p1,
Vec2  p2,
Vec2  p3,
Vec2 centre,
double *  radius 
)

Definition at line 70 of file geom2.c.

References a, sqrt(), u, v, vec2_diff(), vec2_dot(), Vec2_id, vec2_sqrmod(), vec2_sum(), and vec2_times().

Referenced by conic_circ_3pt().

{
    Vec2    a = {Vec2_id};
    Vec2    b = {Vec2_id};
    double  a2, b2, ab, u, v, w;

    a = vec2_diff(p2, p1);
    b = vec2_diff(p3, p1);

    a2 = vec2_sqrmod(a);
    b2 = vec2_sqrmod(b);
    ab = vec2_dot(a, b);

    u = b2 * (a2 - ab);
    v = a2 * (b2 - ab);
    w = 2.0 * (a2 * b2 - ab * ab);

    a = vec2_times(u, a);
    b = vec2_times(v, b);

    *centre = vec2_sum(p1, vec2_times(1 / w, vec2_sum(a, b)));
    *radius = sqrt((a2 * b2 * (a2 + b2 - 2.0 * ab)) / (2.0 * w));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vec2_comps ( Vec2  v,
float *  x,
float *  y 
)

Definition at line 70 of file vec2.c.

References vec2::el.

Referenced by vec2_perp().

{
    *x = v.el[0];
    *y = v.el[1];
}

Here is the caller graph for this function:

Vec2* vec2_copy ( Vec2 vec2)

Definition at line 25 of file vec2.c.

References ts_ralloc, and vec2().

Referenced by export_inner(), export_outer(), hough2_locate_max_peak(), mask_size_point_u(), pnt_list_add(), read_poly_points(), str2_copy(), tv_polyroi_proc(), and tv_roipnt_proc().

{
    Vec2   *vec2_new = ts_ralloc(Vec2);

    *vec2_new = *vec2;
    return vec2_new;
}

Here is the call graph for this function:

Here is the caller graph for this function:

double vec2_cross ( Vec2  v,
Vec2  w 
)

Definition at line 155 of file vec2.c.

References vec2::el.

Referenced by area(), line_error(), pvec2_cross(), snake_rot_force(), str2_area(), vec2_angle(), and vec2_inter_lines().

{
    return (v.el[0] * w.el[1] - v.el[1] * w.el[0]);
}

Here is the caller graph for this function:

Vec2 vec2_diff ( Vec2  v,
Vec2  w 
)

Definition at line 122 of file vec2.c.

References vec2::el, and Vec2_id.

Referenced by bridge_small_gaps(), closest_in_index(), compare_lines_directed(), compare_lines_mirror(), compare_lines_rotate(), conic2_draw_axes(), conic_residual(), conics_compatible(), curv_invar_ratio(), curv_invar_ratio_dds(), dd2_ang_length(), ddstr_5pts_choose(), ddstr_conic_5pt(), ddstr_conic_circ_3pt(), ddstr_conic_ellipse_5pt(), dir_vec(), disp_pos3(), dist_to_pos2(), dist_to_v(), ellipse_param(), es_closest_ends(), es_combine(), es_list_order(), figuraly_compatible(), fit2_point_on_line(), fit2_regres_it(), get_inter_lines(), get_intersection(), grad_orth(), grad_pre_ave(), grad_pre_bin(), grad_pre_lin(), hough2_plot_points(), hyperbola_branch(), hyperbola_param(), imf_poly_crop(), kw_attract(), kw_repel(), kwsnake_from_ucbs2(), kwsnake_internal_step_orth(), kwsnake_orth(), kwsnake_reorth(), label_grid_lines(), line2_best_fit(), line2_fit(), line2_fit_and_grow(), line2_make(), line2_on_and_overlap(), line2_point_on_line(), line_error(), line_sqrdist(), line_to_model(), linear_prox(), locate_using_short_lines(), mirror_matched_model(), notv_snake_push_drag(), notv_snake_shift_drag(), notv_snake_zoom_drag(), origin1_from_match(), paxis_frame_drag(), paxis_set_start(), paxis_show(), pmove_frame_drag(), poly_prox(), poly_rotate(), poly_rotate_and_scale(), proj2(), pvec2_diff(), raxis_show(), rectify_orient(), rectify_pos_and_dir(), remerge(), roiline_closest(), rts_get(), seg_es_etest(), snake_external_step(), snake_perp(), snake_push_drag(), snake_rot_force(), snake_rot_step(), snake_scale_force(), snake_scale_step(), snake_shift_drag(), snake_trans_force(), snake_zoom_drag(), str2_align(), str2_eigen(), str2_rts(), str_ics2(), tol(), trans2_rot_about(), tv_poly_expand_p(), tv_poly_replace_p(), tv_poly_rotate_p(), tv_roigbl_proc(), ucbs2_param(), vec2_circ_3_points(), vec2_dist_point_line(), vec2_inter_lines(), vec2_inter_par_test(), vec2_join_2_points(), vec2_perp_dist(), vec2_proj_on_line(), vec2_projperp(), and wx_add_line().

{
    Vec2    diff = {Vec2_id};

    diff.el[0] = v.el[0] - w.el[0];
    diff.el[1] = v.el[1] - w.el[1];
    return (diff);
}
double vec2_dist ( Vec2  v,
Vec2  w 
)
double vec2_dist_point_line ( Vec2  q,
Vec2  l,
Vec2  v 
)

Definition at line 62 of file geom2.c.

References vec2_diff(), Vec2_id, vec2_mod(), and vec2_projperp().

Referenced by line_pair_residual(), roiline_closest(), and scale_from_loc().

{
    Vec2    dq = {Vec2_id};

    dq = vec2_projperp(vec2_diff(q, l), v);
    return (vec2_mod(dq));
}

Here is the call graph for this function:

Here is the caller graph for this function:

double vec2_dot ( Vec2  v,
Vec2  w 
)
Vec2 vec2_ex ( void  )

Definition at line 60 of file vec2.c.

References vec2().

Referenced by basis2_alloc(), hough2_plot_points(), scale_from_loc(), tv_camera2_image(), tv_camera2_rect(), tv_camera2_roi(), tv_camera2_roi_stretch(), vec2_basis(), vec2_modunit(), and vec2_unit().

{
    return (vec2(1.0, 0.0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vec2_extend_hull ( Vec2 vmin,
Vec2 vmax,
Vec2  v 
)

@(#)Find max and min x,y extent of a set of vectors sequentially

Definition at line 8 of file hull2.c.

References vec2(), vec2_x, vec2_y, xmax, xmin, ymax, and ymin.

Referenced by roi_rectify().

{
    double  xmin = vec2_x(*vmin), ymin = vec2_y(*vmin);
    double  xmax = vec2_x(*vmax), ymax = vec2_y(*vmax);
    double  s;

    s = vec2_x(v);
    if (s < xmin)
        xmin = s;
    if (s > xmax)
        xmax = s;
    s = vec2_y(v);
    if (s < ymin)
        ymin = s;
    if (s > ymax)
        ymax = s;
    *vmin = vec2(xmin, ymin);
    *vmax = vec2(xmax, ymax);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec2 vec2_ey ( void  )

Definition at line 65 of file vec2.c.

References vec2().

Referenced by basis2_alloc(), mirror_matched_model(), tv_camera2_image(), tv_camera2_rect(), tv_camera2_roi(), tv_camera2_roi_stretch(), tv_create(), vec2_basis(), xinit(), yinit(), and zinit().

{
    return (vec2(0.0, 1.0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vec2_format ( Vec2  v)

Definition at line 304 of file vec2.c.

References vec2::el, and format().

Referenced by edge_format(), and trans2_format().

{
    format("%f %f\n", v.el[0], v.el[1]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vec2_free ( void *  v)

Definition at line 41 of file vec2.c.

References rfree().

Referenced by edge_add_corr_prop(), edge_add_rect_prop(), edge_save_pos_prop(), label_grid_lines(), mask_size_start_u(), restart_markup(), sroi_markup_mouse(), stat_snake_edit(), stat_snake_mingap(), tv_poly_replace_p(), tv_poly_set(), and world_free().

{
    rfree((void *) v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double vec2_get_x ( Vec2 v)

Definition at line 76 of file vec2.c.

References vec2::el.

Referenced by form_disp_str().

{
    return (v->el[0]);
}

Here is the caller graph for this function:

double vec2_get_y ( Vec2 v)

Definition at line 81 of file vec2.c.

References vec2::el.

{
    return (v->el[1]);
}
Vec2 vec2_greater ( Vec2  v1,
Vec2  v2 
)

Definition at line 320 of file vec2.c.

References vec2::el, MAX, and vec2().

Referenced by vec2_ranges().

{
    return (vec2(MAX(v1.el[0], v2.el[0]), (MAX(v1.el[1], v2.el[1]))));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec2 vec2_inter_lines ( Vec2  l1,
Vec2  v1,
Vec2  l2,
Vec2  v2 
)

Definition at line 46 of file geom2.c.

References c, vec2_cross(), vec2_diff(), vec2_midpoint(), vec2_sum(), and vec2_times().

Referenced by vec2_inter_par_test().

{
    double  c = vec2_cross(v1, v2), t1;

    if (c == 0.0)
        return (vec2_midpoint(l1, l2));
    t1 = vec2_cross(vec2_diff(l2, l1), v2) / c;
    return (vec2_sum(l1, vec2_times(t1, v1)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec2* vec2_inter_par_test ( Vec2  p,
Vec2  v1,
Vec2  q,
Vec2  v2,
double  parallel 
)

Definition at line 94 of file geom2.c.

References a, cp, vec2::el, NULL, vec2_alloc(), vec2_diff(), vec2_dot(), Vec2_id, vec2_inter_lines(), vec2_parallel(), and vec2_times().

Referenced by grid_match(), label_grid_lines(), min_interx(), min_intery(), store_left_vertex(), and store_right_vertex().

{
    Vec2    cp = {Vec2_id};
    Vec2    b = {Vec2_id};
    Vec2   *isct;
    double  a;

    cp = vec2_inter_lines(p, v1, q, v2);
    if (!vec2_parallel(v1, v2, parallel))
    {
        cp.el[0] = -v2.el[1];
        cp.el[1] = v2.el[0];

        a = vec2_dot(cp, vec2_diff(p, q)) / vec2_dot(cp, v1);
        b = vec2_times(a, v1);

        isct = vec2_alloc();
        isct->el[0] = p.el[0] - b.el[0];
        isct->el[1] = p.el[1] - b.el[1];
        return (isct);
    } else
        return (NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Vec2 vec2_interp ( double  k,
Vec2  v1,
Vec2  v2 
)

Definition at line 140 of file vec2.c.

References vec2::el, interp, and Vec2_id.

Referenced by str2_point().

{
    double  k1 = 1.0 - k;
    Vec2    interp = {Vec2_id};

    interp.el[0] = k1 * v1.el[0] + k * v2.el[0];
    interp.el[1] = k1 * v1.el[1] + k * v2.el[1];
    return (interp);
}

Here is the caller graph for this function: