18
$\begingroup$

I have been looking everywhere trying to find out how to convert an angle in radians (expressed as -Pi to Pi) to a heading vector.

The only [x,y] answer I have found is, [cos(angle), sin(angle)] , however, this doesn't work! Or am I missing something?

I just want a vector pointing at a direction of a specified angle, and for it to have a magnitude of 1, such is called a "heading vector" I believe. At least it is in the various game code I look at.

CLARIFICATION:

A heading vector is a vector with a magnitude of 1 with the start at 0, and the end (the arrowhead) at some value within a unit circle. A heading vector is a way of showing direction as a vector. I want to take an angle and express it as a vector, however, people seem to just be telling me how to do unit conversions.

I appreciate you trying to be helpful, however, hopefully these clarifications will guide others to giving more fitting responses.

Thanks.

  • 0
    An angle in standard position has one side on the positive x-axis, and is measured counter-clockwise. The angle for heading/bearing is measured from the positive y-axis, clockwise.2012-08-09
  • 0
    This does not answer my question.2012-08-10
  • 2
    "...this doesn't work!" - you haven't said why...2012-08-10
  • 0
    Let's stop using the word "heading". See [the picture in the top right](http://www.regentsprep.org/Regents/math/algtrig/ATT3/referenceAngles.htm) for visuals of "initial" and "terminal" sides of an angle. If you want a point that is one unit away from the origin that makes an angle $\theta$ with the positive x-axis when connected to the origin, that point is (cos $\theta$, sin $\theta$). If you want a vector, use brackets instead of parenthesis.2012-08-10
  • 0
    J.M. - It doesn't work, because I have tried it and it gives strange answers!Funny I can't find a solution to a seemingly simple problem...2012-08-10
  • 0
    Here are some examples of why the [cos(angle), sin(angle)] doesn't work: Pi gives: [-1.0, 1.2246467991473532E-16] should be: [1,0] -Pi gives: [-1.0, -1.2246467991473532E-16] should be: [1,0] (Pi/2) gives: [6.123233995736766E-17, 1.0] should be: [0,1] -(Pi/2) gives: [6.123233995736766E-17, -1.0] should be: [0,-1]2012-08-10
  • 1
    When you finally show the problem, it is clear it is a numerical problem. Unless you use a symbolic package, $\sin \pi$ does not exactly equal $0$ in part because $\pi$ is not exact.2013-02-05
  • 0
    I think the OP is searching for a unit vector. http://www.dummies.com/how-to/content/finding-the-unit-vector-of-a-vector.html2014-05-01
  • 0
    BTW, in any scientific calculator, one can confirm that (cos(Pi), sin(Pi)) is (1, 0), or values close to that, depending on the accuracy of the calculator. Verifying that OP did have the correct formula, so his problem is a calculation mistake or inaccuracy, not a math issue.2018-02-01

3 Answers 3