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

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.

主站蜘蛛池模板: 南京市| 广汉市| 瑞丽市| 多伦县| 吉安市| 乳山市| 潢川县| 汉源县| 蕉岭县| 灵川县| 晋州市| 金华市| 朝阳县| 新建县| 江永县| 乌拉特前旗| 乌拉特前旗| 青铜峡市| 元朗区| 德清县| 海兴县| 石楼县| 赣州市| 藁城市| 揭西县| 内丘县| 惠水县| 宜城市| 景德镇市| 翁牛特旗| 五指山市| 哈密市| 开鲁县| 大名县| 汝南县| 富顺县| 芷江| 怀远县| 铜陵市| 资阳市| 峨眉山市|