में पर्ल प्रोग्रामिंग भाषा में बनाया गया है एक समारोह atan2()
.
का मुख्य उद्देश्य समारोह है रूपांतरण से काटीज़ियनवादी प्रणाली के समन्वय के लिए ध्रुवीय.
इस कार्यक्रम को प्रदर्शित करता है 1.26879861219712
.
my $value = atan2($y, $x);
तर्क करने के लिए पर्ल समारोह atan2()
— दो की संख्या ।
यदि कार्य atan2()
के पास नहीं है किसी भी तर्क, या पास वास्तव में एक तर्क है, यह त्रुटि होगा:
Not enough arguments for atan2 at script.pl line 3, near "atan2()"
Execution of script.pl aborted due to compilation errors.
समारोह का उपयोग करता है, डिफ़ॉल्ट चर $_
.
अगर वहाँ एक की जरूरत है इसे उपयोग करने के लिए, तो यह होना चाहिए स्पष्ट रूप से फ़ंक्शन करने के लिए दिया atan2($_, 1);
यदि कार्य atan2()
पारित कर सकते हैं और अधिक से अधिक दो तर्क, यह त्रुटि होगा:
Too many arguments for atan2 at script.pl line 3, near "3)"
Execution of script.pl aborted due to compilation errors.
समारोह atan2()
हमेशा एक नंबर देता है. atan2($y, $x)
रिटर्न arctangent से $y/$x
.
सीमा के संभव मान है -π
, के लिए π
, यानी, से -3.14159265358979
के लिए 3.14159265358979
.
यहाँ उत्पादन के आदेश perldoc -f atan2
:
atan2 Y,X
Returns the arctangent of Y/X in the range -PI to PI.
For the tangent operation, you may use the "Math::Trig::tan"
function, or use the familiar relation:
sub tan { sin($_[0]) / cos($_[0]) }
The return value for "atan2(0,0)" is implementation-defined;
consult your atan2(3) manpage for more information.
Portability issues: "atan2" in perlport.