- 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.
- Arduino by Example
- 小創客玩轉圖形化編程
- Unity 2020 Mobile Game Development
- ASP.NET Core Essentials
- Python進階編程:編寫更高效、優雅的Python代碼
- Scratch 3游戲與人工智能編程完全自學教程
- 假如C語言是我發明的:講給孩子聽的大師編程課
- Learning Laravel 4 Application Development
- Visual C++數字圖像處理技術詳解
- QGIS:Becoming a GIS Power User
- Natural Language Processing with Java and LingPipe Cookbook
- 計算機組裝與維護(第二版)
- Vue.js 3.x高效前端開發(視頻教學版)
- Python程序設計:基礎與實踐
- Access 2016數據庫應用與開發:實戰從入門到精通(視頻教學版)