Hello guys. As you know (most likely), CFrames have 4 vectors, which represent position and rotation. But, if CFrames consist of vectors, I got question: can I remade CFrame’s functions to work with Vector3, then using CFrame.fromMatrix() and increase performance with such thing, or it will be a bad idea?
Note: I care more about performance, speed of code, not about it’s readability and lengths (although if I can I care about both)
…which essentially means we have native 3-wide SIMD support. For code that uses many vector values this results in significantly smaller GC pressure and significantly faster execution…
In other words, doing math on Vector3s is going to be optimized quite a bit. So, my guess is that doing the math on the vectors themselves is probably going to be faster. However, always benchmark it yourself to verify.
It seems very unlikely there is a gain to be found. Cframes are all over the Roblox api, so it seems likely they will be implemented in an efficient way already.
If you have some code that is computationally intensive, you would be better off looking at opter optimisations. Or maybe play with this beta:
The reason CFrame’s require 4 vectors is because 1 is assigned for the position but the other 3 are required for the actual rotational matrix in 3d space.
LEAST what we can use to make rotation is 2 vectors, and to get third, you will need to cross it. You can’t represent rotation with only 1 vector. Only XYZ-like rotation (Like FromEulerAnglesXYZ). But this leads to precision problems.