Rotating the elements of a quaternion
If I turned the quaternion into a matrix I could then oad the matrix and perform the rotation.....right??
here is to make a matrix:
Note: This is for dx so you may have to swizzle the matrix order (ie row major to column major)
float wx, wy, wz, xx, yy, yz, xy, xz, zz;// xs, ys, zs; float x2,y2,z2; x2 = v.x + v.x; y2 = v.y + v.y; z2 = v.z + v.z; xx = v.x * x2; xy = v.x * y2; xz = v.x * z2; yy = v.y * y2; yz = v.y * z2; zz = v.z * z2; wx = w * x2; wy = w * y2; wz = w * z2; m[0] = 1.0f - (yy + zz); m[1] = xy - wz; m[2] = xz + wy; m[3] = 0.0f; m[0+4] = xy + wz; m[1+4] = 1.0f - (xx + zz); m[2+4] = yz - wx; m[3+4] = 0.0f; m[0+8] = xz - wy; m[1+8] = yz + wx; m[2+8] = 1.0f - (xx + yy); m[3+8] = 0.0f; m[0+12] = 0.f; m[1+12] = 0.f; m[2+12] = 0.f; m[3+12] = 1.f;
Note: This is for dx so you may have to swizzle the matrix order (ie row major to column major)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement