Are these functions main columns or row columns?

I am comparing two different linear math libraries for 3D graphics using matrices. Here are two Translate functions from two libraries:

static Matrix4<T> Translate(T x, T y, T z)
{
    Matrix4 m;
    m.x.x = 1; m.x.y = 0; m.x.z = 0; m.x.w = 0;
    m.y.x = 0; m.y.y = 1; m.y.z = 0; m.y.w = 0;
    m.z.x = 0; m.z.y = 0; m.z.z = 1; m.z.w = 0;
    m.w.x = x; m.w.y = y; m.w.z = z; m.w.w = 1;
    return m;
}

(C ++ library from SO user privilege)

static inline void mat4x4_translate(mat4x4 T, float x, float y, float z)
{    
mat4x4_identity(T);
T[3][0] = x;
T[3][1] = y;
T[3][2] = z;
 }

(linmath c library from user SO datenwolf)

I'm new to this, but I know that the order of matrix multiplication depends on whether you use the column format or the main row.

In my opinion, these two use the same format as in the first index is considered as a row, the second is a column. That is, both x y zapply to the same first index. That would mean row-major to me, and thus matrix multiplication remains associative (for example, you usually do rotate * translatein that order).

, , . , , -, .

+1
2

, , , - .

, linmath.h . C ++ , ,

sometype a[n][m];

n m sometype . , , . OpenGL 4 × 4

0 4 8 c
1 5 9 d
2 6 a e
3 7 b f

++,

   ----> n

|  0 4 8 c
|  1 5 9 d
V  2 6 a e
m  3 7 b f

2-

0 -> 0,0
1 -> 0,1
2 -> 0,2
3 -> 0,3
4 -> 1,0
5 -> 1,1
6 -> 1,2
7 -> 1,3
8 -> 2,0
9 -> 2,1
a -> 2,2
b -> 2,3
c -> 3,0
d -> 3,1
e -> 3,2
f -> 3,3

, OpenGL , . , M i, j i j ? . , - . , .

:

A 3 dimensional cartesian coordinate system with right handed base vectors

X, Y Z , , .

X = (1,0,0)
Y = (0,1,0)
Z = (0,0,1)

, ? , !

, , . , , , . .

, , , (.. ) . < > right row < > - , .

()

v_clip = P · V · M · v_local

, . , = . , , Pascal Delphi :=. , ,

v_clip = v_local · M · V · P

. M, V P (, ), / .

, : . , . ? , , , . , , .

, , , , OpenGL. : == .

+6

, . , , , .

, , . , , . , . , .

GL , . D3D , .

, .

:

GL:
    V' = CAMERA * WORLD * LOCAL * V
D3D:
    V' = V * LOCAL * WORLD * CAMERA

, ( , ...)

+2

All Articles