home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BuildingFinder
/
Staging
/
grouping.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-16
|
3KB
|
119 lines
#include "../polygons.h"
#include "../stdDefs.h"
int inSearchCone(cList *c, cList *candidate, int axis, double sAngle)
/*
* Test If the 'candidate' corner lays in the search cone projected
* from 'c'. The width of the cone is defined by SEARCH_ANGLE.
*
*
*/
{
double ray_x1, ray_y1, ray_x2, ray_y2;
double colInt, rowInt;
double px, py;
double theta;
/* Create a ray, starting at point 'c' and extending in the
image plane in a direction given by Dx, and Dy of the
axis. */
ray_x1 = (double) c->x; ray_y1 = (double) c->y;
if (axis == AXIS1) {
ray_x2 = ray_x1 + c->leg1Dx*LINE_SEARCH_DIST;
ray_y2 = ray_y1 + c->leg1Dy*LINE_SEARCH_DIST;
} else {
ray_x2 = ray_x1 + c->leg2Dx*LINE_SEARCH_DIST;
ray_y2 = ray_y1 + c->leg2Dy*LINE_SEARCH_DIST;
}
/* Now check if 'candiate' overlaps the ray */
theta = LineSegTheta(ray_x1,ray_y1,ray_x2,ray_y2);
LineSegColIntercept(ray_x1,ray_y1,ray_x2,ray_y2,&colInt);
LineSegRowIntercept(ray_x1,ray_y1,ray_x2,ray_y2,&rowInt);
/* Project a perp. line from 'candidate' to the ray */
PtLinePerpIntercept((double)candidate->x,(double)candidate->y,
colInt,rowInt,theta,&px,&py);
/** Take the point of intersection and check if it is on the
segment. **/
if (CheckPtParlLineSeg(px,py,0.0,0.0,
LineLength(ray_x1,ray_y1,ray_x1,ray_y2),theta,
ray_x1,ray_y1,ray_x2,ray_y2) != 0) {
/* printf("Does not Overlap !\n"); */
return(FALSE);
}
/** Now see if the perp line to the ray from the point is within
the search cone. **/
if (LineLength(px,py,(double)candidate->x,(double)candidate->y) <=
(3.0 + (sAngle*LineLength(px,py,(double)c->x,(double)c->y))) ) {
return(TRUE);
}
else {
return(FALSE);
}
}
int cornersCompatible(cList *c1, cList *c2)
{
/** Check if 'c1' and 'c2' are compatile. That is
if c2 is in a cone defined by SEARCH_ANGLE from c1 and
c1 is in a cone from c2 defined by a looser constraint.
Then the corners are compatible. This is tested both
ways, that is if c1 is in c2's "tight" cone **/
float Dx, Dy;
if ( fabs(c1->height - c2->height) > HEIGHT_BUCKET) {
return(FALSE);
}
if (distance((double)c1->x,(double)c1->y,(double)c2->x,
(double)c2->y) < MIN_LINE_LENGTH)
return(FALSE);
Dx = c1->x - c2->x; Dy = c1->y - c2->y;
if (c1->x == c2->x && c1->y == c2->y)
return(FALSE);
if ( inSearchCone(c1,c2,AXIS1,SEARCH_ANGLE)) {
if (inSearchCone(c2,c1,AXIS1,SEARCH_ANGLE+0.1)
|| inSearchCone(c2,c1,AXIS2,SEARCH_ANGLE+0.1) ) {
return(AXIS1);
}
}
if ( inSearchCone(c1,c2,AXIS2,SEARCH_ANGLE)) {
if (inSearchCone(c2,c1,AXIS1,SEARCH_ANGLE+0.1)
|| inSearchCone(c2,c1,AXIS2,SEARCH_ANGLE+0.1) ) {
return(AXIS2);
}
}
if ( inSearchCone(c2,c1,AXIS1,SEARCH_ANGLE)) {
if (inSearchCone(c1,c2,AXIS1,SEARCH_ANGLE+0.1)
|| inSearchCone(c1,c2,AXIS2,SEARCH_ANGLE+0.1) )
return(AXIS1);
}
if ( inSearchCone(c2,c1,AXIS2,SEARCH_ANGLE)) {
if (inSearchCone(c1,c2,AXIS1,SEARCH_ANGLE+0.1)
|| inSearchCone(c1,c2,AXIS2,SEARCH_ANGLE+0.1) )
return(AXIS2);
}
return(FALSE);
}