- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 181字
- 2021-06-30 14:45:57
Scaling a matrix
Matrices can be scaled by floating point numbers; this kind of scaling is a component-wise operation. To scale a matrix, multiply every element by the provided floating point number.
Implement matrix scaling in mat4.cpp. Don't forget to add the function declaration to mat4.h:
mat4 operator*(const mat4& m, float f) {
return mat4(
m.xx * f, m.xy * f, m.xz * f, m.xw * f,
m.yx * f, m.yy * f, m.yz * f, m.yw * f,
m.zx * f, m.zy * f, m.zz * f, m.zw * f,
m.tx * f, m.ty * f, m.tz * f, m.tw * f
);
}
Scaling matrices and then adding them allows you to "lerp" or "mix" between two matrices, so long as both matrices represent a linear transform. In the next section, you will learn how to multiply matrices together.
推薦閱讀
- 深入淺出數據科學:Python編程
- CMDB分步構建指南
- MySQL數據庫應用與管理 第2版
- 軟件測試項目實戰之性能測試篇
- HTML5從入門到精通 (第2版)
- 前端HTML+CSS修煉之道(視頻同步+直播)
- Nginx Lua開發實戰
- Visual FoxPro程序設計習題集及實驗指導(第四版)
- Swift 4 Protocol-Oriented Programming(Third Edition)
- 區塊鏈技術進階與實戰(第2版)
- 小程序,巧應用:微信小程序開發實戰(第2版)
- C語言程序設計習題與實驗指導
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- PyQt編程快速上手
- Laravel Design Patterns and Best Practices