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

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.

主站蜘蛛池模板: 鹰潭市| 廊坊市| 怀集县| 东阿县| 五峰| 舞钢市| 东乌| 淮滨县| 昭苏县| 盐源县| 邢台县| 荥阳市| 合川市| 体育| 澜沧| 泰宁县| 永平县| 台北县| 砀山县| 监利县| 蒲江县| 贞丰县| 徐水县| 甘孜| 二连浩特市| 闻喜县| 凤台县| 翁牛特旗| 郧西县| 富裕县| 剑河县| 梓潼县| 南康市| 天长市| 睢宁县| 抚远县| 襄汾县| 达尔| 邮箱| 习水县| 郎溪县|