I’ve written a blog(ish) post about matrices in Codea. Having seen a fair amount of confusion about them, I thought I’d like to set things straight. There are a few subtleties about order and so forth.

Thanks for writing this, @Andrew_Stacey! I will need to play with the examples to better understand it. I’ve used quaternions before for 3D rotations, but couldn’t say I understand them fully. Are they applicable to Codea for specifying rotations?

@Fred I use quaternions for handling rotations - I find them much easier to handle and manipulate than rotation matrices. When writing my shape explorer, I wrote a library for dealing with quaternions: http://www.math.ntnu.no/~stacey/code/CodeaLibrary/Quaternion.lua. In particular, it has a function for converting a quaternion to a matrix suitable for using in modelMatrix().

I could write a follow-up post on quaternions if there’s interest.

The sub article ‘saving the result’ starts to go beyond easy explanation. By the time someone gets there, their head is buzzing and they should take a break before trying to read all that math…

My intention was that you don’t have to read the more maths-y bits - you can just assume the result. I just don’t like it when something says “This is what you need to do” without giving any explanation. If it provides explanation then I can choose to skip it or not, but if it doesn’t then I don’t have a choice.