- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 97字
- 2021-06-30 14:45:50
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.
推薦閱讀
- 少兒人工智能趣味入門:Scratch 3.0動(dòng)畫與游戲編程
- C#高級(jí)編程(第10版) C# 6 & .NET Core 1.0 (.NET開發(fā)經(jīng)典名著)
- Rake Task Management Essentials
- Twilio Best Practices
- Three.js開發(fā)指南:基于WebGL和HTML5在網(wǎng)頁上渲染3D圖形和動(dòng)畫(原書第3版)
- 編寫整潔的Python代碼(第2版)
- YARN Essentials
- Visual FoxPro程序設(shè)計(jì)
- JBoss:Developer's Guide
- Visual FoxPro 6.0程序設(shè)計(jì)
- Practical Maya Programming with Python
- Flink核心技術(shù):源碼剖析與特性開發(fā)
- Elastix Unified Communications Server Cookbook
- Python人工智能項(xiàng)目實(shí)戰(zhàn)
- Build Your Own PaaS with Docker