Changes in / [0d5dce:da3024]


Ignore:
Location:
src
Files:
11 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • src/Line.cpp

    r0d5dce rda3024  
    215215}
    216216
    217 std::vector<Vector> Line::getSphereIntersections() const{
    218   std::vector<Vector> res;
    219 
    220   // line is kept in normalized form, so we can skip a lot of calculations
    221   double discriminant = 1-origin->NormSquared();
    222   // we might have 2, 1 or 0 solutions, depending on discriminant
    223   if(discriminant>=0){
    224     if(discriminant==0){
    225       res.push_back(*origin);
    226     }
    227     else{
    228       Vector helper = sqrt(discriminant)*(*direction);
    229       res.push_back(*origin+helper);
    230       res.push_back(*origin-helper);
    231     }
    232   }
    233   return res;
    234 }
    235 
    236217Line makeLineThrough(const Vector &x1, const Vector &x2){
    237218  if(x1==x2){
  • src/Line.hpp

    r0d5dce rda3024  
    3838  Plane getOrthogonalPlane(const Vector &origin) const;
    3939
    40   std::vector<Vector> getSphereIntersections() const;
    41 
    4240private:
    4341  std::auto_ptr<Vector> origin;
  • src/Makefile.am

    r0d5dce rda3024  
    102102  Patterns/Observer.hpp \
    103103  Patterns/Singleton.hpp
    104  
    105 SHAPESOURCE = \
    106   Shapes/BaseShapes.cpp \
    107   Shapes/Shape.cpp \
    108   Shapes/ShapeOps.cpp
    109 SHAPEHEADER = \
    110   Shapes/BaseShapes.hpp \
    111   Shapes/Shape.hpp \
    112   Shapes/ShapeOps.hpp
    113  
    114104
    115105# all these files are only used for legacy reasons while the transition is in progress
     
    154144  ${PATTERNSOURCE} \
    155145  ${PARSERSOURCE} \
    156   ${SHAPESOURCE} \
    157146  ${DESCRIPTORSOURCE} \
    158147  ${HELPERSOURCE} \
     
    201190  ${PARSERHEADER} \
    202191  ${PATTERNHEADER} \
    203   ${SHAPEHEADER} \
    204192  ${DESCRIPTORHEADER} \
    205193  ${EXCEPTIONHEADER} \
  • src/unittests/LineUnittest.cpp

    r0d5dce rda3024  
    352352  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
    353353}
    354 
    355 void LineUnittest::sphereIntersectionTest(){
    356   {
    357     std::vector<Vector> res = la1->getSphereIntersections();
    358     CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    359     CPPUNIT_ASSERT(testDirection(res[0],e1));
    360     CPPUNIT_ASSERT(testDirection(res[1],e1));
    361     CPPUNIT_ASSERT(res[0]!=res[1]);
    362   }
    363 
    364   {
    365     std::vector<Vector> res = la2->getSphereIntersections();
    366     CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    367     CPPUNIT_ASSERT(testDirection(res[0],e2));
    368     CPPUNIT_ASSERT(testDirection(res[1],e2));
    369     CPPUNIT_ASSERT(res[0]!=res[1]);
    370   }
    371 
    372   {
    373     std::vector<Vector> res = la3->getSphereIntersections();
    374     CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    375     CPPUNIT_ASSERT(testDirection(res[0],e3));
    376     CPPUNIT_ASSERT(testDirection(res[1],e3));
    377     CPPUNIT_ASSERT(res[0]!=res[1]);
    378   }
    379 
    380   {
    381     std::vector<Vector> res = lp1->getSphereIntersections();
    382     CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    383     CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2));
    384     CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2));
    385     CPPUNIT_ASSERT(res[0]!=res[1]);
    386   }
    387 
    388   {
    389     std::vector<Vector> res = lp2->getSphereIntersections();
    390     CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    391     CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3));
    392     CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3));
    393     CPPUNIT_ASSERT(res[0]!=res[1]);
    394   }
    395 
    396   {
    397     std::vector<Vector> res = lp3->getSphereIntersections();
    398     CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    399     CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1));
    400     CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1));
    401     CPPUNIT_ASSERT(res[0]!=res[1]);
    402   }
    403 }
  • src/unittests/LineUnittest.hpp

    r0d5dce rda3024  
    2222  CPPUNIT_TEST ( intersectionTest );
    2323  CPPUNIT_TEST ( rotationTest );
    24   CPPUNIT_TEST ( sphereIntersectionTest );
    2524  CPPUNIT_TEST_SUITE_END();
    2625
     
    3433  void intersectionTest();
    3534  void rotationTest();
    36   void sphereIntersectionTest();
    3735
    3836private:
  • src/unittests/Makefile.am

    r0d5dce rda3024  
    3838  periodentafelTest \
    3939  PlaneUnittest \
    40   ShapeUnittest \
    4140  SingletonTest \
    4241  StackClassUnitTest \
     
    8382  periodentafelTest.cpp \
    8483  PlaneUnittest.cpp \
    85   ShapeUnittest.cpp \
    8684  SingletonTest.cpp \
    8785  stackclassunittest.cpp \
     
    211209PlaneUnittest_LDADD = ${ALLLIBS}
    212210
    213 ShapeUnittest_SOURCES = UnitTestMain.cpp ShapeUnittest.cpp ShapeUnittest.hpp
    214 ShapeUnittest_LDADD = ${ALLLIBS}
    215 
    216211SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp
    217212SingletonTest_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB}
Note: See TracChangeset for help on using the changeset viewer.