21 #ifndef __HOMGLINE2D_HH__
22 #define __HOMGLINE2D_HH__
23 #include "bias_config.h"
25 #include <Base/Debug/Error.hh>
26 #include <Base/Debug/Debug.hh>
28 #include <Base/Math/Vector3.hh>
30 #include "HomgPoint2D.hh"
32 #define HOMGLINE2D_TYPE double
34 #define HOMGLINE2D_EPS 1E-12
56 inline HomgLine2D(HOMGLINE2D_TYPE a, HOMGLINE2D_TYPE b, HOMGLINE2D_TYPE c);
71 inline HOMGLINE2D_TYPE GetW();
75 inline void Homogenize();
79 {
return sqrt(DistanceSquared(point)); };
82 inline HOMGLINE2D_TYPE DistanceSquared(
const HomgPoint2D& point);
94 bool GetIntersectionsWithImage(
unsigned int width,
unsigned int height,
136 if (
data_[0] < HOMGLINE2D_EPS &&
data_[0] > -HOMGLINE2D_EPS)
138 if (
data_[1] < HOMGLINE2D_EPS &&
data_[1] > -HOMGLINE2D_EPS)
140 if (
data_[2] < HOMGLINE2D_EPS &&
data_[2] > -HOMGLINE2D_EPS)
151 register HOMGLINE2D_TYPE w =
GetW();
159 inline HOMGLINE2D_TYPE
162 HOMGLINE2D_TYPE dist =
data_[0] * point[0] +
data_[1] * point[1] +
167 return (dist>HOMGLINE2D_EPS)? (dist):(0.0);
191 perpline[0] =
data_[1];
192 perpline[1] = -
data_[0];
194 perpline[2] = - perpline[1]*point[1] - perpline[0]*point[0];
197 #endif // __HOMGLINE2D_HH__
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
HOMGLINE2D_TYPE data_[VECTOR3_SIZE]
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
HOMGLINE2D_TYPE GetW()
returns length of hypothenuse in gradient triangle
void Set(const HomgPoint2D &p1, const HomgPoint2D &p2)
constructing a line through two points
void CrossProduct(const Vector3< T > &argvec, Vector3< T > &destvec) const
cross product of two vectors destvec = this x argvec
void GetPerpendicularLine(HomgPoint2D &point, HomgLine2D &perpline)
return perpendicular line throug point
void Intersection(const HomgLine2D &line, HomgPoint2D &intersect) const
calculates homogenized intersection of two lines
a line l = (a b c)^T is a form of the implicit straight line equation 0 = a*x + b*y + c if homogenize...
void Homogenize()
aequivalent to homogenize for points the gradient triangle is normed to hypothenuse length of 1 ...
class Vector3 contains a Vector of fixed dim.
HOMGLINE2D_TYPE Distance(const HomgPoint2D &point)
calculates distance of a point from line
HOMGLINE2D_TYPE DistanceSquared(const HomgPoint2D &point)
calculates squared distance of a point from line