We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Thanks for this. It's not every day that I get corrections for a 7 year old blog post. :)
I changed int to bool where you noted that it was incorrect.
I had originally defined addition and subtraction to work on vectors and scalars in the same way as multiplication and division. You're right that this isn't defined mathematically, and I'm not aware of a single real-world use for this, so I've removed it.
Thank you!
i have to give Thanks...
was searching for a simple Vector lib, but all i could find are tons of libs, with hundreds of header files i don't have use for. luckily i stumbled across this and just stitched my own mini-lib together.
if you are interested, i'll post normalization and projection implementations later on, so you can include that for future souls, too lazy to look up and implement these Vector basics :)
I'm glad it was helpful. I probably won't add anything to this, as other more complete libs exist.
I believe that the two methods you mentioned are simple to add as:
v.norm() => v / v.length()
v.proj(rhs) => v ยท rhs.norm()
This is awesome thank you!
What does "rhs" refer to?
This refers to the right hand side of the operation.
"int operator==(vec3 rhs);"
should be
"bool operator==(vec3 rhs);" in the header i guess,
also you cannot add/substract a scalar from a Vector, its undefined behavior.
Multiplying and dividing a vector by a vector is also not possible.