Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- //I want to rotate this vector about the x axis by PI/2 radians:
- Quaternion v(0, 1, 0, 0);
- v.normalize();
- float angle = PI / 2.0f;
- float cos = math::cos(angle / 2.0f);
- float sin = math::sin(angle / 2.0f);
- Quaternion q(1.0f*sin, 0.0f*sin, 0.0f*sin, cos);
- std::cout << "q not normalized = " <<"t"<< q.x << " " << q.y << " " << q.z << " " << q.w << std::endl;
- q.normalize();
- std::cout << "q normalized = " <<"tt"<< q.x << " " << q.y << " " << q.z << " " << q.w << std::endl;
- std::cout << std::endl;
- Quaternion r;
- //I multiply the vector v by the quaternion v, then I multiply by the conjugate.
- r = q * v;
- //do I need to normalize here?
- r = r * q.conjugate();
- //and here?
- //shouldn't the resulting vector be 0,0,1?
- std::cout << "r not normalized = " << "t" << r.x << " " << r.y << " " << r.z << " " << r.w << std::endl;
- r.normalize();
- std::cout << "r normalized = " << "tt" << r.x << " " << r.y << " " << r.z << " " << r.w << std::endl;
- std::cout << std::endl;
- system("pause");
- return 0;
- }
- float cos = math::cos(angle / 2.0f);
- float sin = math::sin(angle / 2.0f);
- float cos = math::cos(angle);
- float sin = math::sin(angle);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement