title: Convert an angle in degrees, to a vector
body: <p>I'm doing some game programming. FWIW I'm using XNA, but I'm doubtful that this is relevant.</p>
  
  <p>I'd like to convert degrees to a directional vector (ie X and Y) with magnitude 1.</p>
  
  <p>My origin (0,0) is in the upper left. </p>
  
  <p>So I'd like 0 degrees to convert to [0, -1]</p>
  
  <p>I thought the best way to do this was to take my definition of North/Up and rotate it using a matrix, but this does not seem to be working.</p>
  
  <p><strong>Here is the Code...</strong></p>
  
  <pre><code>public class Conversion
  {
      public static Vector2 GetDirectionVectorFromDegrees(float Degrees)
      {
          Vector2 North= new Vector2(0, -1);
          float Radians = MathHelper.ToRadians(Degrees);
  
          var RotationMatrix = Matrix.CreateRotationZ(Radians);
          return Vector2.Transform(North, RotationMatrix);
      }
  }
  </code></pre>
  
  <p><strong>... and here are my unit tests...</strong></p>
  
  <pre><code>[TestFixture]
  public class Turning_Tests
  {
      [Test]
      public void Degrees0_Tests()
      {
          Vector2 result = Conversion.GetDirectionVectorFromDegrees(0);
          Assert.AreEqual(0, result.X);
          Assert.AreEqual(-1, result.Y);
      }
      [Test]
      public void Degrees90_Tests()
      {
          Vector2 result = Conversion.GetDirectionVectorFromDegrees(90);
          Assert.AreEqual(1, result.X);
          Assert.AreEqual(0, result.Y);
      }
      [Test]
      public void Degrees180_Tests()
      {
          Vector2 result = Conversion.GetDirectionVectorFromDegrees(180);
          Assert.AreEqual(0, result.X);
          Assert.AreEqual(1, result.Y);
      }
      [Test]
      public void Degrees270_Tests()
      {
          Vector2 result = Conversion.GetDirectionVectorFromDegrees(270);
          Assert.AreEqual(-1, result.X);
          Assert.AreEqual(0, result.Y);
      }
  
  }
  </code></pre>
  
  <p>Am I approaching this all wrong?
  Should I be using a matrix?
  Have I screwed up and converted from degrees to radians in the wrong place?</p>
  
  <p>I've seen suggestions that this can be done using code like: </p>
  
  <pre><code>new Vector2((float)Math.Cos(Angle), (float)Math.Sin(Angle));
  </code></pre>
  
  <p>...or sometimes...</p>
  
  <pre><code>new Vector2((float)Math.Sin(Angle), (float)Math.Cos(Angle));
  </code></pre>
  
  <p>However these don't seem to work either </p>
  
  <p><strong>Can someone put me on the right path... or better yet give me some code which causes the 4 provided unit tests to path?</strong></p>
  
  <p>Many thanks in advance.</p>