- 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.
- Kubernetes實戰
- SQL學習指南(第3版)
- The DevOps 2.4 Toolkit
- FFmpeg入門詳解:音視頻原理及應用
- Linux命令行與shell腳本編程大全(第4版)
- bbPress Complete
- PhoneGap:Beginner's Guide(Third Edition)
- ElasticSearch Cookbook(Second Edition)
- Learning Unreal Engine Android Game Development
- Solr Cookbook(Third Edition)
- Python商務數據分析(微課版)
- C++程序設計教程(第2版)
- Emotional Intelligence for IT Professionals
- Hack與HHVM權威指南
- Software-Defined Networking with OpenFlow(Second Edition)