Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float matrixA[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- float matrixB[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };
- matrixA[0] == matrixB[0][0];
- matrixA[3] == matrixB[0][3];
- matrixA[4] == matrixB[1][0];
- matrixA[7] == matrixB[1][3];
- 1, 0, 0, transX
- 0, 1, 0, transY
- 0, 0, 1, transZ
- 0, 0, 0, 1
- x.x x.y x.z 0
- y.x y.y y.z 0
- z.x z.y z.z 0
- p.x p.y p.z 1
- { x.x x.y x.z 0 y.x y.y y.z 0 z.x z.y z.z 0 p.x p.y p.z 1 }
- { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, transX, transY, transZ, 1 }.
- mat4 T; vec4 v; vec4 v_transformed;
- v_transformed = T*v;
- {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, transX, transY, transZ, 1 }
- v_transformed = v*T;
- { 1, 0, 0, transX, 0, 1, 0, transY, 0, 0, 1, transZ, 0, 0, 0, 1 }
- mat4 column_matrix = mat4(
- vec4( Xx, Xy, Xz, 0.0),
- vec4( Yx, Xy, Yz, 0.0),
- vec4( Zx Zy Zz, 0.0),
- vec4( Tx, Ty, Tz, 1.0) );
- vec4 u = column_matrix * v; // multiply the vector from the right to the matrix
- mat4 row_matrix = mat4(
- vec4( Xx, Yx, Zx, Tx),
- vec4( Xy, Yy, Zy, Ty),
- vec4( Xz Yz Zz, Tz),
- vec4( 0.0, 0.0, 0.0, 1.0) );
- vec4 u = v * row_matrix; // multiply the vector from the left to the matrix
- mat2(vec2, vec2);
- mat3(vec3, vec3, vec3);
- mat4(vec4, vec4, vec4, vec4);
- mat2(float, float,
- float, float);
- mat3(float, float, float,
- float, float, float,
- float, float, float);
- mat4(float, float, float, float,
- float, float, float, float,
- float, float, float, float,
- float, float, float, float);
- mat4 matrix=mat4(
- Xx, Xy, Xz, 0.0
- Yx, Xy, Yz, 0.0
- Zx Zy Zz, 0.0
- Tx, Ty, Tz, 1.0);
- c0 c1 c2 c3
- [ Xx Yx Zx Tx ]
- [ Xy Yy Zy Ty ]
- [ Xz Yz Zz Tz ]
- [ 0 0 0 1 ]
- [ Xx, Xy, Xz, 0, Yx, Yy, Yz, 0, Zx, Zy, Zz, 0, Tx, Ty, Tz, 1 ]
- mat2(
- float, float, // first column
- float, float); // second column
- mat4 m;
- m[1] = vec4(2.0); // sets the second column to all 2.0
- m[0][0] = 1.0; // sets the upper left element to 1.0
- m[2][3] = 2.0; // sets the 4th element of the third column to 2.0
- vec3 v, u;
- mat3 m;
- u.x = dot(v, m[0]); // m[0] is the left column of m
- u.y = dot(v, m[1]); // dot(a,b) is the inner (dot) product of a and b
- u.z = dot(v, m[2]);
- u.x = m[0].x * v.x + m[1].x * v.y + m[2].x * v.z;
- u.y = m[0].y * v.x + m[1].y * v.y + m[2].y * v.z;
- u.z = m[0].z * v.x + m[1].z * v.y + m[2].z * v.z;
Add Comment
Please, Sign In to add comment