4 ms·
What operator do you use for vector dot product? What about cross product (as opposed to vector scaling)? What about the different precedence between primitiv
by peterashford 13y ago
What operator do you use for vector dot product? What about cross product (as opposed to vector scaling)? What about the different precedence between primitive operators and overloaded operators ('+' and '*' have the same precedence in vector maths, no so in basic arithmetic).
Does adding mathematical notation to programming languages make the code easier for non-mathematicians? Does having two different coding standards make the language easier to use and maintain? What do you do when your set of operator glyphs is less than the number of mathematical operations you need to perform? What happens with your code when the operator overloads you use clash with the operator overloads from a new library?
I don't see any language that does operator overloading well and a lot of issues with making a good implementation. I like the idea I just see a lot of problems with the reality. And unless you can solve the problem well, I think it's the right thing to do the simplest thing that might possibly work.
- Aardwolf 13y agoNone for dot product. The regular matrix and vector multiplication as * operator makes things a lot more readable. Dot and cross product are less common for 3D rendering (one or none per line of code) so having that as a function doesn't hurt readibility.
- peterashford 13y agoI like writing ray tracers, so I use dot product and cross product quite a lot.
- bjz_ 13y agoI normally have dot and cross as free functions.
- peterashford 13y agoSo it's internally inconsistent and inconsistent with the mathematical notation. See, this is what I mean about Operator Overloading - I like the idea but it's actually really hard to see how you can actually do the job consistently and completely. I also don't find something like: a = b.dot(c); especially hard to read. YMMV.