Neo wrote:As for othornormal rotation, I don't have a clear idea now
I'll try to explain that a little, as it is one of the most important things you need to understand.
Let's begin with 2d, here a orientation matrix wood look like:
1,0 // X axis
0,1 // Y axis
graphically: |_ (y points up, x points right)
Both those vectors have length of one and are prependicular.
Also this is identity (no rotation)
Another orientation, rotated slightly counterclockwise could be:
0.8,0.6 // X axis now points right and slightly upwards
-0.6,0.8 // Y axis points slightly left and upwards
graphically like: \/
Note: Both axis have length 1: sqrt(0.8*0.8+0.6*0.6)==1, so they are normalized.
And they are perpenducular to each other == normal == 90 degrees
So this is rotated, not identity, but it is orthonormal.
You can build any valid 2d rotation matrix like:
cos(angle), sin(angle)
-sin(angle), cos(angle)
In 3d it's the same:
1,0,0 // x axis pointing right
0,1,0 // y pointing up
0,0,1 // z pointing out of the screen
this is identity.
Now we want some rotation around the z axis (so the z axis stays untouched, as anything rotates around it):
0.8, 0.6, 0
-0.6, 0.8, 0
0, 0, 1
Now we want some rotation around the y axis:
0.8, 0, 0.6
0, 1, 0
-0.6, 0, 0.8
It get's harder to imagine how that would look like and is really boring (and useless too),
but i hope you get the point: The topleft 3x3 values af a 3D orthonormalized Transformation matrix are 3 axis vectors.
They are unit length and normal to each other - if you get that you really understood what those matrices are (for our use case).
Note that this holds for both if you treat the axis vectors as rows OR columns of the matrix.
Now, let's add some evil scaling (2d again):
1,0
0,1
scaled uniformily by 10 becomes
10,0 // simply larger axis
0,10
and if we want a nonuniform scale, say x axis stretched by 10 we get
10,0
0,1
and if we'd want to rotate that again it should get:
8.0, 6.0 // long X axis scaled by 10 pointing right and upwards
-0.6, 0.8 // Y axis stays unit length
This is exactly what you have and is not good.
We want to seperate the scale from the orientation, first isolate scale:
xScale = length(8,6) = 10 // how long is x axis?
yScale = length(-0.6,0.

= 1 // how long y?
now, divide both axis by their lengths to normalize them:
0.8,0.6
-0.6,0.8
Now you have the orthonormal orientation you want to create the body, and you also have the scale you need to bring it back to your wanted shape.
I'll leave the 3d case as an exercise to you, but don't worry - this (and little more) is what julio will give you after you posted your code.
But read this and try to imagine until you understand - this is bread and butter of 3d programming, and you should get able to help yourself in such cases.
Note that we did not cover any calculations with matrices (famous matrix multiplication f.ex.), so a big part of the picture is missing to give it real sense.
However, it should be clear now, why we use those 9 numbers to represent 3D orientation.