For Programmers: Free Programming Magazines  


Home > Archive > Tcl > May 2006 > Inverse sin/cos/tan









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Inverse sin/cos/tan
chawki@surpac.com

2006-05-24, 10:04 pm

Hello.

Please excuse what must be a silly question. :)

I have values that represent sin & cos of an angle. I need to compute
the angle itself. How do I use the 'expr' command to calculate inverse
sin?

Thanks,
CJ

suchenwi

2006-05-24, 10:04 pm

% expr asin(sin(1.2345))
1.2345
% expr acos(cos(1.2345))
1.2345

neil mckay

2006-05-24, 10:04 pm

If you have values for both sin AND cos, you can use atan2:

% set s [expr {sin(1.2345)}]
0.943983323945
% set c [expr {cos(1.2345)}]
0.329993157679
% expr {atan2($s,$c)}
1.2345

This will guarantee that the angle's in the right quadrant.

Neil

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com