Revision a2e6a2b1dd1da48e502fc25126aa9b8a139ed543 authored by GUANGMING ZANG on 13 August 2018, 08:44:48 UTC, committed by GitHub on 13 August 2018, 08:44:48 UTC
1 parent 80d039c
Quaternion.cpp
#include "Quaternion.h"
Quaternion::Quaternion()
{
Identity();
}
Quaternion::Quaternion(float ax, float ay, float az, float angle)
{
float xx,yy,zz;
float rad, scale;
float length;
length = sqrtf(ax*ax+ay*ay+az*az);
if (0.0f==length) // if axis is zero, then return Quaternion (1,0,0,0)
{
w = 1.0f;
x = 0.0f;
y = 0.0f;
z = 0.0f;
return;
}
float lenInv=1.0f/length;
xx = ax *lenInv;
yy = ay *lenInv;
zz = az *lenInv;
rad = angle / 2;
w = cosf(rad);
scale = sinf(rad);
x = xx * scale;
y = yy * scale;
z = zz * scale;
//Change by GM, test rotation.
//x=0;
//y=0;
//z=0;
}

Computing file changes ...