function invtan(y_inv){ x = y_inv; if(y_inv > 100 ) theta = 1.570796326795 - 1.0 / y_inv; else if(y_inv > 1.0) x = 0.7853981633974 + (y_inv - 1.0) * 0.5 ; else if(y_inv < -1.0) x = -0.7853981633974 + (y_inv + 1.0) * 0.5 ; else x = 0.9 * y_inv; if(x > 1.570796326795) x = 1.57; if(x < -1.570796326795) x = -1.57; for(var n=0;n<8;n=n+1) x = x + (y_inv - Math.tan(x)) / (1.0 + Math.tan(x)*Math.tan(x)); arg = x * 57.29577951308; return x; } function arctan(absissa,ordinate) { var theta = 1.570796326795; var temp = ordinate / absissa ; if(temp > 100 ) theta = 1.570796326795 - 1.0 / temp; else if(temp < -100 ) theta = -1.570796326795 - 1.0 / temp; else { if(absissa*absissa < 0.00000001) {theta = 1.57 ; if(ordinate < 0 ) theta = - theta ; document.bgColor = "804040"; return theta;} if(absissa>0) {theta = invtan(ordinate / absissa); document.bgColor = "208060";} else {theta = 3.14159265359 - invtan( ordinate / -absissa); document.bgColor = "604020";} } return theta; } /* f(x)=sin(x) f'(x)= cos(x) f(x)=cos(x) f'(x)=-sin(x) f(x)=tan(x) f'(x)= 1+tan(x)**2 return x; */ function arcsin(sin_ratio) { x = sin_ratio; if(sin_ratio <= 1.0 && sin_ratio >= -1.0) for(var n=0;n<8;n=n+1) x = x + (sin_ratio - Math.sin(x)) / Math.cos(x); else err_flag = true; // arg_deg = x * 57.29577951308; return x;} function arcsin_(sin_ratio) { x = 3.14159265359 - sin_ratio; // quad_two if(sin_ratio <= 1.0 && sin_ratio >= -1.0) for(var n=0;n<8;n=n+1) x = x + (sin_ratio - Math.sin(x)) / Math.cos(x); else err_flag = true; // arg_deg = x * 57.29577951308; return x;} // for quad_neg use x - 2.0 * 3.14159265359 function arccos(cos_ratio){ x = 1.570796326795*(1.0 - cos_ratio); if( cos_ratio <= 1.0 && cos_ratio >= -1.0) for(var n=0;n<8;n=n+1) x = x - (cos_ratio - Math.cos(x)) / Math.sin(x); else err_flag = true; arg_deg = x * 57.29577951308; return x; } function arccos_(cos_ratio){ x = -1.570796326795*(1.0 - cos_ratio); if( cos_ratio <= 1.0 && cos_ratio >= -1.0) for(var n=0;n<8;n=n+1) x = x - (cos_ratio - Math.cos(-x)) / Math.sin(x); else err_flag = true; arg_deg = x * 57.29577951308; return x; } /* -+ ++ -- +- */ function a_sign(v_polar,if_pos,if_neg){ the_sign = v_polar / Math.sqrt(v_polar * v_polar); the_one = (the_sign + 1.0 )*0.5*if_pos - ( the_sign - 1.0 )*0.5*if_neg ; return the_one;} xi_sin = 0.5 ; // xi_sin = Math.sqrt(v_sin * v_sin) / v_sin ; // xi_sin = 0.5 * xi_sin + 0.5; // NaN xi_sin = Math.sqrt(v_sin * v_sin) / v_sin ; xi_sin = 0.5 * xi_sin + 0.5; xi_cos = Math.sqrt(v_cos * v_cos) / v_cos ; xi_cos = 0.5 * xi_cos + 0.5; xi_pos = xi_sin * xi_cos; xi_neg = (1.0 - xi_sin) * (1.0 - xi_cos); xi_two = xi_sin * (1.0 - xi_cos); xi_cap = (1.0 - xi_sin) * xi_cos; if(v_sin > 0){if(v_cos > 0) quad_pos = true; else quad_two = true;} else {if(v_cos > 0) quad_cap = true; else quad_neg = true;} if( v_sin > 0 && v_cos > 0) quad_pos = true; if( 10 * v_sin < 0 && 10 * v_cos < 0) quad_neg = true; if( v_sin > 0 && v_cos < 0) quad_two = true; if( 10 * v_sin < 0 && 10 * v_cos > 0) quad_cap = true; quad_neg=( v_sin < 0 && v_cos < 0)?true:false; if(new_sin){ if(v_sin < 1.0 && v_sin > -1.0) theta = 1.570796326795 * v_sin; else if(v_sin < -1.0) theta = -1.570796326795; else theta = 1.570796326795; theta = arcsin(v_sin); // the_sign_cos = v_cos / Math.sqrt(v_cos * v_cos) ; // the_sign_sin = v_sin / Math.abs(v_sin) ; // if(v_cos < 0) {if(v_sin > 0) theta = 3.14159265359 - arcsin(v_sin); // else theta = -3.14159265359 + arcsin(-v_sin);} // theta = (1.0 - the_sign_cos) * the_sign_sin * 1.570796326795 + arcsin(v_sin); // theta = 1.0 - the_sign_cos ; // theta = theta * the_sign_sin ; // theta = theta * 1.570796326795 ; // theta = theta + arcsin(v_sin) ; theta = a_sign(v_sin, 3.14159265359 - arcsin(v_sin), -3.14159265359 + arcsin(- v_sin)); theta = a_sign(v_cos,arcsin(v_sin),theta); // // if(v_sin > 0) // // {if(v_cos> 0) theta = arcsin(v_sin); // // else theta = 3.14159265359 - arcsin(v_sin);} // // else // // {if(v_cos> 0) theta = - arcsin(-v_sin); // // else theta = -3.14159265359 + arcsin(-v_sin);} }else if(new_cos){ // theta = 2.0 * 1.570796326795 - 1.570796326795 * (v_cos + 1); if(v_cos < 1.0 && v_cos > -1.0) theta = 1.570796326795 - 1.570796326795 * v_cos ; else if(v_cos < -1.0) theta = 2.0 * 1.570796326795; else theta = 0.0; theta = arccos(v_cos); // if(quad_cap) theta = - theta; // if(quad_neg) theta = - theta; // theta=( v_sin < 0 && v_cos < 0)?-theta:theta; theta=(quad_neg)?-theta:theta; theta=(quad_cap)?-theta:theta; // if(v_sin < 0) {theta = - arccos(v_cos);} //never // theta = a_sign(v_sin,theta, - theta); // the_sign_cos = Math.abs(v_cos) / v_cos ; // the_sign_sin = Math.abs(v_sin) / v_sin ; // theta = the_sign_sin * theta; // if(v_cos > 0) // {if(v_sin > 0) theta = 1.570796326795 - arcsin(v_cos); // else theta = 3.14159265359 - arccos(v_cos);} // else // {if(v_sin> 0) theta = 3.14159265359 - arccos(-v_cos); // else theta = -3.14159265359 + arccos(-v_cos);} }else if(new_tan){ if(v_tan < 1.0 && v_tan > -1.0) theta = 1.570796326795 * v_tan; else if(v_tan < -1.0) theta = -1.570796326795; else theta = 1.570796326795; theta = arctan(1.0,v_tan); // if(theta.substring(0,1) == "N") {theta = 0.0; document.bgColor = "D01010";} } /* http://www-rak.sggw.waw.pl/info/java/methods.htm#atan_method http://www.pageresource.com/jscript/jmath.htm Math.atan() in radians */ /* http://www.mathworks.co.uk/access/helpdesk_r11/help/techdoc/ref/atan.shtml taninv(z) =(i/2)*log((i+z)/(i-z)) tanhinv(z)=(1/2)*log((1+z)/(1+z)) */