- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 138字
- 2021-06-30 14:46:01
Retrieving quaternion data
Since a quaternion can be created from an angle and an axis, it's reasonable to expect to be able to retrieve the same angle and axis from the quaternion. To retrieve the axis of rotation, normalize the vector part of the quaternion. The angle of rotation is double the inverse cosine of the real component.
Implement the getAngle and getAxis functions in quat.cpp and add function declarations for both in quat.h:
vec3 getAxis(const quat& quat) {
return normalized(vec3(quat.x, quat.y, quat.z));
}
float getAngle(const quat& quat) {
return 2.0f * acosf(quat.w);
}
Being able to retrieve the angle and the axis that defines a quaternion will be needed later for some quaternion operations.
Next, you're going to learn about the component-wise operations that are commonly performed on quaternions.
- Node.js Design Patterns
- Magento 1.8 Development Cookbook
- C語言程序設計案例精粹
- ASP.NET 3.5程序設計與項目實踐
- 快速念咒:MySQL入門指南與進階實戰
- Orleans:構建高性能分布式Actor服務
- 從零開始:UI圖標設計與制作(第3版)
- 平面設計經典案例教程:CorelDRAW X6
- 零基礎學HTML+CSS
- Fastdata Processing with Spark
- Python開發基礎
- 算法設計與分析:基于C++編程語言的描述
- Penetration Testing with the Bash shell
- Python編程快速上手2
- 深入理解Kafka:核心設計與實踐原理