官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 延寿县| 广水市| 南江县| 柞水县| 蒙城县| 射洪县| 辉南县| 尤溪县| 略阳县| 仙游县| 梅州市| 滦平县| 林口县| 江口县| 连南| 射阳县| 沈丘县| 渝中区| 西贡区| 邯郸市| 甘洛县| 江油市| 黄平县| 余庆县| 马山县| 柳州市| 石狮市| 娱乐| 达日县| 盐边县| 漯河市| 武平县| 勐海县| 乐安县| 阜阳市| 鄄城县| 布尔津县| 青海省| 漳浦县| 榆中县| 青浦区|