Changeset 0e9394 for molecuilder/src/Plane.cpp
- Timestamp:
- Apr 30, 2010, 9:03:57 AM (16 years ago)
- Children:
- 7a8319
- Parents:
- c53e0b
- git-author:
- Tillmann Crueger <crueger@…> (04/30/10 08:26:28)
- git-committer:
- Tillmann Crueger <crueger@…> (04/30/10 09:03:57)
- File:
-
- 1 edited
-
molecuilder/src/Plane.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Plane.cpp
rc53e0b r0e9394 8 8 #include "Plane.hpp" 9 9 #include "vector.hpp" 10 #include "defs.hpp" 10 11 #include "Exceptions/LinearDependenceException.hpp" 11 12 #include "info.hpp" … … 13 14 #include "verbose.hpp" 14 15 #include "Helpers/Assert.hpp" 16 #include <cmath> 15 17 16 18 /** … … 163 165 return res; 164 166 }; 167 168 /************ Methods inherited from Space ****************/ 169 170 double Plane::distance(Vector &point){ 171 double res = point.ScalarProduct(*normalVector)-offset; 172 return fabs(res); 173 } 174 175 Vector Plane::getClosestPoint(Vector &point){ 176 Vector difference = distance(point) * (*normalVector); 177 if(difference.IsZero()){ 178 // the point itself lies on the plane 179 return point; 180 } 181 // get the direction this vector is pointing 182 double sign = difference.ScalarProduct(*normalVector); 183 // sign cannot be zero, since normalVector and difference are both != zero 184 sign = sign/fabs(sign); 185 return (point - (sign * difference)); 186 } 187 188 bool Plane::isContained(Vector &point){ 189 return (point.ScalarProduct(*normalVector) - offset) < MYEPSILON; 190 }
Note:
See TracChangeset
for help on using the changeset viewer.
