#ifndef _TCGVISIONGEOM_H_
#define _TCGVISIONGEOM_H_

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct {
 double x, y;
 int valid;
} tcgVisionPoint2D;

typedef struct {
 double x, y, z;
} tcgVisionPoint3D;

typedef struct {
 tcgVisionPoint2D v1, v2;
 int valid;
} tcgVisionLine2D;

typedef struct {
 tcgVisionPoint3D v1, v2;
} tcgVisionLine3D;

/************************************************************************************************/
/* Finds the coefficients 'a', 'b' and 'c' of the straight line equation 'a.x + b.y + c = 0'.   */
/* Parameters:                                                                                  */
/*  In:                                                                                         */
/*   l - straight line.                                                                         */
/*  Out:                                                                                        */
/*   a, b, c - coefficients.                                                                    */
/* The function returns 1 if ok case and 0 otherwise.                                           */
/************************************************************************************************/
int  tcgVisionGeomGetCoefs(tcgVisionLine2D l, double *a, double *b, double *c);

/************************************************************************************************/
/* Find the intersection of two lines.                                                          */
/* Parameters:                                                                                  */
/*  In:                                                                                         */
/*   a, b, c - coefficients of the first line.                                                  */
/*   d, e, f - coefficients of the second line.                                                 */
/*  Out:                                                                                        */
/*   pinters - intersection point.                                                              */
/* The function returns 1 if ok case and 0 otherwise.                                           */
/************************************************************************************************/
int tcgVisionGeomIntersectLines (double a, double b, double c, double d, double e, double f, tcgVisionPoint2D *pinters);

/************************************************************************************************/
/* Find the intersection of two lines.                                                          */
/* Parameters:                                                                                  */
/*  In:                                                                                         */
/*   l1, l2 - lines.                                                                            */
/*  Out:                                                                                        */
/*   pinters - intersection point.                                                              */
/* The function returns 1 if ok case and 0 otherwise.                                           */
/************************************************************************************************/
int  tcgVisionGeomIntersect2D (tcgVisionLine2D l1, tcgVisionLine2D l2, tcgVisionPoint2D *pinters);

/************************************************************************************************/
/* Find the intersection of two lines.                                                          */
/* Parameters:                                                                                  */
/*  In:                                                                                         */
/*   l1, l2 - lines.                                                                            */
/*  Out:                                                                                        */
/*   pinters - intersection point.                                                              */
/* The function returns 1 if ok case and 0 otherwise.                                           */
/************************************************************************************************/
int  tcgVisionGeomIntersect3D (tcgVisionLine3D l1, tcgVisionLine3D l2, tcgVisionPoint3D *pinters);

#if defined(__cplusplus)
}
#endif

#endif
