Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/BaseShapes.cpp

    r955b91 rc67c65  
    3737#include <algorithm>
    3838
    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){
     39bool Sphere_impl::isInside(const Vector &point) const{
     40  return point.NormSquared()<=1.;
     41}
     42
     43bool Sphere_impl::isOnSurface(const Vector &point) const{
     44  return fabs(point.NormSquared()-1.)<MYEPSILON;
     45}
     46
     47Vector Sphere_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){
    4848  if(!isOnSurface(point)){
    4949    throw NotOnSurfaceException() << ShapeVector(&point);
     
    5252}
    5353
    54 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line){
     54Vector Sphere_impl::getCenter() const
     55{
     56  return Vector(0.,0.,0.);
     57}
     58
     59double Sphere_impl::getRadius() const
     60{
     61  return 1.;
     62}
     63
     64double Sphere_impl::getVolume() const
     65{
     66        return (4./3.)*M_PI; // 4/3 pi r^3
     67}
     68
     69double Sphere_impl::getSurfaceArea() const
     70{
     71        return 2.*M_PI; // 2 pi r^2
     72}
     73
     74
     75LineSegmentSet Sphere_impl::getLineIntersections(const Line &line) const{
    5576  LineSegmentSet res(line);
    5677  std::vector<Vector> intersections = line.getSphereIntersections();
     
    6182}
    6283
    63 std::string Sphere_impl::toString(){
     84std::string Sphere_impl::toString() const{
    6485  return "Sphere()";
     86}
     87
     88enum ShapeType Sphere_impl::getType() const
     89{
     90        return SphereType;
    6591}
    6692
     
    115141}
    116142
     143std::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}
    117148
    118149Shape Sphere(){
     
    129160}
    130161
    131 bool Cuboid_impl::isInside(const Vector &point){
     162bool Cuboid_impl::isInside(const Vector &point) const{
    132163  return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1);
    133164}
    134165
    135 bool Cuboid_impl::isOnSurface(const Vector &point){
     166bool Cuboid_impl::isOnSurface(const Vector &point) const{
    136167  bool retVal = isInside(point);
    137168  // test all borders of the cuboid
     
    144175}
    145176
    146 Vector Cuboid_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){
     177Vector Cuboid_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){
    147178  if(!isOnSurface(point)){
    148179    throw NotOnSurfaceException() << ShapeVector(&point);
     
    162193}
    163194
    164 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line){
     195
     196Vector Cuboid_impl::getCenter() const
     197{
     198  return Vector(0.5,0.5,0.5);
     199}
     200
     201double Cuboid_impl::getRadius() const
     202{
     203  return .5;
     204}
     205
     206double Cuboid_impl::getVolume() const
     207{
     208        return 1.; // l^3
     209}
     210
     211double Cuboid_impl::getSurfaceArea() const
     212{
     213        return 6.;      // 6 * l^2
     214}
     215
     216LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line) const{
    165217  LineSegmentSet res(line);
    166218  // get the intersection on each of the six faces
     
    192244}
    193245
    194 std::string Cuboid_impl::toString(){
     246std::string Cuboid_impl::toString() const{
    195247  return "Cuboid()";
     248}
     249
     250enum ShapeType Cuboid_impl::getType() const
     251{
     252        return CuboidType;
    196253}
    197254
     
    203260  ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet");
    204261  return PointsOnSurface;
     262}
     263
     264std::vector<Vector> Cuboid_impl::getHomogeneousPointsInVolume(const size_t N) const {
     265        ASSERT(0,
     266                        "Cuboid_impl::getHomogeneousPointsInVolume() - not implemented.");
     267        return std::vector<Vector>();
    205268}
    206269
Note: See TracChangeset for help on using the changeset viewer.