citro3d/source/maths/quat_fromaxisangle.c
Thompson Lee 0ce2c1398c Adding Quat_LookAt() and Quat_FromAxisAngle().
Removing excess copy/paste code.

Please check my TAU... Fixed K&R. One-liner IFs.

Changed bogus code to accept Quat_FromAxisAngle(vector, angle).
Normalized axis vector in Quat_FromAxisAngle().

Missed that little cross.

Replaced FVec4_New() with Quat_New().

* Changed bogus code to accept Quat_FromAxisAngle(vector, angle).
Normalized axis vector in Quat_FromAxisAngle().

Missed that little cross.

Replaced FVec4_New() with Quat_New().
2016-08-11 12:15:26 -04:00

10 lines
263 B
C

#include <c3d/maths.h>
C3D_FQuat Quat_FromAxisAngle(C3D_FVec axis, float angle)
{
float halfAngle = angle / 2.0f;
float scale = sinf(halfAngle);
axis = Quat_Normalize(axis);
return Quat_New(axis.x * scale, axis.y * scale, axis.z * scale, cosf(halfAngle));
}