IMHO you better serve by implementing them as classes, simply because it will allow you to write your code faster with less errors. You have to take measurements to find out what works best if it matters to you, but also make sure that this code is actually a performance bottleneck. (Mandatory Quote by Donald Knuth : “premature optimization is the root of all evil”).
Most compilers will work very well to optimize the code for you, I would say. More often than not, I find it to be something other than these low-level things that matter, like adding an early test or minimizing a dataset or something else.
For the quaternion, you can still implement the class using an array inside (in case it happens faster), which should make the difference even less important.
You are probably best served, for example, to make sure you can run your algorithms in parallel on multi-core machines or do your actual calculations using SSE instructions.
villintehaspam
source share