- 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.
推薦閱讀
- Vue.js 3.x快速入門
- Learning Single:page Web Application Development
- Mastering Ext JS(Second Edition)
- LabVIEW Graphical Programming Cookbook
- Python數(shù)據(jù)分析基礎(chǔ)
- Unity 2017 Mobile Game Development
- C#開發(fā)案例精粹
- TMS320LF240x芯片原理、設(shè)計及應(yīng)用
- Scratch·愛編程的藝術(shù)家
- 后臺開發(fā):核心技術(shù)與應(yīng)用實踐
- 深入理解BootLoader
- Windows Phone 8 Game Development
- Python Digital Forensics Cookbook
- 人人都能開發(fā)RPA機器人:UiPath從入門到實戰(zhàn)
- 現(xiàn)代CPU性能分析與優(yōu)化