Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/BaseShapes.cpp

    rc5186e rbf3817  
    66 */
    77
    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
    915#include "Shapes/BaseShapes.hpp"
    1016#include "Shapes/BaseShapes_impl.hpp"
    11 
    12 #include <cmath>
    1317
    1418#include "LinearAlgebra/Vector.hpp"
     
    1822}
    1923
    20 
    21 /**
    22  * algorithm taken from http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere
    23  * \param N number of points on surface
    24  */
    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 
    4924Shape Sphere(){
    5025  Shape::impl_ptr impl = Shape::impl_ptr(new Sphere_impl());
     
    5328
    5429bool 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;
    6531}
    6632
    6733Shape Cuboid(){
    68   Shape::impl_ptr impl = Shape::impl_ptr(new Cuboid_impl());
     34  Shape::impl_ptr impl = Shape::impl_ptr(new Sphere_impl());
    6935  return Shape(impl);
    7036}
Note: See TracChangeset for help on using the changeset viewer.