{I+=codeWee;}
[C++] Math: Quaternion from Direction Vector
This is Pseudo Code:

struct Quaternion
{
	float x, y, z, w;



void FromDirectionVector(const _In_ Vector3& dir, const  _In_ Vector3& up, const _In_ Vector3& right)
{
	float _11n = right.x;
	float _12n = right.y;
	float _13n = right.z;
	float _21n = up.x;
	float _22n = up.y;
	float _23n = up.z;
	float _31n = dir.x;
	float _32n = dir.y;
	float _33n = dir.z;
	w = sqrt(1.0f + _11n + _22n + _33n) / 2.0f;
	float w4 = (4.0f * w);
	if (w4 != 0)
	{
		x = (_32n - _23n) / w4;
		y = (_13n - _31n) / w4;
		z = (_21n - _12n) / w4;
	}

}

};
HTML | PHP | C++ | DirectX11 | Javascript | C# | HTML5 | ASP | SQL | General | CSS | Oculus Rift | Unity3d | Virtools SDK | Tip | NSIS | PowerShell | node.js | Web API | RTSP | All
Copyright© 2016 CodeWee.com All rights reserved.