- 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.
推薦閱讀
- NativeScript for Angular Mobile Development
- 營銷數據科學:用R和Python進行預測分析的建模技術
- Visual Basic程序設計教程
- Learning Neo4j 3.x(Second Edition)
- Python程序設計
- SQL Server與JSP動態網站開發
- Mastering Xamarin.Forms(Second Edition)
- Frank Kane's Taming Big Data with Apache Spark and Python
- 零基礎學Scratch 3.0編程
- Python趣味編程與精彩實例
- Learning Cocos2d-JS Game Development
- Google Maps JavaScript API Cookbook
- MySQL數據庫教程(視頻指導版)
- Python編程基礎與數據分析
- Learning HTML5 by Creating Fun Games