title: Converting Cartesian Coordinates To Polar Coordinates - Matlab
body: <p>I'm having a problem throughout the conversion process of converting Cartesian to Polar, then back to Cartesian in order to confirm that my initial conversion was successful.</p>
  
  <p>But, for some reason when I am converting back to Cartesian coordinates with Polar coordinates from the third quadrant, my <code>x</code> and <code>y</code> values are the wrong way around.</p>
  
  <p>Take this part of my code for instance:</p>
  
  <pre><code>x = -2.075548439;
  y = -2.481775416;
  
  if x &lt; 0 &amp;&amp; y &lt; 0 % QUAD 3
  
      radius = sqrt( (x^2) + (y^2) );
      theta = atand( (y*-1)/(x*-1) );
      theta = (270 - theta);
  end
  
  x = radius * cosd(theta); 
  y = radius * sind(theta);
  
  % answer: x = -2.481775416, and y = -2.075548439
  </code></pre>
  
  <p>All other <code>x</code> and <code>y</code> conversions that fall within the other three quadrants put <code>x</code> and <code>y</code> back in the correct order.</p>
  
  <p>This part of the code, however, does put <code>x</code> and <code>y</code> back in the correct order:</p>
  
  <pre><code>x = 3.130287009;
  y = -0.50613326;
  
  if x &gt; 0 &amp;&amp; y &lt; 0 % QUAD 4
  
      radius = sqrt( (x^2) + (y^2) );
      theta = atand( (y*-1)/(x) );
      theta = (360 - theta);
  end
  
  x = radius * cosd(theta); 
  y = radius * sind(theta);
  
  % answer: x = 3.130287009, and y = -0.50613326
  </code></pre>