Hi NeuroFuzzy,
First of all: I made a mistake in my code last time. I edited it.
The line
divide vector4 3, z vector4(3) + Zn
had to be
divide vector4 3, w vector4(3)
It was a bit late yesterday...
Quote: "Is it true that "multiply matrix4 ret, a, b" actually says ret=A*B and not ret=B*A? I think that I was..."
Multiply matrix4 ret, A, B means ret = A * B if you're working with row vectors.
Though I advise you to 'think' in row vectors, it is not strictly necessary. Why?
You see, the transposed of a matrix multiplication is the multiplication in reverse order of the transposed matrices.
A * B * X = X' * B' * A'
This allows you to have a certain degree of freedom:
So if you were thinking to do
X = A * B * X
X =
column vector
B = first transformation
A = second transformation
Then it would translate to (using ret = second * first)
multiply matrix4 C, B, A
transform vector4 X, X, C
And if you were thinking
X = X * B * A (which is the same transformation, but with a row vector where B and A are now transposed)
X =
row vector
B = first transformation
A = second transformation
Then it would translate to (using ret = first * second)
multiply matrix4 C, B, A
transform vector4 X, X, C
which is clearly the same.
So basically, it doesn't have that big of an impact on how you interpret it, but you have to stick with one. However, if you use row vectors, the commands are more logical.
When you want to use column vectors
transform ****** Y, X, A changes to Y = A * X
multiply vector4 C, A, B changes to C = B * A
subtract matrix4 C, A, B does not change and stays C = A - B
get matrix4 element(Mat, E) now 'counts' downwards. E = 2 is element (3, 1), E = 4 is element (1, 2)
All other commands stay the same (they're either commutative or the parameters describe what it should be).
When you want to use row vectors, everything is pretty much as you would suspect:
transform ****** Y, X, A is Y = X * A
multiply vector4 C, A, B is C = A * B
subtract matrix4 C, A, B is C = A - B
get matrix4 element(Mat, E) counts to the right. E = 2 is the element (1, 3), E = 4 is element (2, 1).
So if you work with row vectors, you basically avoid a few problems, but technically it's possible to work with column vectors as well.
Cheers!
Sven B