![]() |
|
Formula for converting angle to vector? - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Game Programming Fundamentals (/forum-7.html) +--- Thread: Formula for converting angle to vector? (/thread-9221.html) |
Formula for converting angle to vector? - komirad - Jul 29, 2011 12:34 AM Hi guys Basic game math help needed. I need a formula to convert an angle in to (x, y). For example 135 deg = (1, 1) and 90 = (1, 0)
RE: Formula for converting angle to vector? - sealfin - Jul 29, 2011 04:25 AM Code: double XComponentOfVector( const double p_direction, const double p_magnitude )...and... Code: double YComponentOfVector( const double p_direction, const double p_magnitude )RE: Formula for converting angle to vector? - ThemsAllTook - Jul 29, 2011 07:29 AM sin and cos are what you want. If your angles are in degrees, remember to convert to radians first. Also note that 135 degrees in your example will be {0.707106781186548, 0.707106781186548}, not {1, 1}; if you want square coordinates rather than circular ones, you'll need to do something like divide both numbers by the larger of the two. |