Skip to content
Permalink
Browse files

[pal] Remove more unused functions

  • Loading branch information
nyalldawson committed Jul 17, 2015
1 parent 3a44e29 commit ece231908cd810799e30056f5734e75466b8e78f
Showing with 0 additions and 212 deletions.
  1. +0 −177 src/core/pal/geomfunction.cpp
  2. +0 −35 src/core/pal/geomfunction.h
@@ -145,159 +145,6 @@ namespace pal
&& cross_product( x3, y3, x4, y4, x1, y1 ) * cross_product( x3, y3, x4, y4, x2, y2 ) < 0 );
}




/*
*/

bool computeSegIntersectionExt( double x1, double y1, double x2, double y2, double xs1, double ys1, // 1st (segment)
double x3, double y3, double x4, double y4, double xs2, double ys2, // 2nd segment
double *x, double *y )
{
double cp1, cp2, cp3, cp4;
cp1 = cross_product( x1, y1, x2, y2, x3, y3 );
cp2 = cross_product( x1, y1, x2, y2, x4, y4 );
cp3 = cross_product( x3, y3, x4, y4, x1, y1 );
cp4 = cross_product( x3, y3, x4, y4, x2, y2 );


if ( cp1 == 0 && cp2 == 0 && cp3 == 0 && cp4 == 0 )
{
#ifdef _DEBUG_FULL_
std::cout << "coolineaire..." << std::endl;
#endif
return false;
}

// 1 ter
if ( cp1 == 0 && cp3 == 0 )
{
#ifdef _DEBUG_FULL_
std::cout << "cp1 = cp3 = 0 => ignoring..." << std::endl;
#endif
return false;
}

// 1 bis
if ( cp1 == 0 && cp4 == 0 )
{
#ifdef _DEBUG_FULL_
std::cout << "cp1 = cp4 = 0 => ignoring..." << std::endl;
#endif
return false;
}

// 1 bis
if ( cp2 == 0 && cp3 == 0 )
{
#ifdef _DEBUG_FULL_
std::cout << "cp2 = cp3 = 0 => ignoring..." << std::endl;
#endif
return false;
}

// 2bis and 3bis
if ( cp1 == 0 || cp3 == 0 )
{
#ifdef _DEBUG_FULL_
std::cout << "skip..." << std::endl;
#endif
return false;
}

// case 3
if ( cp4 == 0 && cp1 * cp1 < 0 )
{
if ( cross_product( x3, y3, x4, y4, xs1, ys1 ) * cp3 < 0 )
{
*x = x2;
*y = y2;
return true;
}
else
return false;
}

// case 2
if ( cp2 == 0 && cp3 * cp4 < 0 )
{
if ( cross_product( x1, y1, x2, y2, xs2, ys2 ) * cp1 < 0 )
{
*x = x4;
*y = y4;
return true;
}
else
return false;
}

// case 1
if ( cp2 == 0 && cp4 == 0 )
{
double distance[4];
double cx, cy;
double dx, dy;
double nx[4], ny[4];
double toDist;
double ratio;
int i;

cx = x2;
cy = y2;

nx[0] = x1;
ny[0] = y1;

nx[1] = xs1;
ny[1] = ys1;

nx[2] = x3;
ny[2] = y3;

nx[3] = xs2;
ny[3] = ys2;

distance[0] = dist_euc2d( cx, cy, x1, y1 ); // i
toDist = distance[0];

distance[1] = dist_euc2d( cx, cy, xs1, ys1 );// j2
toDist = qMax( toDist, distance[1] );

distance[2] = dist_euc2d( cx, cy, x3, y3 );// k
toDist = qMax( toDist, distance[2] );

distance[3] = dist_euc2d( cx, cy, xs2, ys2 ); // l2
toDist = qMax( toDist, distance[3] );

for ( i = 0; i < 4; i++ )
{
dx = nx[i] - cx;
dy = ny[i] - cy;

ratio = toDist / distance[i];

nx[i] = cx + dx * ratio;
ny[i] = cy + dy * ratio;
}

bool return_val = computeSegIntersection( nx[0], ny[0], nx[1], ny[1], nx[2], ny[2], nx[3], ny[3], x, y );

return return_val;
}

if ( cp1 * cp2 <= 0
&& cp3 *cp4 <= 0 )
{
return computeLineIntersection( x1, y1, x2, y2, x3, y3, x4, y4, x, y );
}

return false;
}




/*
* \brief Intersection bw a line and a segment
* \return true if the point exist false otherwise
@@ -316,30 +163,6 @@ namespace pal
return false;
}



/*
* \brief compute the point wherre two segment intersects
* \return true if the point exist false otherwise
*/

bool computeSegIntersection( double x1, double y1, double x2, double y2, // 1st (segment)
double x3, double y3, double x4, double y4, // 2nd segment
double *x, double *y )
{
double cp1, cp2, cp3, cp4;
cp1 = cross_product( x1, y1, x2, y2, x3, y3 );
cp2 = cross_product( x1, y1, x2, y2, x4, y4 );
cp3 = cross_product( x3, y3, x4, y4, x1, y1 );
cp4 = cross_product( x3, y3, x4, y4, x2, y2 );

if ( cp1 * cp2 <= 0
&& cp3 *cp4 <= 0 )
return computeLineIntersection( x1, y1, x2, y2, x3, y3, x4, y4, x, y );

return false;
}

/*
* \brief compute the point wherre two lines intersects
* \return true if the ok false if line are parallel
@@ -60,41 +60,17 @@ namespace pal
}

bool isPointInPolygon( int npol, double *xp, double *yp, double x, double y );
/*
// code from Randolph Franklin (found at http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/)
int i, j;
bool c = false;
for (i = 0, j = npol-1; i < npol; j = i++){
if ((( (yp[i] <= y) && (y < yp[j])) ||
((yp[j] <= y) && (y < yp[i])))
&& (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i])){
c = !c;
}
}
return c;
}*/



void findLineCircleIntersection( double cx, double cy, double radius,
double x1, double y1, double x2, double y2,
double& xRes, double& yRes );


int convexHull( int *id, const double* const x, const double* const y, int n );


int convexHullId( int *id, const double* const x, const double* const y, int n, int *&cHull );

bool isSegIntersects( double x1, double y1, double x2, double y2, // 1st segment
double x3, double y3, double x4, double y4 ); // 2nd segment

bool computeSegIntersectionExt( double x1, double y1, double x2, double y2, double xs1, double ys1, // 1st (segment)
double x3, double y3, double x4, double y4, double xs2, double ys2, // 2nd segment
double *x, double *y );


/*
* \brief Intersection bw a line and a segment
* \return true if the point exist false otherwise
@@ -103,17 +79,6 @@ namespace pal
double x3, double y3, double x4, double y4, // 2nd segment
double *x, double *y );



/*
* \brief compute the point wherre two segmentss intersects
* \return true if the point exists
*/
bool computeSegIntersection( double x1, double y1, double x2, double y2, // 1st line (segment)
double x3, double y3, double x4, double y4, // 2nd line segment
double *x, double *y );


/*
* \brief compute the point wherre two lines intersects
* \return true if the ok false if line are parallel

0 comments on commit ece2319

Please sign in to comment.
You can’t perform that action at this time.