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

Multiplying vectors

Vector multiplication can be considered a non-uniform scale. Instead of scaling every component of a vector by a scalar, to multiply two vectors, you scale every component of a vector by the like component of another vector.

You can implement vector multiplication by overloading the * operator in vec3.cpp. Don't forget to add the function declaration to vec3.h:

vec3 operator*(const vec3 &l, const vec3 &r) {

    return vec3(l.x * r.x, l.y * r.y, l.z * r.z);

}

The result generated by multiplying two vectors will have a different direction and magnitude.

主站蜘蛛池模板: 新津县| 博客| 厦门市| 景宁| 陆丰市| 钟祥市| 龙山县| 淳安县| 盐池县| 河北省| 华亭县| 建始县| 奈曼旗| 河源市| 榆中县| 青州市| 涞源县| 泸溪县| 辉南县| 蒙山县| 鄂伦春自治旗| 沛县| 江津市| 张家港市| 碌曲县| 贞丰县| 古交市| 渭南市| 霍城县| 安泽县| 灵丘县| 屯留县| 蒲城县| 阿鲁科尔沁旗| 年辖:市辖区| 民乐县| 奉贤区| 宣恩县| 吉隆县| 如东县| 方山县|