title: Draw square with polar coordinates
body: <p>I have a square, where the closest points are 1 unit away from the center. See my ascii diagram below:</p>
  
  <pre><code>+-----------+
  |           |
  |  x        |
  |-----+     |
  |           |
  |           |
  +-----------+
  </code></pre>
  
  <p>Therefore, the distance from the origin to the corners is the sqrt(2). I need a function that returns the distance from the origin to a point on the square at any angle. For example, for an input of 0, the function would return 1. For an input of 45, the function would return the distance to a corner, the square root of 2. Then for 90, it would return 1 again.</p>
  
  <p>In other words, when you graph the function with polar graphing, it will draw a square.</p>
  
  <p>I believe that the function would be something like this:</p>
  
  <pre><code>f(x) = sqrt(tan(x)^2+1)
  </code></pre>
  
  <p>The only problem is that the function above will not graph the sides of the square. I need something that draws all 4 sides.</p>
  
  <p>I know that there is a trigonometric function for something similar to this, but I will be using this function in javascript, so I will only be able to use the standard trigonometry functions.</p>
  
  <p>Any help will be appreciated. Thanks in advance.</p>