- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 174字
- 2021-06-30 14:46:01
Common quaternion operations
Like vectors, quaternions also have component-wise operations. Common
component-wise operations are adding, subtracting, multiplying, or negating
quaternions. Component-wise quaternion multiplication multiplies a quaternion
by a single scalar value.
Since these functions are component-wise, they just perform the appropriate action on similar components of the input quaternions. Implement these functions in quat.cpp and add declarations for each function in quat.h:
quat operator+(const quat& a, const quat& b) {
return quat(a.x+b.x, a.y+b.y, a.z+b.z, a.w+b.w);
}
quat operator-(const quat& a, const quat& b) {
return quat(a.x-b.x, a.y-b.y, a.z-b.z, a.w-b.w);
}
quat operator*(const quat& a, float b) {
return quat(a.x * b, a.y * b, a.z * b, a.w * b);
}
quat operator-(const quat& q) {
return quat(-q.x, -q.y, -q.z, -q.w);
}
These component-wise operations don't have much practical use by themselves. They are the building blocks for building the rest of the quaternion functionality on. Next, you're going to learn about the different ways to compare quaternions.
- 深入核心的敏捷開發:ThoughtWorks五大關鍵實踐
- AWS Serverless架構:使用AWS從傳統部署方式向Serverless架構遷移
- C/C++算法從菜鳥到達人
- Mastering Natural Language Processing with Python
- Object-Oriented JavaScript(Second Edition)
- Python貝葉斯分析(第2版)
- Learning FuelPHP for Effective PHP Development
- Python大學實用教程
- jQuery技術內幕:深入解析jQuery架構設計與實現原理
- 百萬在線:大型游戲服務端開發
- 一步一步學Spring Boot:微服務項目實戰(第2版)
- Java EE輕量級解決方案:S2SH
- Internet of Things with Arduino Cookbook
- 鋁合金陽極氧化與表面處理技術(第三版)
- Drools 8規則引擎:核心技術與實踐