4 ms·
I'd be happy if C and C++ had 2,3,and 4 element vectors as built in types, along with cross and dot product operations. There are intrinsics, and GCC has it's o
by phkahler 12y ago
I'd be happy if C and C++ had 2,3,and 4 element vectors as built in types, along with cross and dot product operations. There are intrinsics, and GCC has it's own intrinsics that can be used across architectures. But the languages need to have these. They are so fundamental to so many things.
There are many more things to wish for, but I'm starting with one of the simplest.
- adrianN 12y agoWhy would you need this in the language? It seems to me that these things can be provided by a library without any loss.
- colomon 12y agoWell, to be fair, there aren't good C++ operators to use for dot and cross product. (Funny, looking at my own C++ vector op file, I see in addition to the usual +, -, *, / I've added function definitions Dot, Normalize, Cross, and Length. I don't think of Normalize and Length as operators, but it might make sense if they were...)
- phkahler 12y agoWhy would you need this in the language? It seems to me that these things can be provided by a library without any loss. No loss in function. C++ will certainly let you create classes, but you need to be extremely good to make them low overhead. You also can't pass them by value (the intrinsics can). And lastly, classes don't exist in C. Vector math is so common it should have direct support and operators.