- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 171字
- 2021-06-30 14:45:57
Adding matrices
Two matrices can be added together by component. To add two matrices together, sum their respective components and store the result in a new matrix. Matrix addition can be used with scalar multiplication to interpolate or blend between multiple matrices. Later, you will learn how to use this property to implement animation skinning.
Implement the matrix addition function in mat4.cpp. Don't forget to add the function declaration to mat4.h:
mat4 operator+(const mat4& a, const mat4& b) {
return mat4(
a.xx+b.xx, a.xy+b.xy, a.xz+b.xz, a.xw+b.xw,
a.yx+b.yx, a.yy+b.yy, a.yz+b.yz, a.yw+b.yw,
a.zx+b.zx, a.zy+b.zy, a.zz+b.zz, a.zw+b.zw,
a.tx+b.tx, a.ty+b.ty, a.tz+b.tz, a.tw+b.tw
);
}
Matrix addition is simple but it will play a big role in displaying an animated mesh. In the next section, you will learn how to scale a matrix by a scalar value.
- 大學計算機基礎(第二版)
- Dynamics 365 Application Development
- INSTANT Sencha Touch
- 機器人Python青少年編程開發實例
- 高級C/C++編譯技術(典藏版)
- 差分進化算法及其高維多目標優化應用
- Easy Web Development with WaveMaker
- Mastering Drupal 8 Views
- Visual C#.NET Web應用程序設計
- 匯編語言編程基礎:基于LoongArch
- Android群英傳
- Django實戰:Python Web典型模塊與項目開發
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- Mastering HTML5 Forms
- Java程序設計教程