jawaidpk Posted April 16, 2008 Share Posted April 16, 2008 Hi Friends, well I got a problem while using inverse trigonometric functions like atan, asin etc. in fact the formula which I am using assumed all the calculations would be done in degrees while PHP assumes the input to be provided to the trigonometric functions is Radians. I guess most of you would be thinking about to suggest me to use deg2rad() function, but I think its not the solution. for example in degrees atan(0.4423) = 23.8598 but in PHP atan(deg2rad(0.4423)) = 0.0077 I need 23.8598 as my answer as I have to use it in the upcoming calculations. if any body can tell me from where I could get those trigonometric functions in PHP which accepts degree as argument rather than radians then it would solve my overall problems. Otherwise it would also be acceptable if anybody can tell me how can I get the same result by using existing atan() and deg2rad or rad2deg functions. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/101387-help-needed-regarding-inverse-trigonometric-functions-in-php-asin-acos-etc/ Share on other sites More sharing options...
Zhadus Posted April 16, 2008 Share Posted April 16, 2008 You almost have it correct. atan() outputs in radians, you don't put the argument in radians. e.g. $arg = 0.4423; $val = deg2rad(atan($arg)); echo $val; // = 23.8598; Link to comment https://forums.phpfreaks.com/topic/101387-help-needed-regarding-inverse-trigonometric-functions-in-php-asin-acos-etc/#findComment-518582 Share on other sites More sharing options...
Barand Posted April 16, 2008 Share Posted April 16, 2008 <?php $arg = 0.4423; // tangent value echo rad2deg(atan($arg)); // angle converted to degrees = 23.8598 ?> Link to comment https://forums.phpfreaks.com/topic/101387-help-needed-regarding-inverse-trigonometric-functions-in-php-asin-acos-etc/#findComment-518760 Share on other sites More sharing options...
Zhadus Posted April 16, 2008 Share Posted April 16, 2008 Ack, yeah Barand's is correct. I typoed the rad2deg function. Link to comment https://forums.phpfreaks.com/topic/101387-help-needed-regarding-inverse-trigonometric-functions-in-php-asin-acos-etc/#findComment-518764 Share on other sites More sharing options...
jawaidpk Posted April 17, 2008 Author Share Posted April 17, 2008 Hi Zhadus, Barand Thanks buddies, I did'nt read the documentation properly, but your help have resolved my issue. Thanks Jawed Islam Link to comment https://forums.phpfreaks.com/topic/101387-help-needed-regarding-inverse-trigonometric-functions-in-php-asin-acos-etc/#findComment-519257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.