|
void Mat4::setRotation(const Quat& q)
{
f32 d = q.length2(); // f32 Quat::length2() const{return dot(*this);}
f32 s = 2.0f / d;
f32 xs = q.x * s, ys = q.y * s, zs = q.z * s;
f32 wx = q.w * xs, wy = q.w * ys, wz = q.w * zs;
f32 xx = q.x * xs, xy = q.x * ys, xz = q.x * zs;
f32 yy = q.y * ys, yz = q.y * zs, zz = q.z * zs;
setValue(
1.0f - (yy + zz), xy - wz, xz + wy,
xy + wz, 1.0f - (xx + zz), yz - wx,
xz - wy, yz + wx, 1.0f - (xx + yy));
}
void Mat4::setValue(f32 xx, f32 xy, f32 xz,
f32 yx, f32 yy, f32 yz,
f32 zx, f32 zy, f32 zz)
{
m_data[0].set(xx, xy, xz, 0.f); // vec4
m_data[1].set(yx, yy, yz, 0.f); // vec4
m_data[2].set(zx, zy, zz, 0.f); // vec4
}
|
|