Open full view…

Naming Convention for Matrix Math // A Random Walk Through Geek-Space

Sat, 29 Jul 2017 17:23:06 GMT

Sat, 29 Jul 2017 17:23:06 GMT

I really like conventions like this - easy to start using and easy to check. If you're not vigilant though, there's nothing to tell you it's wrong! I wonder if you could (ab)use templates to get the build to fail when the coordinate spaces don't match? Something kind of like this: ---C template <typename From, typename To> struct Matrix4 { // ... }; Matrix4<A, C> operator*(Matrix4<A, B>, Matrix4<B, C>); struct ObjectSpace; struct WorldSpace; struct ViewSpace; Matrix4<ObjectSpace, WorldSpace> object_to_world = /* ... */; Matrix4<WorldSpace, ViewSpace> world_to_view = /* ... */; Matrix4<ObjectSpace, ViewSpace> object_to_view = object_to_world * world_to_view; Matrix4<ObjectSpace, ViewSpace> object_to_view = world_to_view * object_to_world; // ERROR ---

Mon, 31 Jul 2017 22:04:02 GMT

Your thought reminds me of phantom types:

Fri, 11 Aug 2017 07:01:09 GMT

I think thee is a small typo here: "...looking at the leftmost and rightmost word of the multiplication chain (in this case object and world)..", should not it say.... "view" instead of "world"? Maybe I'm wrong.

Wed, 16 Aug 2017 01:28:03 GMT

Thanks, yeah that was typo.