Changes in src/Shapes/BaseShapes.cpp [955b91:c67c65]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Shapes/BaseShapes.cpp
r955b91 rc67c65 37 37 #include <algorithm> 38 38 39 bool Sphere_impl::isInside(const Vector &point) {40 return point.NormSquared()<=1 ;41 } 42 43 bool Sphere_impl::isOnSurface(const Vector &point) {44 return fabs(point.NormSquared()-1 )<MYEPSILON;45 } 46 47 Vector Sphere_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){39 bool Sphere_impl::isInside(const Vector &point) const{ 40 return point.NormSquared()<=1.; 41 } 42 43 bool Sphere_impl::isOnSurface(const Vector &point) const{ 44 return fabs(point.NormSquared()-1.)<MYEPSILON; 45 } 46 47 Vector Sphere_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){ 48 48 if(!isOnSurface(point)){ 49 49 throw NotOnSurfaceException() << ShapeVector(&point); … … 52 52 } 53 53 54 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line){ 54 Vector Sphere_impl::getCenter() const 55 { 56 return Vector(0.,0.,0.); 57 } 58 59 double Sphere_impl::getRadius() const 60 { 61 return 1.; 62 } 63 64 double Sphere_impl::getVolume() const 65 { 66 return (4./3.)*M_PI; // 4/3 pi r^3 67 } 68 69 double Sphere_impl::getSurfaceArea() const 70 { 71 return 2.*M_PI; // 2 pi r^2 72 } 73 74 75 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line) const{ 55 76 LineSegmentSet res(line); 56 77 std::vector<Vector> intersections = line.getSphereIntersections(); … … 61 82 } 62 83 63 std::string Sphere_impl::toString() {84 std::string Sphere_impl::toString() const{ 64 85 return "Sphere()"; 86 } 87 88 enum ShapeType Sphere_impl::getType() const 89 { 90 return SphereType; 65 91 } 66 92 … … 115 141 } 116 142 143 std::vector<Vector> Sphere_impl::getHomogeneousPointsInVolume(const size_t N) const { 144 ASSERT(0, 145 "Sphere_impl::getHomogeneousPointsInVolume() - not implemented."); 146 return std::vector<Vector>(); 147 } 117 148 118 149 Shape Sphere(){ … … 129 160 } 130 161 131 bool Cuboid_impl::isInside(const Vector &point) {162 bool Cuboid_impl::isInside(const Vector &point) const{ 132 163 return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1); 133 164 } 134 165 135 bool Cuboid_impl::isOnSurface(const Vector &point) {166 bool Cuboid_impl::isOnSurface(const Vector &point) const{ 136 167 bool retVal = isInside(point); 137 168 // test all borders of the cuboid … … 144 175 } 145 176 146 Vector Cuboid_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){177 Vector Cuboid_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){ 147 178 if(!isOnSurface(point)){ 148 179 throw NotOnSurfaceException() << ShapeVector(&point); … … 162 193 } 163 194 164 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line){ 195 196 Vector Cuboid_impl::getCenter() const 197 { 198 return Vector(0.5,0.5,0.5); 199 } 200 201 double Cuboid_impl::getRadius() const 202 { 203 return .5; 204 } 205 206 double Cuboid_impl::getVolume() const 207 { 208 return 1.; // l^3 209 } 210 211 double Cuboid_impl::getSurfaceArea() const 212 { 213 return 6.; // 6 * l^2 214 } 215 216 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line) const{ 165 217 LineSegmentSet res(line); 166 218 // get the intersection on each of the six faces … … 192 244 } 193 245 194 std::string Cuboid_impl::toString() {246 std::string Cuboid_impl::toString() const{ 195 247 return "Cuboid()"; 248 } 249 250 enum ShapeType Cuboid_impl::getType() const 251 { 252 return CuboidType; 196 253 } 197 254 … … 203 260 ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet"); 204 261 return PointsOnSurface; 262 } 263 264 std::vector<Vector> Cuboid_impl::getHomogeneousPointsInVolume(const size_t N) const { 265 ASSERT(0, 266 "Cuboid_impl::getHomogeneousPointsInVolume() - not implemented."); 267 return std::vector<Vector>(); 205 268 } 206 269
Note:
See TracChangeset
for help on using the changeset viewer.