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
/
LineSegColIntercept.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-06
|
2KB
|
90 lines
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Name : LineSegColIntercept
Type : int
Written on : 20-Nov-90 By : A. Etemadi
Modified on : By :
Directory : ~ees1ae/vap/PerceptualGrouping/LPEG/src/LineRoutines
==============================================================================
Input parameters :
StartCol -- The column number of the start point of the line
StartRow -- The row number of the start point of the line
EndCol -- The column number of the end point of the line
EndRow -- The row number of the end point of the line
Output result :
-1 = Intercept point is at infinity (ie line is horizontal)
0 = successful in calculating gradient
Output parameters :
ColIntercept -- Intercept of the line (y = m.x + c) with x axis
Calling procedure:
double StartCol;
double StartRow;
double EndCol;
double EndRow;
double ColIntercept;
LineSegColIntercept( StartCol,
StartRow,
EndCol,
EndRow,
&ColIntercept)
Functionality:
This function finds the Intercept point of a line with the x axis, given
any two points that lie along the line.
----------------------------------------------------------------------------*/
#include <stdio.h> /* Standard C I/O library */
#include <math.h> /* Standard C mathematics library */
#include <errno.h> /* Standard C error handling routines */
/* #include <strings.h> */ /* Standard C string handling routines */
#include <ctype.h> /* Standard C type identification routines */
#include "../header.h"
int LineSegColIntercept(double StartCol,
double StartRow,
double EndCol,
double EndRow,
double *ColIntercept)
{
#ifdef debug
fprintf(stderr," Start of function LineSegColIntercept \n");
#endif
if (EndCol == StartCol) { /* Line is vertical */
*ColIntercept = StartCol;
return(0);
}
if ( EndRow != StartRow) { /* Line is not horizontal */
*ColIntercept = (StartCol*EndRow - EndCol*StartRow)/
(EndRow - StartRow);
return(0);
}
*ColIntercept = HUGE; /* Line is horizontal */
return(-1);
#ifdef debug
fprintf(stderr," End of function LineSegColIntercept \n");
#endif
}