- 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.
推薦閱讀
- 大話PLC(輕松動漫版)
- 數字媒體應用教程
- jQuery EasyUI網站開發實戰
- Java Web基礎與實例教程
- Learning JavaScript Data Structures and Algorithms
- Windows內核編程
- MySQL入門很輕松(微課超值版)
- Learning Splunk Web Framework
- SignalR:Real-time Application Development(Second Edition)
- 數字媒體技術概論
- Java服務端研發知識圖譜
- Mobile Test Automation with Appium
- Access 2016數據庫應用與開發:實戰從入門到精通(視頻教學版)
- Visual C++ 開發從入門到精通
- Python大數據與機器學習實戰