00001 /************************************************************************ 00002 * * 00003 * Copyright 2004, Brown University, Providence, RI * 00004 * * 00005 * Permission to use and modify this software and its documentation * 00006 * for any purpose other than its incorporation into a commercial * 00007 * product is hereby granted without fee. Recipient agrees not to * 00008 * re-distribute this software or any modifications of this * 00009 * software without the permission of Brown University. Brown * 00010 * University makes no representations or warrantees about the * 00011 * suitability of this software for any purpose. It is provided * 00012 * "as is" without express or implied warranty. Brown University * 00013 * requests notification of any modifications to this software or * 00014 * its documentation. Notice should be sent to: * 00015 * * 00016 * To: * 00017 * Software Librarian * 00018 * Laboratory for Engineering Man/Machine Systems, * 00019 * Division of Engineering, Box D, * 00020 * Brown University * 00021 * Providence, RI 02912 * 00022 * Software_Librarian@lems.brown.edu * 00023 * * 00024 * We will acknowledge all electronic notifications. * 00025 * * 00026 ************************************************************************/ 00027 00028 #ifndef BI_ARC_H 00029 #define BI_ARC_H 00030 00031 #include "points.h" 00032 #include "angles.h" 00033 00034 #define eA 0.0001 //Epsilon for angles 00035 #define eK 0.0001 //Epsilon for curvature 00036 #define K_LARGE 100000 //large curvature value 00037 00038 class BiArcParams 00039 { 00040 public: 00041 int flag; //0:single arc, 1:biarc 00042 00043 Point2D<double> start_pt; 00044 Point2D<double> end_pt; 00045 00046 double start_angle; 00047 double end_angle; 00048 00049 double K1; 00050 double K2; 00051 00052 double L1; 00053 double L2; 00054 00055 double E; //energy 00056 00057 double R1; 00058 double R2; 00059 00060 int dir1; 00061 int dir2; 00062 00063 Point2D<double> mid_pt; 00064 Point2D<double> center1; 00065 Point2D<double> center2; 00066 00067 BiArcParams() 00068 { 00069 flag = 0; 00070 00071 start_angle = 0; 00072 end_angle = 0; 00073 00074 K1 = 0; 00075 K2 = 0; 00076 00077 L1 = 0; 00078 L2 = 0; 00079 00080 dir1 = 0; 00081 dir2 = 0; 00082 00083 R1 = 0; 00084 R2 = 0; 00085 00086 E = 0; 00087 00088 }; 00089 00090 ~BiArcParams(){}; 00091 00092 BiArcParams( const BiArcParams &rhs) 00093 { 00094 start_pt = rhs.start_pt; 00095 end_pt = rhs.end_pt; 00096 00097 start_angle = rhs.start_angle; 00098 end_angle = rhs.end_angle; 00099 00100 K1 = rhs.K1; 00101 K2 = rhs.K2; 00102 00103 L1 = rhs.L1; 00104 L2 = rhs.L2; 00105 00106 mid_pt = rhs.mid_pt; 00107 center1 = rhs.center1; 00108 center2 = rhs.center2; 00109 00110 dir1 = rhs.dir1; 00111 dir2 = rhs.dir2; 00112 00113 R1 = rhs.R1; 00114 R2 = rhs.R2; 00115 00116 flag = rhs.flag; 00117 E = rhs.E; 00118 00119 }; 00120 00121 BiArcParams& operator=(const BiArcParams &rhs) 00122 { 00123 if (this!=&rhs){ 00124 start_pt = rhs.start_pt; 00125 end_pt = rhs.end_pt; 00126 00127 start_angle = rhs.start_angle; 00128 end_angle = rhs.end_angle; 00129 00130 K1 = rhs.K1; 00131 K2 = rhs.K2; 00132 00133 L1 = rhs.L1; 00134 L2 = rhs.L2; 00135 00136 mid_pt = rhs.mid_pt; 00137 center1 = rhs.center1; 00138 center2 = rhs.center2; 00139 00140 dir1 = rhs.dir1; 00141 dir2 = rhs.dir2; 00142 00143 R1 = rhs.R1; 00144 R2 = rhs.R2; 00145 00146 flag = rhs.flag; 00147 E = rhs.E; 00148 } 00149 return *this; 00150 } 00151 00152 //total arclength 00153 double L(){return (L1+L2);} 00154 00155 void scale (double factor) 00156 { 00157 K1 /=factor; 00158 L1 *=factor; 00159 00160 K2 /=factor; 00161 L2 *=factor; 00162 } 00163 }; 00164 00165 class BiArc 00166 { 00167 public: 00168 BiArcParams params; 00169 00170 BiArc(){} 00171 BiArc(Point2D<double> start_pt, double start_angle, Point2D<double> end_pt, double end_angle) 00172 { 00173 params.start_pt = start_pt; 00174 params.start_angle = angle0To2Pi(start_angle); 00175 00176 params.end_pt = end_pt; 00177 params.end_angle = angle0To2Pi(end_angle); 00178 00179 //since we have all the parameters, we might as well compute it 00180 compute_biarc_params(); 00181 } 00182 00183 ~BiArc(){} 00184 00185 void compute_biarc_params (); 00186 void compute_other_stuff (); 00187 double compute_join_theta (double k1, double k2); 00188 double compute_arclength (double theta0, double theta2, double k); 00189 00190 void set_start_params(Point2D<double> start_pt, double start_angle) 00191 { 00192 params.start_pt = start_pt; 00193 params.start_angle = angle0To2Pi(start_angle); 00194 } 00195 00196 void set_end_params(Point2D<double> end_pt, double end_angle) 00197 { 00198 params.end_pt = end_pt; 00199 params.end_angle = angle0To2Pi(end_angle); 00200 } 00201 }; 00202 00203 #endif
1.5.6