21 #include "HomgLine2D.hh"
33 int intersectioncount = 0;
40 edges[0] = Intersection(left);
41 edges[1] = Intersection(right);
42 edges[2] = Intersection(top);
43 edges[3] = Intersection(bottom);
55 for (
unsigned int i=0; i<4; i++){
56 if (!edges[i].IsAtInfinity()) {
58 if (edges[i][0] < 0.0 && edges[i][0] > -HOMGLINE2D_EPS)
60 if (edges[i][1] < 0.0 && edges[i][1] > -HOMGLINE2D_EPS)
62 if (edges[i][0] > (
double)width-1.0 &&
63 edges[i][0] < (
double)width-1.0 +HOMGLINE2D_EPS)
64 edges[i][0] = (double)width-1.0;
65 if (edges[i][1] > (
double)height-1.0 &&
66 edges[i][1] < (double)height-1.0 +HOMGLINE2D_EPS)
67 edges[i][1] = (double)height-1.0;
69 edges[i][0] = edges[i][1] = -numeric_limits<double>::max();
83 if ((edges[0][1]>=0.0 && edges[0][1]<=(
double)height-1.0)){
86 coo[1] = (
unsigned int)rint(edges[0][1]);
90 if ((edges[1][1]>=0.0 && edges[1][1]<=(
double)height-1.0)){
91 coo[intersectioncount*2] = width - 1;
92 coo[intersectioncount*2+1] = (
unsigned int)rint(edges[1][1]);
104 if ((edges[2][0]>=0.0 && edges[2][0]<=(
double)width-1.0)){
106 switch (intersectioncount){
108 coo[0] = (
unsigned int)rint(edges[2][0]);
113 coo[2] = (
unsigned int)rint(edges[2][0]);
124 if ((edges[3][0]>=0.0 && edges[3][0]<=(
double)width-1.0)){
126 switch (intersectioncount){
128 coo[0] = (
unsigned int)rint(edges[3][0]);
133 coo[2] = (
unsigned int)rint(edges[3][0]);
138 if (sqrt(pow((
double)(coo[0]-coo[2]),2) +
139 pow((
double)(coo[1]-coo[3]),2))<
140 sqrt(pow((
double)(coo[0]-(
unsigned int)rint(edges[3][0])),2) +
141 pow((
double)(coo[1]-(height -1)),2))){
142 coo[2] = (
unsigned int)rint(edges[3][0]);
156 return (intersectioncount >1);
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
bool GetIntersectionsWithImage(unsigned int width, unsigned int height, unsigned int coo[4])
! assumes line is given in pixel coo ! returns true if line intersects with image of given size retur...
a line l = (a b c)^T is a form of the implicit straight line equation 0 = a*x + b*y + c if homogenize...