26 #ifndef __HOMGPLANE3D_HH__
27 #define __HOMGPLANE3D_HH__
28 #include "bias_config.h"
30 #include <Base/Debug/Error.hh>
31 #include <Base/Debug/Debug.hh>
32 #include <Base/Math/Vector4.hh>
33 #include <Base/Math/Matrix3x3.hh>
35 #include "HomgPoint3D.hh"
37 #define HOMGPLANE3D_TYPE double
39 #define HOMGPLANE3D_EPS 1E-12
47 :
public Vector4<HOMGPLANE3D_TYPE>
51 { data_[0] = data_[1] = data_[3] = 0.0 ; data_[2] = 1.0 ; };
55 HOMGPLANE3D_TYPE c, HOMGPLANE3D_TYPE d)
56 { data_[0]=a; data_[1]=b; data_[2]=c; data_[3]=d; };
63 SetFromPoints(p1, p2, p3);
72 Set(PointOnPlane, NormalVector); }
76 Set(PointOnPlane, NormalVector); }
82 { SetFromVector(theplane); };
91 BIASASSERT(theplane.
size()==4);
92 data_[0]=theplane[0]; data_[1]=theplane[1];
93 data_[2]=theplane[2]; data_[3]=theplane[3];
105 data_[0] = NormalVector[0];
106 data_[1] = NormalVector[1];
107 data_[2] = NormalVector[2];
124 inline void Normalize();
133 inline HOMGPLANE3D_TYPE DistanceSquared(
const HomgPoint3D& point)
const;
145 inline int GetLineIntersection(
const HomgPoint3D& PointOnLine,
165 HOMGPLANE3D_TYPE norm =
175 HOMGPLANE3D_TYPE norm =
177 normalv[0] = data_[0] / norm;
178 normalv[1] = data_[1] / norm;
179 normalv[2] = data_[2] / norm;
183 inline HOMGPLANE3D_TYPE
186 HOMGPLANE3D_TYPE dist =
data_[0] * point[0] +
data_[1] * point[1] +
200 for (
unsigned int row=0; row<3; row++) {
201 M234[row][0] = p1[row+1];
202 M234[row][1] = p2[row+1];
203 M234[row][2] = p3[row+1];
205 M123[row][0] = p1[row];
206 M123[row][1] = p2[row];
207 M123[row][2] = p3[row];
242 if (LineDir[3]!=0.0) {
243 BIASERR(
"Incorrect data for line direction (w==0 required for dir)! "
244 <<PointOnLine<<
" "<<LineDir);
253 const double dirproduct = LineDir[0]*
data_[0]+LineDir[1]*
data_[1]+
255 const double pointproduct = PointOnLine[0]*data_[0] +
256 PointOnLine[1]*data_[1] + PointOnLine[2]*data_[2] +
257 PointOnLine[3]*data_[3];
259 if (fabs(dirproduct)<HOMGPLANE3D_EPS) {
260 if (fabs(pointproduct)<HOMGPLANE3D_EPS) {
262 Intersection = PointOnLine;
266 Intersection = PointOnLine;
267 Intersection[3] = 0.0;
271 const double lamda = pointproduct / dirproduct;
272 Intersection = PointOnLine - (LineDir * lamda);
289 #endif // __HOMGPLANE3D_HH__
void SetFromPoints(const HomgPoint3D &p1, const HomgPoint3D &p2, const HomgPoint3D &p3)
constructs a homogeneous plane from three points
int GetLineIntersection(const HomgPoint3D &PointOnLine, const HomgPoint3D &LineDir, HomgPoint3D &Intersection) const
compute the intersection point of the plane with a line (defined by point and direction) ...
HOMGPLANE3D_TYPE DistanceSquared(const HomgPoint3D &point) const
calculates squared distance of a point from plane
class for column vectors with arbitrary size
HomgPlane3D(const Vector< HOMGPLANE3D_TYPE > &theplane)
void ScalarProduct(const Vector3< T > &argvec, T &result) const
scalar product (=inner product) of two vectors, storing the result in result
Vector3< HOMGPLANE3D_TYPE > GetNormalVector() const
returns normal vector, only wrapper
class Vector4 contains a Vector of dim.
HomgPlane3D(const HomgPoint3D &p1, const HomgPoint3D &p2, const HomgPoint3D &p3)
constructs a homogeneous plane from three points
HOMGPLANE3D_TYPE data_[VECTOR4SIZE]
HomgPlane3D(const HomgPoint3D &PointOnPlane, const Vector3< double > &NormalVector)
HomgPlane3D(const Vector4< HOMGPLANE3D_TYPE > &theplane)
HomgPlane3D(const Vector3< double > &PointOnPlane, const Vector3< double > &NormalVector)
construct plane, given arbitrary point and normal
HomgPoint3D ProjectPoint(const HomgPoint3D &origPoint) const
finds the closest point which is on the plane
is a 'fixed size' quadratic matrix of dim.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Vector4< T > & operator=(const T &scalar)
assignment operator set the vector elementwise to scalar value
void Set(const Vector3< double > &PointOnPlane, const Vector3< double > &NormalVector)
construct plane, given arbitrary point and normal
T GetDeterminant() const
returns the Determinant |A| of this
void Normalize()
set first three components to vector of norm 1 and scales w accordingly => encodes Hesse normal form ...
void SetFromVector(const Vector< HOMGPLANE3D_TYPE > &theplane)
~HomgPlane3D()
empty destructor
HomgPlane3D(HOMGPLANE3D_TYPE a, HOMGPLANE3D_TYPE b, HOMGPLANE3D_TYPE c, HOMGPLANE3D_TYPE d)
set four values of the plane vector
A homogeneous plane (in P^3) All points X on the plane p fulfill p ' * X = 0.