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

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.

主站蜘蛛池模板: 于田县| 仙居县| 铅山县| 双牌县| 巨野县| 集安市| 鄂温| 夏津县| 汽车| 夏邑县| 神木县| 铜梁县| 定日县| 增城市| 乡宁县| 界首市| 望城县| 西宁市| 临西县| 长汀县| 班戈县| 阿勒泰市| 荆州市| 得荣县| 祥云县| 遵化市| 进贤县| 同江市| 句容市| 北宁市| 巴林左旗| 塘沽区| 略阳县| 思南县| 四会市| 沽源县| 保亭| 庄浪县| 聊城市| 海兴县| 邛崃市|