Changes in src/Shapes/BaseShapes.cpp [c5186e:bf3817]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Shapes/BaseShapes.cpp
rc5186e rbf3817 6 6 */ 7 7 8 #include "Helpers/Assert.hpp" 8 // include config.h 9 #ifdef HAVE_CONFIG_H 10 #include <config.h> 11 #endif 12 13 #include "Helpers/MemDebug.hpp" 14 9 15 #include "Shapes/BaseShapes.hpp" 10 16 #include "Shapes/BaseShapes_impl.hpp" 11 12 #include <cmath>13 17 14 18 #include "LinearAlgebra/Vector.hpp" … … 18 22 } 19 23 20 21 /**22 * algorithm taken from http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere23 * \param N number of points on surface24 */25 std::vector<Vector> Sphere_impl::getHomogeneousPointsOnSurface(const int N) const {26 std::vector<Vector> PointsOnSurface;27 28 const double dlength = M_PI*(3.-sqrt(5.));29 double length = 0;30 const double dz = 2.0/N;31 double z = 1. - dz/2.;32 Vector point;33 for (int ka = 0; ka<N; ka++){34 const double r = sqrt(1.-z*z);35 point.Zero();36 point[0] = cos(length)*r;37 point[1] = sin(length)*r;38 point[2] = z;39 PointsOnSurface.push_back(point);40 z = z - dz;41 length = length + dlength;42 }43 44 ASSERT(PointsOnSurface.size() == N, "Sphere_impl::getHomogeneousPointsOnSurface() did not create enough points.");45 return PointsOnSurface;46 }47 48 49 24 Shape Sphere(){ 50 25 Shape::impl_ptr impl = Shape::impl_ptr(new Sphere_impl()); … … 53 28 54 29 bool Cuboid_impl::isInside(const Vector &point){ 55 return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1); 56 } 57 58 /** 59 * \param N number of points on surface 60 */ 61 std::vector<Vector> Cuboid_impl::getHomogeneousPointsOnSurface(const int N) const { 62 std::vector<Vector> PointsOnSurface; 63 ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet"); 64 return PointsOnSurface; 30 return point[0]<=1 && point[1]<=1 && point[2]<=1; 65 31 } 66 32 67 33 Shape Cuboid(){ 68 Shape::impl_ptr impl = Shape::impl_ptr(new Cuboid_impl());34 Shape::impl_ptr impl = Shape::impl_ptr(new Sphere_impl()); 69 35 return Shape(impl); 70 36 }
Note:
See TracChangeset
for help on using the changeset viewer.