
Home  Search Forums  Register  Forum Rules  Man Pages  Unix Commands  Linux Commands  FAQ  Members  Search  Today's Posts  Mark Forums Read 
Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here. 

Thread Tools  Search this Thread  Display Modes 
#1




awk and trig functions
dear all,
In my script, it would be ideal if I could use an arccos (inverse cos) function. I think trig functions are indeed provided by awk, but not inverse trig functions. So my question simply is: are there any alternative ways to incorporate inverse trig functions into a script? Any help greatly appreciated! Many thanks, pauli 
Sponsored Links  

#2




look here or here or here Code:
function asin(x) { return atan2(x, sqrt(1x*x)) } function acos(x) { return atan2(sqrt(1x*x), x) } function atan(x) { return atan2(x,1) } Last edited by vgersh99; 07032009 at 08:47 AM.. 
Sponsored Links  

#3




Hello,
I want to calculate distance between two GPS coordinates(Latitude A, Longitude A, Latitude B, Longitude B). By Spherical Law, the formula is: distance= ACOS ( SIN(latA) * SIN(latB) + COS(latA) * COS(latB) * COS(longBLongA)) * R where R= Radius of the earth(6371) As there is no ACOS function in awk, therefore I have to use the following method: function acos(x) { return atan2(sqrt(1x*x), x) } value = sin(latA) * sin(latB) + cos(latA) * cos(latB) * cos(longBLongA) distance = acos(value)*R But I don't know when I calculate the distance using this method, I get different value from Spherical law formula. For Spherical Law I use MS Excel to calculate the value. I need your help please.Thanks a lot. Regards, Ubee 
Sponsored Links  

Thread Tools  Search this Thread 
Display Modes  
More UNIX and Linux Forum Topics You Might Find Helpful  
Thread  Thread Starter  Forum  Replies  Last Post 
functions  TimHortons  Shell Programming and Scripting  2  04082009 10:41 AM 
Use of functions  amitrajvarma  Shell Programming and Scripting  1  11232007 05:52 AM 
ksh functions  scriptingmani  Shell Programming and Scripting  3  07062007 07:15 AM 
functions in  Raom  Shell Programming and Scripting  6  07212006 03:06 AM 
Regarding functions  sendhilmani  Shell Programming and Scripting  2  03242006 03:40 AM 
