# 2D vector to Quaternion

I have a 2D vector (with only X and Y), and my engine only supports orientation through Quaternions.

How do I translate a 2D vector to a quaternion?

The X and Y represent the direction (so X = 0 and Y=1 means going forward, X=0.707 and Y=0.707 means rotate 45 degree, etc).

• What library is it? Are you sure it doesn't have any interchange methods? Commented Jul 29, 2013 at 21:07
• Ogre3D, and I have no idea what methods to use Commented Jul 29, 2013 at 21:13

## 1 Answer

void Ogre::Quaternion::FromAngleAxis(
const Radian & rfAngle, const Vector3 & rkAxis )


Your rkAxis will always be UnitZ, because you are constraining yourself to the X-Y plane.

• and the angle? How do I find it? Commented Jul 29, 2013 at 21:20
• It's the angle of rotation, and it is arbitrary. Commented Jul 29, 2013 at 21:22
• But how do I find the angle from a 2D vector? Commented Jul 29, 2013 at 21:23
• You have some options there, but it will probably involve arctangent Commented Jul 29, 2013 at 21:25
• it is better to store the rotation/orientation and calculate the direction from it if possible Commented Jul 29, 2013 at 22:49