Guest User

Untitled

a guest
Apr 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. float matrixA[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  2. float matrixB[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };
  3.  
  4. matrixA[0] == matrixB[0][0];
  5. matrixA[3] == matrixB[0][3];
  6. matrixA[4] == matrixB[1][0];
  7. matrixA[7] == matrixB[1][3];
  8.  
  9. 1, 0, 0, transX
  10. 0, 1, 0, transY
  11. 0, 0, 1, transZ
  12. 0, 0, 0, 1
  13.  
  14. x.x x.y x.z 0
  15. y.x y.y y.z 0
  16. z.x z.y z.z 0
  17. p.x p.y p.z 1
  18.  
  19. { 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 }
  20.  
  21. { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, transX, transY, transZ, 1 }.
  22.  
  23. mat4 T; vec4 v; vec4 v_transformed;
  24. v_transformed = T*v;
  25.  
  26. {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, transX, transY, transZ, 1 }
  27.  
  28. v_transformed = v*T;
  29.  
  30. { 1, 0, 0, transX, 0, 1, 0, transY, 0, 0, 1, transZ, 0, 0, 0, 1 }
  31.  
  32. mat4 column_matrix = mat4(
  33. vec4( Xx, Xy, Xz, 0.0),
  34. vec4( Yx, Xy, Yz, 0.0),
  35. vec4( Zx Zy Zz, 0.0),
  36. vec4( Tx, Ty, Tz, 1.0) );
  37.  
  38. vec4 u = column_matrix * v; // multiply the vector from the right to the matrix
  39.  
  40. mat4 row_matrix = mat4(
  41. vec4( Xx, Yx, Zx, Tx),
  42. vec4( Xy, Yy, Zy, Ty),
  43. vec4( Xz Yz Zz, Tz),
  44. vec4( 0.0, 0.0, 0.0, 1.0) );
  45.  
  46. vec4 u = v * row_matrix; // multiply the vector from the left to the matrix
  47.  
  48. mat2(vec2, vec2);
  49. mat3(vec3, vec3, vec3);
  50. mat4(vec4, vec4, vec4, vec4);
  51.  
  52. mat2(float, float,
  53. float, float);
  54.  
  55. mat3(float, float, float,
  56. float, float, float,
  57. float, float, float);
  58.  
  59. mat4(float, float, float, float,
  60. float, float, float, float,
  61. float, float, float, float,
  62. float, float, float, float);
  63.  
  64. mat4 matrix=mat4(
  65. Xx, Xy, Xz, 0.0
  66. Yx, Xy, Yz, 0.0
  67. Zx Zy Zz, 0.0
  68. Tx, Ty, Tz, 1.0);
  69.  
  70. c0 c1 c2 c3
  71. [ Xx Yx Zx Tx ]
  72. [ Xy Yy Zy Ty ]
  73. [ Xz Yz Zz Tz ]
  74. [ 0 0 0 1 ]
  75.  
  76. [ Xx, Xy, Xz, 0, Yx, Yy, Yz, 0, Zx, Zy, Zz, 0, Tx, Ty, Tz, 1 ]
  77.  
  78. mat2(
  79. float, float, // first column
  80. float, float); // second column
  81.  
  82. mat4 m;
  83. m[1] = vec4(2.0); // sets the second column to all 2.0
  84. m[0][0] = 1.0; // sets the upper left element to 1.0
  85. m[2][3] = 2.0; // sets the 4th element of the third column to 2.0
  86.  
  87. vec3 v, u;
  88. mat3 m;
  89.  
  90. u.x = dot(v, m[0]); // m[0] is the left column of m
  91. u.y = dot(v, m[1]); // dot(a,b) is the inner (dot) product of a and b
  92. u.z = dot(v, m[2]);
  93.  
  94. u.x = m[0].x * v.x + m[1].x * v.y + m[2].x * v.z;
  95. u.y = m[0].y * v.x + m[1].y * v.y + m[2].y * v.z;
  96. 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