- 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.
- Learn TypeScript 3 by Building Web Applications
- 深入淺出WPF
- JavaScript+jQuery開發實戰
- Go語言精進之路:從新手到高手的編程思想、方法和技巧(1)
- Node.js:來一打 C++ 擴展
- C指針原理揭秘:基于底層實現機制
- Web前端開發技術:HTML、CSS、JavaScript
- Xamarin Cross-Platform Development Cookbook
- Java程序設計實用教程(第2版)
- Yii2 By Example
- LabVIEW數據采集(第2版)
- JavaScript程序設計基礎教程(慕課版)
- 區塊鏈原理、架構與應用(第2版)
- 15天學會JavaScript(視頻教學版)
- 商業銀行經營管理(第2版)