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

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.

主站蜘蛛池模板: 济阳县| 子长县| 尉氏县| 西宁市| 北安市| 陆丰市| 通江县| 蒙自县| 广平县| 南乐县| 泰宁县| 阜新市| 霸州市| 禄劝| 泽库县| 普洱| 青龙| 三台县| 宁乡县| 天长市| 邯郸市| 建湖县| 泾源县| 开平市| 张家港市| 循化| 津南区| 宁乡县| 封开县| 从江县| 阿坝县| 毕节市| 乌拉特中旗| 资中县| 盐亭县| 山阳县| 木兰县| 五莲县| 武鸣县| 自贡市| 安多县|