Changeset ef9df36
- Timestamp:
- Aug 19, 2009, 12:23:05 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 99c484
- Parents:
- 658efb
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r658efb ref9df36 2 2 HEADER = atom.hpp bond.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp helpers.hpp leastsquaremin.hpp linkedcell.hpp molecules.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp 3 3 4 bin_PROGRAMS = molecuilder joiner analyzer VectorUnitTest 4 noinst_PROGRAMS = VectorUnitTest 5 6 bin_PROGRAMS = molecuilder joiner analyzer 5 7 molecuilderdir = ${bindir} 6 8 molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db -
src/vector.cpp
r658efb ref9df36 212 212 * \param *PlaneNormal Plane's normal vector 213 213 * \param *PlaneOffset Plane's offset vector 214 * \param * LineVectorfirst vector of line215 * \param *LineVector 2second vector of line214 * \param *Origin first vector of line 215 * \param *LineVector second vector of line 216 216 * \return true - \a this contains intersection point on return, false - line is parallel to plane 217 217 */ … … 224 224 Direction.CopyVector(LineVector); 225 225 Direction.SubtractVector(Origin); 226 //*out << Verbose(4) << "INFO: Direction is " << Direction << "." << endl; 226 227 factor = Direction.ScalarProduct(PlaneNormal); 227 228 if (factor < MYEPSILON) { // Uniqueness: line parallel to plane? … … 230 231 } 231 232 helper.CopyVector(PlaneOffset); 232 helper.SubtractVector( LineVector);233 helper.SubtractVector(Origin); 233 234 factor = helper.ScalarProduct(PlaneNormal)/factor; 234 235 //factor = Origin->ScalarProduct(PlaneNormal)*(-PlaneOffset->ScalarProduct(PlaneNormal))/(Direction.ScalarProduct(PlaneNormal)); 235 236 Direction.Scale(factor); 236 CopyVector(LineVector); 237 CopyVector(Origin); 238 //*out << Verbose(4) << "INFO: Scaled direction is " << Direction << "." << endl; 237 239 AddVector(&Direction); 238 240 … … 241 243 helper.SubtractVector(PlaneOffset); 242 244 if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) { 243 *out << Verbose(2) << "INFO: Intersection at " << *this << " is good." << endl;245 //*out << Verbose(2) << "INFO: Intersection at " << *this << " is good." << endl; 244 246 return true; 245 247 } else { … … 250 252 251 253 /** Calculates the intersection of the two lines that are both on the same plane. 252 * Note that we do not check whether they are on the same plane. Vector is calculated with respecy to second line. 254 * We construct auxiliary plane with its vector normal to one line direction and the PlaneNormal, then a vector 255 * from the first line's offset onto the plane. Finally, scale by factor is 1/cos(angle(line1,line2..)) = 1/SP(...), and 256 * project onto the first line's direction and add its offset. 253 257 * \param *out output stream for debugging 254 258 * \param *Line1a first vector of first line … … 261 265 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, Vector *Line1a, Vector *Line1b, Vector *Line2a, Vector *Line2b, const Vector *PlaneNormal) 262 266 { 263 double factor1, factor2; 264 Vector helper, Line, LineNormal, *OtherNormal = NULL; 265 const Vector *Normal; 266 bool result = false; 267 268 // create Plane normal vector 269 if (PlaneNormal == NULL) { 270 OtherNormal = new Vector(0.,0.,0.); 271 if (!OtherNormal->MakeNormalVector(Line1a, Line1b, Line2a)) 272 if (!OtherNormal->MakeNormalVector(Line1a, Line1b, Line2b)) { 273 *out << Verbose(1) << "ERROR: GetIntersectionOfTwoLinesOnPlane() cannot create a normal of the plane, everything is linear dependent." << endl; 274 return false; 275 } 276 Normal = OtherNormal; 277 } else 278 Normal = PlaneNormal; 279 *out << Verbose(3) << "INFO: Normal of plane is " << *Normal << "." << endl; 280 281 // check if lines are parallel 282 helper.CopyVector(Line2b); 283 helper.SubtractVector(Line2a); 284 if (fabs(helper.ScalarProduct(Normal)) < MYEPSILON) { 285 *out << Verbose(1) << "Lines " << helper << " and " << Line << " are parallel, no cross point!" << endl; 286 result = false; 287 } else { 288 helper.CopyVector(Line2a); 289 helper.SubtractVector(Line1a); 290 factor1 = helper.ScalarProduct(Normal); 291 helper.CopyVector(Line2b); 292 helper.SubtractVector(Line1a); 293 factor2 = helper.ScalarProduct(Normal); 294 if (fabs(factor2) > MYEPSILON) { 295 CopyVector(Line2a); 296 helper.Scale(factor1/factor2); 297 AddVector(&helper); 267 bool result = true; 268 Vector Direction, OtherDirection; 269 Vector AuxiliaryNormal; 270 Vector Distance; 271 const Vector *Normal = NULL; 272 Vector *ConstructedNormal = NULL; 273 bool FreeNormal = false; 274 275 // construct both direction vectors 276 Zero(); 277 Direction.CopyVector(Line1b); 278 Direction.SubtractVector(Line1a); 279 if (Direction.IsZero()) 280 return false; 281 OtherDirection.CopyVector(Line2b); 282 OtherDirection.SubtractVector(Line2a); 283 if (OtherDirection.IsZero()) 284 return false; 285 286 Direction.Normalize(); 287 OtherDirection.Normalize(); 288 289 //*out << Verbose(4) << "INFO: Normalized Direction " << Direction << " and OtherDirection " << OtherDirection << "." << endl; 290 291 if (fabs(OtherDirection.ScalarProduct(&Direction) - 1.) < MYEPSILON) { // lines are parallel 292 if ((Line1a == Line2a) || (Line1a == Line2b)) 293 CopyVector(Line1a); 294 else if ((Line1b == Line2b) || (Line1b == Line2b)) 295 CopyVector(Line1b); 296 else 297 return false; 298 *out << Verbose(4) << "INFO: Intersection is " << *this << "." << endl; 299 return true; 300 } else { 301 // check whether we have a plane normal vector 302 if (PlaneNormal == NULL) { 303 ConstructedNormal = new Vector; 304 ConstructedNormal->MakeNormalVector(&Direction, &OtherDirection); 305 Normal = ConstructedNormal; 306 FreeNormal = true; 307 } else 308 Normal = PlaneNormal; 309 310 AuxiliaryNormal.MakeNormalVector(&OtherDirection, Normal); 311 //*out << Verbose(4) << "INFO: PlaneNormal is " << *Normal << " and AuxiliaryNormal " << AuxiliaryNormal << "." << endl; 312 313 Distance.CopyVector(Line2a); 314 Distance.SubtractVector(Line1a); 315 //*out << Verbose(4) << "INFO: Distance is " << Distance << "." << endl; 316 if (Distance.IsZero()) { 317 // offsets are equal, match found 318 CopyVector(Line1a); 298 319 result = true; 299 320 } else { 300 Zero(); 301 result = false; 321 CopyVector(Distance.Projection(&AuxiliaryNormal)); 322 //*out << Verbose(4) << "INFO: Projected Distance is " << *this << "." << endl; 323 double factor = Direction.ScalarProduct(&AuxiliaryNormal); 324 //*out << Verbose(4) << "INFO: Scaling factor is " << factor << "." << endl; 325 Scale(1./(factor*factor)); 326 //*out << Verbose(4) << "INFO: Scaled Distance is " << *this << "." << endl; 327 CopyVector(Projection(&Direction)); 328 //*out << Verbose(4) << "INFO: Distance, projected into Direction, is " << *this << "." << endl; 329 if (this->IsZero()) 330 result = false; 331 else 332 result = true; 333 AddVector(Line1a); 302 334 } 303 } 304 305 if (OtherNormal != NULL) 306 delete(OtherNormal); 335 336 if (FreeNormal) 337 delete(ConstructedNormal); 338 } 339 if (result) 340 *out << Verbose(4) << "INFO: Intersection is " << *this << "." << endl; 307 341 308 342 return result; … … 311 345 /** Calculates the projection of a vector onto another \a *y. 312 346 * \param *y array to second vector 313 * \return \f$\langle x, y \rangle\f$ 314 */ 315 double Vector::Projection(const Vector *y) const 316 { 317 return (ScalarProduct(y)); 347 */ 348 void Vector::ProjectIt(const Vector *y) 349 { 350 Vector helper(*y); 351 helper.Scale(-(ScalarProduct(y))); 352 AddVector(&helper); 353 }; 354 355 /** Calculates the projection of a vector onto another \a *y. 356 * \param *y array to second vector 357 * \return Vector 358 */ 359 Vector Vector::Projection(const Vector *y) const 360 { 361 Vector helper(*y); 362 helper.Scale((ScalarProduct(y)/y->NormSquared())); 363 364 return helper; 318 365 }; 319 366 … … 390 437 }; 391 438 439 /** Checks whether vector is normal to \a *normal. 440 * @return true - vector is normalized, false - vector is not 441 */ 442 bool Vector::IsNormalTo(const Vector *normal) const 443 { 444 if (ScalarProduct(normal) < MYEPSILON) 445 return true; 446 else 447 return false; 448 }; 449 392 450 /** Calculates the angle between this and another vector. 393 451 * \param *y array to second vector … … 397 455 { 398 456 double norm1 = Norm(), norm2 = y->Norm(); 399 double angle = 1;457 double angle = -1; 400 458 if ((fabs(norm1) > MYEPSILON) && (fabs(norm2) > MYEPSILON)) 401 459 angle = this->ScalarProduct(y)/norm1/norm2; … … 418 476 // normalise this vector with respect to axis 419 477 a.CopyVector(this); 420 a.Scale(Projection(axis)); 421 SubtractVector(&a); 478 a.ProjectOntoPlane(axis); 422 479 // construct normal vector 423 480 y.MakeNormalVector(axis,this); … … 430 487 // add part in axis direction 431 488 AddVector(&a); 489 }; 490 491 /** Compares vector \a to vector \a b component-wise. 492 * \param a base vector 493 * \param b vector components to add 494 * \return a == b 495 */ 496 bool operator==(const Vector& a, const Vector& b) 497 { 498 bool status = true; 499 for (int i=0;i<NDIM;i++) 500 status = status && (fabs(a.x[i] - b.x[i]) < MYEPSILON); 501 return status; 432 502 }; 433 503 … … 703 773 x2.SubtractVector(y2); 704 774 if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) { 705 cout << Verbose(4) << " Given vectors are linear dependent." << endl;775 cout << Verbose(4) << "WARNING: Given vectors are linear dependent." << endl; 706 776 return false; 707 777 } … … 737 807 Zero(); 738 808 if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) { 739 cout << Verbose(4) << " Given vectors are linear dependent." << endl;809 cout << Verbose(4) << "WARNING: Given vectors are linear dependent." << endl; 740 810 return false; 741 811 } … … 757 827 /** Calculates orthonormal vector to one given vectors. 758 828 * Just subtracts the projection onto the given vector from this vector. 829 * The removed part of the vector is Vector::Projection() 759 830 * \param *x1 vector 760 831 * \return true - success, false - vector is zero … … 763 834 { 764 835 bool result = false; 765 double factor = y1-> Projection(this)/y1->Norm()/y1->Norm();836 double factor = y1->ScalarProduct(this)/y1->NormSquared(); 766 837 Vector x1; 767 838 x1.CopyVector(y1); … … 820 891 }; 821 892 822 /** Determines param ter needed to multiply this vector to obtain intersection point with plane defined by \a *A, \a *B and \a *C.893 /** Determines parameter needed to multiply this vector to obtain intersection point with plane defined by \a *A, \a *B and \a *C. 823 894 * \param *A first plane vector 824 895 * \param *B second plane vector … … 833 904 // cout << "C " << C->Projection(this) << "\t"; 834 905 // cout << endl; 835 return A-> Projection(this);906 return A->ScalarProduct(this); 836 907 }; 837 908 … … 945 1016 for (int i=NDIM;i--;) 946 1017 this->x[i] = y->x[i]; 1018 } 1019 1020 /** Copy vector \a y componentwise. 1021 * \param y vector 1022 */ 1023 void Vector::CopyVector(const Vector y) 1024 { 1025 for (int i=NDIM;i--;) 1026 this->x[i] = y.x[i]; 947 1027 } 948 1028 -
src/vector.hpp
r658efb ref9df36 27 27 double PeriodicDistanceSquared(const Vector *y, const double *cell_size) const; 28 28 double ScalarProduct(const Vector *y) const; 29 double Projection(const Vector *y) const;30 29 double Norm() const; 31 30 double NormSquared() const; … … 33 32 bool IsZero() const; 34 33 bool IsOne() const; 34 bool IsNormalTo(const Vector *normal) const; 35 35 36 36 void AddVector(const Vector *y); 37 37 void SubtractVector(const Vector *y); 38 38 void CopyVector(const Vector *y); 39 void CopyVector(const Vector y); 39 40 void RotateVector(const Vector *y, const double alpha); 40 41 void VectorProduct(const Vector *y); 41 42 void ProjectOntoPlane(const Vector *y); 43 void ProjectIt(const Vector *y); 44 Vector Projection(const Vector *y) const; 42 45 void Zero(); 43 46 void One(double one); … … 68 71 69 72 ostream & operator << (ostream& ost, const Vector &m); 73 bool operator==(const Vector& a, const Vector& b); 70 74 Vector& operator+=(Vector& a, const Vector& b); 71 75 Vector& operator-=(Vector& a, const Vector& b); -
src/vectorunittest.cpp
r658efb ref9df36 25 25 void VectorTest::setUp() 26 26 { 27 zero.Init(0.,0.,0.); 28 unit.Init(1.,0.,0.); 29 otherunit.Init(0.,1.,0.); 30 notunit.Init(0.,1.,1.); 31 two.Init(2.,1.,0.); 27 32 }; 28 33 … … 36 41 void VectorTest::UnityTest() 37 42 { 38 Vector zero(0.,0.,0.);39 Vector unit(1.,0.,0.);40 Vector otherunit(1./sqrt(2.),0.,1./sqrt(2.));41 Vector notunit(0.,1.,1.);42 43 43 // unity and zero tests 44 44 CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() ); … … 55 55 void VectorTest::SimpleAlgebraTest() 56 56 { 57 Vector zero(0.,0.,0.);58 Vector unit(1.,0.,0.);59 Vector otherunit(0.,1.,0.);60 Vector notunit(0.,1.,1.);61 57 Vector helper; 62 58 double factor; 63 64 59 // summation and scaling 65 60 helper.CopyVector(&zero); … … 104 99 void VectorTest::OperatorAlgebraTest() 105 100 { 106 Vector zero(0.,0.,0.);107 Vector unit(1.,0.,0.);108 Vector otherunit(0.,1.,0.);109 Vector notunit(0.,1.,1.);110 111 101 // summation and scaling 102 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); 112 103 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); 113 104 CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() ); … … 119 110 CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() ); 120 111 CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() ); 121 }; 122 123 /** UnitTest for scalar products, norms, distances and angles. 124 */ 125 void VectorTest::EuclidianTest() 126 { 127 Vector zero(0.,0.,0.); 128 Vector unit(1.,0.,0.); 129 Vector otherunit(0.,1.,0.); 130 Vector notunit(0.,1.,1.); 131 Vector two(2.,1.,0.); 132 133 // SCP 112 113 CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) ); 114 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,1.), (notunit-otherunit) ); 115 CPPUNIT_ASSERT_EQUAL( Vector(-1, 0., 1.), (notunit-unit-otherunit) ); 116 }; 117 118 /** UnitTest for scalar products. 119 */ 120 void VectorTest::EuclidianScalarProductTest() 121 { 134 122 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&zero) ); 135 123 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&unit) ); … … 143 131 CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(&otherunit) ); 144 132 CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(¬unit) ); 145 146 // Norms 133 } 134 135 /** UnitTest for norms. 136 */ 137 void VectorTest::EuclidianNormTest() 138 { 147 139 CPPUNIT_ASSERT_EQUAL( 0., zero.Norm() ); 148 140 CPPUNIT_ASSERT_EQUAL( 0., zero.NormSquared() ); … … 153 145 CPPUNIT_ASSERT_EQUAL( 2., notunit.NormSquared() ); 154 146 CPPUNIT_ASSERT_EQUAL( sqrt(2.), notunit.Norm() ); 155 156 // distances 147 } 148 149 /** UnitTest for distances. 150 */ 151 void VectorTest::EuclidianDistancesTest() 152 { 157 153 CPPUNIT_ASSERT_EQUAL( 1., zero.Distance(&unit) ); 158 154 CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance(&unit) ); … … 160 156 CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance(¬unit) ); 161 157 CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance(¬unit) ); 162 163 // Angles 158 } 159 160 /** UnitTest for angles. 161 */ 162 void VectorTest::EuclidianAnglesTest() 163 { 164 164 CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(&unit) ); 165 }; 166 165 CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(&unit) ); 166 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(&unit)) < MYEPSILON ); 167 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(¬unit)) < MYEPSILON ); 168 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(¬unit)) < MYEPSILON ); 169 }; 170 171 /** UnitTest for projections. 172 */ 173 void VectorTest::ProjectionTest() 174 { 175 CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(&unit) ); 176 CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(&unit) ); 177 CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.), otherunit.Projection(&two) ); 178 CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.), two.Projection(&otherunit) ); 179 }; 180 181 /** UnitTest for line intersections. 182 */ 183 void VectorTest::LineIntersectionTest() 184 { 185 Vector helper; 186 // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 187 CPPUNIT_ASSERT_EQUAL( true, helper.GetIntersectionWithPlane((ofstream *)&cout, &unit, &zero, &zero, &two) ); 188 CPPUNIT_ASSERT_EQUAL( zero, helper ); 189 190 // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ??? 191 CPPUNIT_ASSERT_EQUAL( true, helper.GetIntersectionWithPlane((ofstream *)&cout, &otherunit, &two, &unit, ¬unit) ); 192 CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), helper ); 193 194 // four vectors equal to zero 195 CPPUNIT_ASSERT_EQUAL( false, helper.GetIntersectionOfTwoLinesOnPlane((ofstream *)&cout, &zero, &zero, &zero, &zero, NULL) ); 196 CPPUNIT_ASSERT_EQUAL( zero, helper ); 197 198 // four vectors equal to unit 199 CPPUNIT_ASSERT_EQUAL( false, helper.GetIntersectionOfTwoLinesOnPlane((ofstream *)&cout, &unit, &unit, &unit, &unit, NULL) ); 200 CPPUNIT_ASSERT_EQUAL( zero, helper ); 201 202 // two equal lines 203 CPPUNIT_ASSERT_EQUAL( true, helper.GetIntersectionOfTwoLinesOnPlane((ofstream *)&cout, &unit, &two, &unit, &two, NULL) ); 204 CPPUNIT_ASSERT_EQUAL( unit, helper ); 205 206 // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ??? 207 CPPUNIT_ASSERT_EQUAL( true, helper.GetIntersectionOfTwoLinesOnPlane((ofstream *)&cout, &unit, &two, &unit, &otherunit, NULL) ); 208 CPPUNIT_ASSERT_EQUAL( unit, helper ); 209 210 // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 211 CPPUNIT_ASSERT_EQUAL( true, helper.GetIntersectionOfTwoLinesOnPlane((ofstream *)&cout, &unit, &zero, &zero, &two, NULL) ); 212 CPPUNIT_ASSERT_EQUAL( zero, helper ); 213 214 // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ??? 215 CPPUNIT_ASSERT_EQUAL( true, helper.GetIntersectionOfTwoLinesOnPlane((ofstream *)&cout, &unit, &two, &zero, &otherunit, NULL) ); 216 CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), helper ); 217 }; 167 218 168 219 /********************************************** Main routine **************************************/ -
src/vectorunittest.hpp
r658efb ref9df36 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 #include "vector.hpp" 13 14 14 15 /********************************************** Test classes **************************************/ … … 20 21 CPPUNIT_TEST ( SimpleAlgebraTest ); 21 22 CPPUNIT_TEST ( OperatorAlgebraTest ); 22 CPPUNIT_TEST ( EuclidianTest ); 23 CPPUNIT_TEST ( EuclidianScalarProductTest ); 24 CPPUNIT_TEST ( EuclidianNormTest ); 25 CPPUNIT_TEST ( EuclidianDistancesTest ); 26 CPPUNIT_TEST ( EuclidianAnglesTest ); 27 CPPUNIT_TEST ( ProjectionTest ); 28 CPPUNIT_TEST ( LineIntersectionTest ); 23 29 CPPUNIT_TEST_SUITE_END(); 24 30 … … 30 36 void OperatorAlgebraTest(); 31 37 void SimpleAlgebraTest(); 32 void EuclidianTest(); 38 void EuclidianScalarProductTest(); 39 void EuclidianNormTest(); 40 void EuclidianDistancesTest(); 41 void EuclidianAnglesTest(); 42 void ProjectionTest(); 43 void LineIntersectionTest(); 44 45 private: 46 Vector zero; 47 Vector unit; 48 Vector otherunit; 49 Vector notunit; 50 Vector two; 33 51 }; 34 52
Note:
See TracChangeset
for help on using the changeset viewer.