10 WELCOME_LOG <<
"Hello from the HyperPlane() Constructor";
12 if ( a.
getDimension() < (int)a.
size() )
ERROR_LOG <<
"You only need #dim points to define a hyperplane - I'll just use the first #dim";
13 if ( a.
getDimension() > (int)a.
size() )
ERROR_LOG <<
"You have not provided enough points to define a hyperplane - I'll probably crash soon";
22 os <<
"HyperPlane: v = ";
25 for (
unsigned int i = 0; i <
_v.
size(); i++){
30 if (endline) os << std::endl;
42 if (interceptionParameters.
size() == 0)
return false;
47 double difference = 0.0;
48 for (
int i = 0; i <
getDimension(); i++) difference += fabs(vectorDifference.
at(i));
50 if( fabs(difference) < 1e-2 )
return true;
60 ERROR_LOG <<
"Your HyperPlane and HyperPoint have different dimensionality. Returning 0";
64 int oldErrorLevel = gErrorIgnoreLevel;
65 gErrorIgnoreLevel = 5000;
68 int reducedDim = dim -1;
70 std::vector<int> linIndep;
71 for (
int i = 0; i < dim; i++){
72 if (dimToOmmit != i) linIndep.push_back(i);
77 TMatrixD vectorD(reducedDim, 1);
78 for (
int i = 0; i < reducedDim ; i++){
79 vectorD(i,0) = lhs.
at(linIndep.at(i));
82 TMatrixD matrix(reducedDim, reducedDim);
83 for (
int j = 0; j < reducedDim; j++){
84 for (
int i = 0; i < reducedDim; i++){
98 if( !lu.Decompose() ) {
101 VERBOSE_LOG <<
"Matrix is singular. Cannot find solution.";
104 gErrorIgnoreLevel = oldErrorLevel;
111 double determinant = 0.0;
112 matrix.Invert(&determinant);
117 TMatrixD result = matrix*vectorD;
120 for (
int i = 0; i < reducedDim; i++){
121 interceptionParameter.
at(i) = result(i,0);
126 gErrorIgnoreLevel = oldErrorLevel;
128 return interceptionParameter;
136 if (lineIntersectionParameter.
getDimension()==0)
return lineIntersectionParameter;
145 if (solution.GetNcols() == 0)
return HyperPoint(0);
153 if (solution.GetNcols() == 0)
return HyperPoint(0);
158 point.
at(i-1) = solution(i,0);
168 ERROR_LOG <<
"Your HyperPlane and HyperLine have different dimensionality. Returning 0";
169 return TMatrixD(0,0);
172 int oldErrorLevel = gErrorIgnoreLevel;
173 gErrorIgnoreLevel = 5000;
181 vectorD(i,0) = lhs.
at(i);
199 TDecompLU lu(matrix);
200 if( !lu.Decompose() ) {
201 VERBOSE_LOG <<
"Matrix is singular. Cannot find solution.";
202 gErrorIgnoreLevel = oldErrorLevel;
203 return TMatrixD(0,0);
209 double determinant = 0.0;
210 matrix.Invert(&determinant);
216 TMatrixD result = matrix*vectorD;
218 gErrorIgnoreLevel = oldErrorLevel;
229 ERROR_LOG <<
"Trying to compare HyperPlanes of different dimensions, returning false";
236 parameters.
at(i) = 1;
238 if ( this->
pointInPlane(pointInOtherPlane) == 0)
return false;
245 GOODBYE_LOG <<
"Goodbye from the HyperPlane() Constructor";
virtual void print(std::ostream &os=std::cout, int endline=1) const
bool pointInPlane(const HyperPoint &hyperPoint) const
virtual void print(std::ostream &os=std::cout, int endline=1) const
virtual const HyperPoint & getDirection(int i=0) const
const HyperPoint & getOrigin() const
bool operator==(const HyperPlane &other) const
HyperPoint findLineIntersectionParameter(const HyperLine &hyperLine) const
HyperPlane(const HyperPointSet &a)
const HyperPoint & at(int i) const
HyperPoint findPlaneIntersectionParameters(const HyperPoint &hyperPoint, int dimToOmmit=0) const
const double & at(int i) const
const int & getDimension() const
unsigned int size() const
TMatrixD findIntersectionSolution(const HyperLine &hyperLine) const
HyperPoint getParametricPoint(const HyperPoint &t) const
HyperPoint findIntersectionPoint(const HyperLine &hyperLine) const