![]() |
RTXI 1.3
|
00001 // 00002 // File = sd_filt.cpp 00003 // 00004 00005 #include <fstream> 00006 #include <math.h> 00007 #include "sd_theor.h" 00008 #include "misdefs.h" 00009 00010 #ifdef _DEBUG 00011 extern std::ofstream DebugFile; 00012 #endif 00013 00014 void SteepestDescentTheoretic( double start_pt_0, 00015 double start_pt_1, 00016 double mu, 00017 int num_pts, 00018 double min_dist) 00019 { 00020 int n; 00021 double w0, w1, old_w0, old_w1, grad_0, grad_1; 00022 double dist, radius, angle, deg_per_rad; 00023 std::cout << "in SteepestDescentTheoretic" << std::endl; 00024 ofstream out_file("sd_traj.txt", ios::out); 00025 00026 deg_per_rad = 180.0/PI; 00027 w0 = start_pt_0; 00028 w1 = start_pt_1; 00029 old_w0 = w0; 00030 old_w1 = w1; 00031 out_file << "0, " << old_w0 << ", " << old_w1 << std::endl; 00032 00033 for(n=1; n<num_pts; n++) 00034 { 00035 grad_0 = 2.0 * (w0 + (w1 - 1.0)/3.0); 00036 grad_1 = 2.0*w1 + (2.0*w0/3.0) + 1.2; 00037 w0 -= mu * grad_0; 00038 w1 -= mu * grad_1; 00039 dist = sqrt( (w0-old_w0)*(w0-old_w0) + 00040 (w1-old_w1)*(w1-old_w1)); 00041 if(dist < min_dist) continue; 00042 radius = sqrt(w0*w0 + w1*w1); 00043 angle = deg_per_rad * atan2(w1, w0); 00044 out_file << n << ", " << w0 << ", " << w1 << std::endl; 00045 old_w0 = w0; 00046 old_w1 = w1; 00047 } 00048 out_file.close(); 00049 } 00050 00051