<p>I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians.</p>

<p>I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var z?  A solution in either AS3 or psuedocode would be very helpful. Thanks.</p>

<p><img src="https://i.stack.imgur.com/B0nfz.jpg" alt="triangle"></p>

[{'answer_id': 56126, 'author': 'Patrick', 'author_id': 429, 'author_profile': 'https://Stackoverflow.com/users/429', 'pm_score': 2, 'selected': False, 'text': "<p>z is equivalent to 180 - angle of yH. Or: </p>\n\n<pre><code>180 - arctan(x/y) //Degrees\npi - arctan(x/y) //radians\n</code></pre>\n\n<p>Also, if actionscript's math libraries have it, use arctan2, which takes both the x and y and deals with signs correctly.</p>\n"}, {'answer_id': 56131, 'author': 'Blorgbeard', 'author_id': 369, 'author_profile': 'https://Stackoverflow.com/users/369', 'pm_score': 0, 'selected': False, 'text': '<p>What @Patrick said, also the hypotenuse is <code>sqrt(x^2 + y^2)</code>.</p>\n'}, {'answer_id': 56239, 'author': 'Vincent Robert', 'author_id': 268, 'author_profile': 'https://Stackoverflow.com/users/268', 'pm_score': 1, 'selected': False, 'text': "<p>The angle you want is the same as the angle opposed to the one wetween y and h.</p>\n\n<p>Let's call <code>a</code> the angle between <code>y</code> and <code>h</code>, the angle you want is actually <code>180 - a</code> or  <code>PI - a</code> depending on your unit (degrees or radians).</p>\n\n<p>Now geometry tells us that:</p>\n\n<pre><code>cos(a) = y/h\nsin(a) = x/h\ntan(a) = x/y\n</code></pre>\n\n<p>Using tan(), we get:</p>\n\n<pre><code>a = arctan(x/y)\n</code></pre>\n\n<p>As we are looking for 180 - a, you should compute:</p>\n\n<pre><code>180 -  arctan(x/y)\n</code></pre>\n"}, {'answer_id': 57362, 'author': 'grapefrukt', 'author_id': 914, 'author_profile': 'https://Stackoverflow.com/users/914', 'pm_score': 4, 'selected': True, 'text': "<p>What you need is this:</p>\n\n<pre><code>var h:Number = Math.sqrt(x*x + y*y);\nvar z:Number = Math.atan2(y, x);\n</code></pre>\n\n<p>That should give you the angle in radians, you might need to swap x/y and possibly add or remove 90 degrees but it should do the trick! (Note that you don't even need <strong>h</strong> to get <strong>z</strong> when you're using atan2)</p>\n\n<p>I use multiplication instead of Math.pow() just because Math is pretty slow, you can do:</p>\n\n<pre><code>var h:Number = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));\n</code></pre>\n\n<p>And it should be exactly the same.</p>\n"}]
['https://Stackoverflow.com/questions/56118', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/192/']