Files Classes Functions Hierarchy
00001 #include <angles.h> 00002 #include <mathlib.h> 00003 00004 00005 doublec angles::radtodeg = 180.0/PI; 00006 doublec angles::degtorad = 1.0/radtodeg; 00007 00008 doublec angles::circlemapto( doublec x, doublec y ) 00009 { 00010 point2<double> X(x,y); 00011 return circlemapto(X); 00012 } 00013 00014 doublec angles::circlemapto( point2<double> const & X ) 00015 { 00016 doublec d = X.distance(); 00017 if (zero<double>::test(d)) 00018 return 0.0; 00019 00020 point2<double> X2(X); 00021 X2 /= d; 00022 00023 return circleunit(X2); 00024 } 00025 00026 doublec angles::circleunit( point2<double> const & X ) 00027 { 00028 assert(zero<double>::test(X.x*X.x+X.y*X.y-1.0)); 00029 00030 double theta = abs(asin(X.y)); 00031 if (X.x<0.0) 00032 { 00033 if (X.y<0.0) 00034 { 00035 // Quadrant 3 00036 00037 return theta + PI; 00038 } 00039 00040 // Quadrant 2 00041 return PI - theta; 00042 } 00043 00044 // Quadrant 4 00045 if (X.y<0.0) 00046 return -theta+PI*2.0; 00047 00048 // Quadrant 1 00049 return theta; 00050 } 00051 00052 /* 00053 // KEEP Chelton 2007-04-09 00054 void angles::rotationsxy 00055 ( 00056 double & rotx, 00057 double & roty, 00058 point3<double> const & X 00059 ) 00060 { 00061 roty = angles::circlemapto(X.z,X.x); 00062 rotx = - angles::circlemapto(X.z,X.y); 00063 } 00064 */ 00065 00066 void angles::rotateaboutaxis 00067 ( 00068 double & theta, 00069 point3<double> & axis, 00070 point3<double> const & nml 00071 ) 00072 { 00073 static point3<double> const zaxis(0.0,0.0,1.0); 00074 00075 point3<double> normal(nml); 00076 normal.normalize(); 00077 00078 // If nml coincies with the z axis no change necessary. 00079 if (zero<double>::test((zaxis-normal).dot())) 00080 { 00081 theta=0.0; 00082 return; 00083 } 00084 00085 crossproduct::evalxyz(axis,zaxis,normal); 00086 theta = acos(normal.z); 00087 } 00088 00089
1.5.8