- 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.
- Mastering Ext JS(Second Edition)
- 零起步玩轉掌控板與Mind+
- Oracle Database In-Memory(架構與實踐)
- Vue.js快速入門與深入實戰
- Rake Task Management Essentials
- 計算機應用基礎案例教程
- Scratch·愛編程的藝術家
- 超簡單:Photoshop+JavaScript+Python智能修圖與圖像自動化處理
- 人人都能開發RPA機器人:UiPath從入門到實戰
- Python預測分析與機器學習
- 基于MATLAB的控制系統仿真及應用
- Building Microservices with .NET Core 2.0(Second Edition)
- Practical Linux Security Cookbook
- 精通Spring MVC 4
- Python程序設計教程