Changeset aab470 for molecuilder/src


Ignore:
Timestamp:
Apr 30, 2010, 9:32:59 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
cb2b9a
Parents:
7a8319
Message:

Added exception specifiers to plane class

Location:
molecuilder/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Plane.cpp

    r7a8319 raab470  
    99#include "vector.hpp"
    1010#include "defs.hpp"
    11 #include "Exceptions/LinearDependenceException.hpp"
    1211#include "info.hpp"
    1312#include "log.hpp"
     
    1918 * generates a plane from three given vectors defining three points in space
    2019 */
    21 Plane::Plane(const Vector &y1, const Vector &y2, const Vector &y3) :
     20Plane::Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException) :
    2221  normalVector(new Vector())
    2322{
     
    4241}
    4342/**
    44  * Constructs a plane from two vectors and a offset.
     43 * Constructs a plane from two direction vectors and a offset.
    4544 * If no offset is given a plane through origin is assumed
    4645 */
    47 Plane::Plane(const Vector &y1, const Vector &y2, double _offset):
     46Plane::Plane(const Vector &y1, const Vector &y2, double _offset) throw(LinearDependenceException) :
    4847    normalVector(new Vector()),
    4948    offset(_offset)
     
    6766}
    6867
    69 Plane::Plane(const Vector &_normalVector, double _offset) :
     68Plane::Plane(const Vector &_normalVector, double _offset) throw(ZeroVectorException):
    7069  normalVector(new Vector(_normalVector)),
    7170  offset(_offset)
    7271{
    73   ASSERT(normalVector->Norm()>MYEPSILON,"Normalvector was zero when constructing a plane.");
     72  if(normalVector->IsZero())
     73    throw ZeroVectorException(__FILE__,__LINE__);
    7474  double factor = 1/normalVector->Norm();
    7575  // normalize the plane parameters
     
    7878}
    7979
    80 Plane::Plane(const Vector &_normalVector, const Vector &_offsetVector) :
     80Plane::Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException):
    8181    normalVector(new Vector(_normalVector))
    8282{
     83  if(normalVector->IsZero()){
     84    throw ZeroVectorException(__FILE__,__LINE__);
     85  }
    8386  normalVector->Normalize();
    8487  offset = normalVector->ScalarProduct(_offsetVector);
  • molecuilder/src/Plane.hpp

    r7a8319 raab470  
    1212#include <vector>
    1313#include "Space.hpp"
     14#include "Exceptions/LinearDependenceException.hpp"
     15#include "Exceptions/ZeroVectorException.hpp"
    1416
    1517class Vector;
     
    1921  typedef std::auto_ptr<Vector> vec_ptr;
    2022public:
    21   Plane(const Vector &y1, const Vector &y2, const Vector &y3);
    22   Plane(const Vector &y1, const Vector &y2, double _offset);
    23   Plane(const Vector &_normalVector, double _offset=0);
    24   Plane(const Vector &_normalVector, const Vector &_offsetVector);
     23  Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException);
     24  Plane(const Vector &y1, const Vector &y2, double _offset) throw(LinearDependenceException);
     25  Plane(const Vector &_normalVector, double _offset=0)  throw(ZeroVectorException);
     26  Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException);
    2527  virtual ~Plane();
    2628
Note: See TracChangeset for help on using the changeset viewer.