aboutsummaryrefslogtreecommitdiff
path: root/files/pl/web/javascript/referencje/obiekty/math/atan2/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/pl/web/javascript/referencje/obiekty/math/atan2/index.html')
-rw-r--r--files/pl/web/javascript/referencje/obiekty/math/atan2/index.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/files/pl/web/javascript/referencje/obiekty/math/atan2/index.html b/files/pl/web/javascript/referencje/obiekty/math/atan2/index.html
new file mode 100644
index 0000000000..81f4606036
--- /dev/null
+++ b/files/pl/web/javascript/referencje/obiekty/math/atan2/index.html
@@ -0,0 +1,63 @@
+---
+title: Math.atan2()
+slug: Web/JavaScript/Referencje/Obiekty/Math/atan2
+tags:
+ - JavaScript
+ - Math
+ - Method
+translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan2
+---
+<p>{{JSRef}}</p>
+
+<h2 id="Podsumowanie" name="Podsumowanie">Podsumowanie</h2>
+
+<p>Zwraca kąta (w radianach) utworzony przez oś OX i prostą przechodzącą przez punkt o podanych współrzędnych.</p>
+
+<h2 id="Sk.C5.82adnia" name="Sk.C5.82adnia">Składnia</h2>
+
+<pre class="syntaxbox"><code>Math.atan2(<var>y</var>, <var>x</var>)</code></pre>
+
+<h3 id="Parametry" name="Parametry">Parametry</h3>
+
+<dl>
+ <dt><code>y, x</code> </dt>
+ <dd>liczby.</dd>
+</dl>
+
+<h2 id="Opis" name="Opis">Opis</h2>
+
+<p>Metoda <code>atan2</code> zwraca wartość liczbową pomiędzy -π a π, reprezentującą kąt theta punktu <code>(x, y)</code>. Kąt ten, mierzony w radianach, został utworzony przez dodatnią oś OX i punkt <code>(x,y)</code>, z obrotem w kierunku przeciwnym do ruchu wskazówek zegara. Należy zwrócić uwagę na to, że pierwszym argumentem tej funkcji jest współrzędna y, a x jest argumentem drugim.</p>
+
+<p>Do metody Math.<code>atan2</code>() przekazywane są osobno argumenty <code>x</code> i <code>y</code>, podczas gdy do metody <code>atan</code> przekazywany jest stosunek tych dwóch wartości.</p>
+
+<p>Ponieważ <code>atan2()</code> jest statyczną metodą obiektu {{jsxref("Math")}}, zawsze odwołujemy się do niej poprzez <code>Math.atan2()</code>, a nie jak do metody instancji obiektu Math utworzonej przez użytkownika.</p>
+
+<h2 id="Przyk.C5.82ady" name="Przyk.C5.82ady">Przykłady</h2>
+
+<h3 id="Przyk.C5.82ad:_Zastosowanie_Math.atan2" name="Przyk.C5.82ad:_Zastosowanie_Math.atan2">Przykład: Zastosowanie <code>Math.atan2()</code></h3>
+
+<pre class="brush: js language-js"><code class="language-js">Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span><span class="token number">90</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment"> // 1.4056476493802699
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span><span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">90</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment"> // 0.16514867741462683
+</span>
+Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">0</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±PI.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">0</span><span class="token punctuation">,</span> <span class="token operator">+</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">0</span><span class="token punctuation">,</span> <span class="token operator">-</span>x<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±PI for x &gt; 0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">0</span><span class="token punctuation">,</span> x<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±0 for x &gt; 0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span><span class="token operator">-</span>y<span class="token punctuation">,</span> ±<span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // -PI/2 for y &gt; 0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>y<span class="token punctuation">,</span> ±<span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // PI/2 for y &gt; 0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±y<span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">Infinity</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±PI for finite y &gt; 0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±y<span class="token punctuation">,</span> <span class="token operator">+</span><span class="token number">Infinity</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±0 for finite y &gt; 0.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">Infinity</span><span class="token punctuation">,</span> x<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment"> // ±PI/2 for finite x.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">Infinity</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">Infinity</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment"> // ±3*PI/4.
+</span>Math<span class="token punctuation">.</span><span class="token function">atan2<span class="token punctuation">(</span></span>±<span class="token number">Infinity</span><span class="token punctuation">,</span> <span class="token operator">+</span><span class="token number">Infinity</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment"> // ±PI/4.</span></code></pre>
+
+<h2 id="Zobacz_tak.C5.BCe" name="Zobacz_tak.C5.BCe">Zobacz także</h2>
+
+<ul>
+ <li>{{jsxref("Math.acos()")}}</li>
+ <li>{{jsxref("Math.asin()")}}</li>
+ <li>{{jsxref("Math.atan()")}}</li>
+ <li>{{jsxref("Math.cos()")}}</li>
+ <li>{{jsxref("Math.sin()")}}</li>
+ <li>{{jsxref("Math.tan()")}}</li>
+</ul>