Luca ListaPotenza, 16/5/2001 Intersezione: implementazione Implementazione dellalgoritmo #include Intersection.h #include #include Surface.h #include Trajectory.h const int maxIterations 20 const double sMax 1.e+6 const double accuracy1.e-3 double Intersection::sIntersect(double s1, double s2) { // algoritmo di Newton-Raphson double s = s1; double maxS = max(s1, s2); double minS = min(s1, s2); double d, delta; for( int j = 0; j < maxIterations; j++ ) { Point p = _trajectory->position( s ); d = surface_->distance( p ); delta = surface_->derDist( p, trajectory_->direction( s ) ); double ds = - d / delta; double test = s + ds; Intersection.cc // controlla che test è tra s1 e s2 if( (s1 - test) * (test - s2) < 0.0 ) { if ( s1 < s2 ) s += abs( d ); else s -= abs( d ); if( s > maxS || s < minS ) return sMax; } else s = test; if( abs(d) < accuracy ) return s; } return sMax; } Point Intersection::intersect(double s1, double s2) { return trajectory_->position(sIntersect(s1, s2)); }
{"Image DocumentName": "Intersezione: implementazione", "Image ImageDescription": "#include Intersection.h #include <math.h> #include Surface.h #include Trajectory.h const int maxIterations 20. const double sMax 1.e+6. const double accuracy1.e-3. double Intersection::sIntersect(double s1, double s2) { // algoritmo di Newton-Raphson. double s = s1; double maxS = max(s1, s2); double minS = min(s1, s2); double d, delta; for( int j = 0; j < maxIterations; j++ ) Point p = _trajectory->position( s ); d = surface_->distance( p ); delta = surface_->derDist( p, trajectory_->direction( s ) ); double ds = - d / delta; double test = s + ds; Intersection.cc. Implementazione dell\u2019algoritmo. // controlla che test \u00e8 tra s1 e s2. if( (s1 - test)   (test - s2) < 0.0 ) { if ( s1 < s2 ) s += abs( d ); else s -= abs( d ); if( s > maxS || s < minS ) return sMax; } else s = test; if( abs(d) < accuracy ) return s; Point Intersection::intersect(double s1, double s2) return. trajectory_->position(sIntersect(s1, s2)); Potenza, 16/5/2001. Luca Lista.", "Image XResolution": "37", "Image YResolution": "37", "Image ResolutionUnit": "Pixels/Centimeter", "Image Software": "SlidePlayer", "Image YCbCrPositioning": "Centered"}