Matrix4.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. /**
  2. * @author mr.doob / http://mrdoob.com/
  3. * @author supereggbert / http://www.paulbrunt.co.uk/
  4. * @author philogb / http://blog.thejit.org/
  5. * @author jordi_ros / http://plattsoft.com
  6. * @author D1plo1d / http://github.com/D1plo1d
  7. */
  8. THREE.Matrix4 = function () {
  9. this._x = new THREE.Vector3();
  10. this._y = new THREE.Vector3();
  11. this._z = new THREE.Vector3();
  12. };
  13. THREE.Matrix4.prototype = {
  14. n11: 1, n12: 0, n13: 0, n14: 0,
  15. n21: 0, n22: 1, n23: 0, n24: 0,
  16. n31: 0, n32: 0, n33: 1, n34: 0,
  17. n41: 0, n42: 0, n43: 0, n44: 1,
  18. identity: function () {
  19. this.n11 = 1; this.n12 = 0; this.n13 = 0; this.n14 = 0;
  20. this.n21 = 0; this.n22 = 1; this.n23 = 0; this.n24 = 0;
  21. this.n31 = 0; this.n32 = 0; this.n33 = 1; this.n34 = 0;
  22. this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
  23. },
  24. copy: function ( m ) {
  25. this.n11 = m.n11; this.n12 = m.n12; this.n13 = m.n13; this.n14 = m.n14;
  26. this.n21 = m.n21; this.n22 = m.n22; this.n23 = m.n23; this.n24 = m.n24;
  27. this.n31 = m.n31; this.n32 = m.n32; this.n33 = m.n33; this.n34 = m.n34;
  28. this.n41 = m.n41; this.n42 = m.n42; this.n43 = m.n43; this.n44 = m.n44;
  29. },
  30. lookAt: function ( eye, center, up ) {
  31. var x = this._x, y = this._y, z = this._z;
  32. z.sub( eye, center );
  33. z.normalize();
  34. x.cross( up, z );
  35. x.normalize();
  36. y.cross( z, x );
  37. y.normalize();
  38. this.n11 = x.x; this.n12 = x.y; this.n13 = x.z; this.n14 = - x.dot( eye );
  39. this.n21 = y.x; this.n22 = y.y; this.n23 = y.z; this.n24 = - y.dot( eye );
  40. this.n31 = z.x; this.n32 = z.y; this.n33 = z.z; this.n34 = - z.dot( eye );
  41. this.n41 = 0; this.n42 = 0; this.n43 = 0; this.
  42. n44 = 1;
  43. },
  44. transform: function ( v ) {
  45. var vx = v.x, vy = v.y, vz = v.z, vw = v.w ? v.w : 1.0;
  46. v.x = this.n11 * vx + this.n12 * vy + this.n13 * vz + this.n14 * vw;
  47. v.y = this.n21 * vx + this.n22 * vy + this.n23 * vz + this.n24 * vw;
  48. v.z = this.n31 * vx + this.n32 * vy + this.n33 * vz + this.n34 * vw;
  49. vw = this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 * vw;
  50. if( v.w ) {
  51. v.w = vw;
  52. } else {
  53. v.x = v.x / vw;
  54. v.y = v.y / vw;
  55. v.z = v.z / vw;
  56. }
  57. return v;
  58. },
  59. crossVector: function ( a ) {
  60. var v = new THREE.Vector4();
  61. v.x = this.n11 * a.x + this.n12 * a.y + this.n13 * a.z + this.n14 * a.w;
  62. v.y = this.n21 * a.x + this.n22 * a.y + this.n23 * a.z + this.n24 * a.w;
  63. v.z = this.n31 * a.x + this.n32 * a.y + this.n33 * a.z + this.n34 * a.w;
  64. v.w = ( a.w ) ? this.n41 * a.x + this.n42 * a.y + this.n43 * a.z + this.n44 * a.w : 1;
  65. return v;
  66. },
  67. multiply: function ( a, b ) {
  68. this.n11 = a.n11 * b.n11 + a.n12 * b.n21 + a.n13 * b.n31 + a.n14 * b.n41;
  69. this.n12 = a.n11 * b.n12 + a.n12 * b.n22 + a.n13 * b.n32 + a.n14 * b.n42;
  70. this.n13 = a.n11 * b.n13 + a.n12 * b.n23 + a.n13 * b.n33 + a.n14 * b.n43;
  71. this.n14 = a.n11 * b.n14 + a.n12 * b.n24 + a.n13 * b.n34 + a.n14 * b.n44;
  72. this.n21 = a.n21 * b.n11 + a.n22 * b.n21 + a.n23 * b.n31 + a.n24 * b.n41;
  73. this.n22 = a.n21 * b.n12 + a.n22 * b.n22 + a.n23 * b.n32 + a.n24 * b.n42;
  74. this.n23 = a.n21 * b.n13 + a.n22 * b.n23 + a.n23 * b.n33 + a.n24 * b.n43;
  75. this.n24 = a.n21 * b.n14 + a.n22 * b.n24 + a.n23 * b.n34 + a.n24 * b.n44;
  76. this.n31 = a.n31 * b.n11 + a.n32 * b.n21 + a.n33 * b.n31 + a.n34 * b.n41;
  77. this.n32 = a.n31 * b.n12 + a.n32 * b.n22 + a.n33 * b.n32 + a.n34 * b.n42;
  78. this.n33 = a.n31 * b.n13 + a.n32 * b.n23 + a.n33 * b.n33 + a.n34 * b.n43;
  79. this.n34 = a.n31 * b.n14 + a.n32 * b.n24 + a.n33 * b.n34 + a.n34 * b.n44;
  80. this.n41 = a.n41 * b.n11 + a.n42 * b.n21 + a.n43 * b.n31 + a.n44 * b.n41;
  81. this.n42 = a.n41 * b.n12 + a.n42 * b.n22 + a.n43 * b.n32 + a.n44 * b.n42;
  82. this.n43 = a.n41 * b.n13 + a.n42 * b.n23 + a.n43 * b.n33 + a.n44 * b.n43;
  83. this.n44 = a.n41 * b.n14 + a.n42 * b.n24 + a.n43 * b.n34 + a.n44 * b.n44;
  84. },
  85. multiplySelf: function ( m ) {
  86. var n11 = this.n11, n12 = this.n12, n13 = this.n13, n14 = this.n14,
  87. n21 = this.n21, n22 = this.n22, n23 = this.n23, n24 = this.n24,
  88. n31 = this.n31, n32 = this.n32, n33 = this.n33, n34 = this.n34,
  89. n41 = this.n41, n42 = this.n42, n43 = this.n43, n44 = this.n44;
  90. this.n11 = n11 * m.n11 + n12 * m.n21 + n13 * m.n31 + n14 * m.n41;
  91. this.n12 = n11 * m.n12 + n12 * m.n22 + n13 * m.n32 + n14 * m.n42;
  92. this.n13 = n11 * m.n13 + n12 * m.n23 + n13 * m.n33 + n14 * m.n43;
  93. this.n14 = n11 * m.n14 + n12 * m.n24 + n13 * m.n34 + n14 * m.n44;
  94. this.n21 = n21 * m.n11 + n22 * m.n21 + n23 * m.n31 + n24 * m.n41;
  95. this.n22 = n21 * m.n12 + n22 * m.n22 + n23 * m.n32 + n24 * m.n42;
  96. this.n23 = n21 * m.n13 + n22 * m.n23 + n23 * m.n33 + n24 * m.n43;
  97. this.n24 = n21 * m.n14 + n22 * m.n24 + n23 * m.n34 + n24 * m.n44;
  98. this.n31 = n31 * m.n11 + n32 * m.n21 + n33 * m.n31 + n34 * m.n41;
  99. this.n32 = n31 * m.n12 + n32 * m.n22 + n33 * m.n32 + n34 * m.n42;
  100. this.n33 = n31 * m.n13 + n32 * m.n23 + n33 * m.n33 + n34 * m.n43;
  101. this.n34 = n31 * m.n14 + n32 * m.n24 + n33 * m.n34 + n34 * m.n44;
  102. this.n41 = n41 * m.n11 + n42 * m.n21 + n43 * m.n31 + n44 * m.n41;
  103. this.n42 = n41 * m.n12 + n42 * m.n22 + n43 * m.n32 + n44 * m.n42;
  104. this.n43 = n41 * m.n13 + n42 * m.n23 + n43 * m.n33 + n44 * m.n43;
  105. this.n44 = n41 * m.n14 + n42 * m.n24 + n43 * m.n34 + n44 * m.n44;
  106. },
  107. multiplyScalar: function ( s ) {
  108. this.n11 *= s; this.n12 *= s; this.n13 *= s; this.n14 *= s;
  109. this.n21 *= s; this.n22 *= s; this.n23 *= s; this.n24 *= s;
  110. this.n31 *= s; this.n32 *= s; this.n33 *= s; this.n34 *= s;
  111. this.n41 *= s; this.n42 *= s; this.n43 *= s; this.n44 *= s;
  112. },
  113. determinant: function () {
  114. //TODO: make this more efficient
  115. //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
  116. return (
  117. this.n14 * this.n23 * this.n32 * this.n41-
  118. this.n13 * this.n24 * this.n32 * this.n41-
  119. this.n14 * this.n22 * this.n33 * this.n41+
  120. this.n12 * this.n24 * this.n33 * this.n41+
  121. this.n13 * this.n22 * this.n34 * this.n41-
  122. this.n12 * this.n23 * this.n34 * this.n41-
  123. this.n14 * this.n23 * this.n31 * this.n42+
  124. this.n13 * this.n24 * this.n31 * this.n42+
  125. this.n14 * this.n21 * this.n33 * this.n42-
  126. this.n11 * this.n24 * this.n33 * this.n42-
  127. this.n13 * this.n21 * this.n34 * this.n42+
  128. this.n11 * this.n23 * this.n34 * this.n42+
  129. this.n14 * this.n22 * this.n31 * this.n43-
  130. this.n12 * this.n24 * this.n31 * this.n43-
  131. this.n14 * this.n21 * this.n32 * this.n43+
  132. this.n11 * this.n24 * this.n32 * this.n43+
  133. this.n12 * this.n21 * this.n34 * this.n43-
  134. this.n11 * this.n22 * this.n34 * this.n43-
  135. this.n13 * this.n22 * this.n31 * this.n44+
  136. this.n12 * this.n23 * this.n31 * this.n44+
  137. this.n13 * this.n21 * this.n32 * this.n44-
  138. this.n11 * this.n23 * this.n32 * this.n44-
  139. this.n12 * this.n21 * this.n33 * this.n44+
  140. this.n11 * this.n22 * this.n33 * this.n44 );
  141. },
  142. transpose: function () {
  143. function swap( obj, p1, p2 ) {
  144. var aux = obj[ p1 ];
  145. obj[ p1 ] = obj[ p2 ];
  146. obj[ p2 ] = aux;
  147. }
  148. swap( this, 'n21', 'n12' );
  149. swap( this, 'n31', 'n13' );
  150. swap( this, 'n32', 'n23' );
  151. swap( this, 'n41', 'n14' );
  152. swap( this, 'n42', 'n24' );
  153. swap( this, 'n43', 'n34' );
  154. return this;
  155. },
  156. clone: function () {
  157. var m = new THREE.Matrix4();
  158. m.n11 = this.n11; m.n12 = this.n12; m.n13 = this.n13; m.n14 = this.n14;
  159. m.n21 = this.n21; m.n22 = this.n22; m.n23 = this.n23; m.n24 = this.n24;
  160. m.n31 = this.n31; m.n32 = this.n32; m.n33 = this.n33; m.n34 = this.n34;
  161. m.n41 = this.n41; m.n42 = this.n42; m.n43 = this.n43; m.n44 = this.n44;
  162. return m;
  163. },
  164. flatten: function() {
  165. return [this.n11, this.n21, this.n31, this.n41,
  166. this.n12, this.n22, this.n32, this.n42,
  167. this.n13, this.n23, this.n33, this.n43,
  168. this.n14, this.n24, this.n34, this.n44];
  169. },
  170. toString: function() {
  171. return "| " + this.n11 + " " + this.n12 + " " + this.n13 + " " + this.n14 + " |\n" +
  172. "| " + this.n21 + " " + this.n22 + " " + this.n23 + " " + this.n24 + " |\n" +
  173. "| " + this.n31 + " " + this.n32 + " " + this.n33 + " " + this.n34 + " |\n" +
  174. "| " + this.n41 + " " + this.n42 + " " + this.n43 + " " + this.n44 + " |";
  175. }
  176. };
  177. THREE.Matrix4.translationMatrix = function ( x, y, z ) {
  178. var m = new THREE.Matrix4();
  179. m.n14 = x;
  180. m.n24 = y;
  181. m.n34 = z;
  182. return m;
  183. };
  184. THREE.Matrix4.scaleMatrix = function ( x, y, z ) {
  185. var m = new THREE.Matrix4();
  186. m.n11 = x;
  187. m.n22 = y;
  188. m.n33 = z;
  189. return m;
  190. };
  191. THREE.Matrix4.rotationXMatrix = function ( theta ) {
  192. var rot = new THREE.Matrix4();
  193. rot.n22 = rot.n33 = Math.cos( theta );
  194. rot.n32 = Math.sin( theta );
  195. rot.n23 = - rot.n32;
  196. return rot;
  197. };
  198. THREE.Matrix4.rotationYMatrix = function ( theta ) {
  199. var rot = new THREE.Matrix4();
  200. rot.n11 = rot.n33 = Math.cos( theta );
  201. rot.n13 = Math.sin( theta );
  202. rot.n31 = - rot.n13;
  203. return rot;
  204. };
  205. THREE.Matrix4.rotationZMatrix = function ( theta ) {
  206. var rot = new THREE.Matrix4();
  207. rot.n11 = rot.n22 = Math.cos( theta );
  208. rot.n21 = Math.sin( theta );
  209. rot.n12 = - rot.n21;
  210. return rot;
  211. };
  212. THREE.Matrix4.rotationAxisAngleMatrix = function ( axis, angle ) {
  213. //Based on http://www.gamedev.net/reference/articles/article1199.asp
  214. var rot = new THREE.Matrix4(),
  215. c = Math.cos( angle ),
  216. s = Math.sin( angle ),
  217. t = 1 - c,
  218. x = axis.x, y = axis.y, z = axis.z;
  219. rot.n11 = t * x * x + c;
  220. rot.n12 = t * x * y - s * z;
  221. rot.n13 = t * x * z + s * y;
  222. rot.n21 = t * x * y + s * z;
  223. rot.n22 = t * y * y + c;
  224. rot.n23 = t * y * z - s * x;
  225. rot.n31 = t * x * z - s * y;
  226. rot.n32 = t * y * z + s * x;
  227. rot.n33 = t * z * z + c;
  228. return rot;
  229. };
  230. THREE.Matrix4.makeInvert = function ( m1 ) {
  231. //TODO: make this more efficient
  232. //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
  233. var m2 = new THREE.Matrix4();
  234. m2.n11 = m1.n23*m1.n34*m1.n42 - m1.n24*m1.n33*m1.n42 + m1.n24*m1.n32*m1.n43 - m1.n22*m1.n34*m1.n43 - m1.n23*m1.n32*m1.n44 + m1.n22*m1.n33*m1.n44;
  235. m2.n12 = m1.n14*m1.n33*m1.n42 - m1.n13*m1.n34*m1.n42 - m1.n14*m1.n32*m1.n43 + m1.n12*m1.n34*m1.n43 + m1.n13*m1.n32*m1.n44 - m1.n12*m1.n33*m1.n44;
  236. m2.n13 = m1.n13*m1.n24*m1.n42 - m1.n14*m1.n23*m1.n42 + m1.n14*m1.n22*m1.n43 - m1.n12*m1.n24*m1.n43 - m1.n13*m1.n22*m1.n44 + m1.n12*m1.n23*m1.n44;
  237. m2.n14 = m1.n14*m1.n23*m1.n32 - m1.n13*m1.n24*m1.n32 - m1.n14*m1.n22*m1.n33 + m1.n12*m1.n24*m1.n33 + m1.n13*m1.n22*m1.n34 - m1.n12*m1.n23*m1.n34;
  238. m2.n21 = m1.n24*m1.n33*m1.n41 - m1.n23*m1.n34*m1.n41 - m1.n24*m1.n31*m1.n43 + m1.n21*m1.n34*m1.n43 + m1.n23*m1.n31*m1.n44 - m1.n21*m1.n33*m1.n44;
  239. m2.n22 = m1.n13*m1.n34*m1.n41 - m1.n14*m1.n33*m1.n41 + m1.n14*m1.n31*m1.n43 - m1.n11*m1.n34*m1.n43 - m1.n13*m1.n31*m1.n44 + m1.n11*m1.n33*m1.n44;
  240. m2.n23 = m1.n14*m1.n23*m1.n41 - m1.n13*m1.n24*m1.n41 - m1.n14*m1.n21*m1.n43 + m1.n11*m1.n24*m1.n43 + m1.n13*m1.n21*m1.n44 - m1.n11*m1.n23*m1.n44;
  241. m2.n24 = m1.n13*m1.n24*m1.n31 - m1.n14*m1.n23*m1.n31 + m1.n14*m1.n21*m1.n33 - m1.n11*m1.n24*m1.n33 - m1.n13*m1.n21*m1.n34 + m1.n11*m1.n23*m1.n34;
  242. m2.n31 = m1.n22*m1.n34*m1.n41 - m1.n24*m1.n32*m1.n41 + m1.n24*m1.n31*m1.n42 - m1.n21*m1.n34*m1.n42 - m1.n22*m1.n31*m1.n44 + m1.n21*m1.n32*m1.n44;
  243. m2.n32 = m1.n14*m1.n32*m1.n41 - m1.n12*m1.n34*m1.n41 - m1.n14*m1.n31*m1.n42 + m1.n11*m1.n34*m1.n42 + m1.n12*m1.n31*m1.n44 - m1.n11*m1.n32*m1.n44;
  244. m2.n33 = m1.n13*m1.n24*m1.n41 - m1.n14*m1.n22*m1.n41 + m1.n14*m1.n21*m1.n42 - m1.n11*m1.n24*m1.n42 - m1.n12*m1.n21*m1.n44 + m1.n11*m1.n22*m1.n44;
  245. m2.n34 = m1.n14*m1.n22*m1.n31 - m1.n12*m1.n24*m1.n31 - m1.n14*m1.n21*m1.n32 + m1.n11*m1.n24*m1.n32 + m1.n12*m1.n21*m1.n34 - m1.n11*m1.n22*m1.n34;
  246. m2.n41 = m1.n23*m1.n32*m1.n41 - m1.n22*m1.n33*m1.n41 - m1.n23*m1.n31*m1.n42 + m1.n21*m1.n33*m1.n42 + m1.n22*m1.n31*m1.n43 - m1.n21*m1.n32*m1.n43;
  247. m2.n42 = m1.n12*m1.n33*m1.n41 - m1.n13*m1.n32*m1.n41 + m1.n13*m1.n31*m1.n42 - m1.n11*m1.n33*m1.n42 - m1.n12*m1.n31*m1.n43 + m1.n11*m1.n32*m1.n43;
  248. m2.n43 = m1.n13*m1.n22*m1.n41 - m1.n12*m1.n23*m1.n41 - m1.n13*m1.n21*m1.n42 + m1.n11*m1.n23*m1.n42 + m1.n12*m1.n21*m1.n43 - m1.n11*m1.n22*m1.n43;
  249. m2.n44 = m1.n12*m1.n23*m1.n31 - m1.n13*m1.n22*m1.n31 + m1.n13*m1.n21*m1.n32 - m1.n11*m1.n23*m1.n32 - m1.n12*m1.n21*m1.n33 + m1.n11*m1.n22*m1.n33;
  250. m2.multiplyScalar( 1 / m1.determinant() );
  251. return m2;
  252. };
  253. THREE.Matrix4.makeInvert3x3 = function ( m1 ) {
  254. // input: THREE.Matrix4, output: THREE.Matrix3
  255. // ( based on http://code.google.com/p/webgl-mjs/ )
  256. var m = m1.flatten(),
  257. m2 = new THREE.Matrix3(),
  258. a11 = m[ 10 ] * m[ 5 ] - m[ 6 ] * m[ 9 ],
  259. a21 = - m[ 10 ] * m[ 1 ] + m[ 2 ] * m[ 9 ],
  260. a31 = m[ 6 ] * m[ 1 ] - m[ 2 ] * m[ 5 ],
  261. a12 = - m[ 10 ] * m[ 4 ] + m[ 6 ] * m[ 8 ],
  262. a22 = m[ 10 ] * m[ 0 ] - m[ 2 ] * m[ 8 ],
  263. a32 = - m[ 6 ] * m[ 0 ] + m[ 2 ] * m[ 4 ],
  264. a13 = m[ 9 ] * m[ 4 ] - m[ 5 ] * m[ 8 ],
  265. a23 = - m[ 9 ] * m[ 0 ] + m[ 1 ] * m[ 8 ],
  266. a33 = m[ 5 ] * m[ 0 ] - m[ 1 ] * m[ 4 ],
  267. det = m[ 0 ] * ( a11 ) + m[ 1 ] * ( a12 ) + m[ 2 ] * ( a13 ),
  268. idet;
  269. // no inverse
  270. if (det == 0) throw "matrix not invertible";
  271. idet = 1.0 / det;
  272. m2.m[ 0 ] = idet * a11; m2.m[ 1 ] = idet * a21; m2.m[ 2 ] = idet * a31;
  273. m2.m[ 3 ] = idet * a12; m2.m[ 4 ] = idet * a22; m2.m[ 5 ] = idet * a32;
  274. m2.m[ 6 ] = idet * a13; m2.m[ 7 ] = idet * a23; m2.m[ 8 ] = idet * a33;
  275. return m2;
  276. }
  277. THREE.Matrix4.makeFrustum = function( left, right, bottom, top, near, far ) {
  278. var m, x, y, a, b, c, d;
  279. m = new THREE.Matrix4();
  280. x = 2 * near / ( right - left );
  281. y = 2 * near / ( top - bottom );
  282. a = ( right + left ) / ( right - left );
  283. b = ( top + bottom ) / ( top - bottom );
  284. c = - ( far + near ) / ( far - near );
  285. d = - 2 * far * near / ( far - near );
  286. m.n11 = x; m.n12 = 0; m.n13 = a; m.n14 = 0;
  287. m.n21 = 0; m.n22 = y; m.n23 = b; m.n24 = 0;
  288. m.n31 = 0; m.n32 = 0; m.n33 = c; m.n34 = d;
  289. m.n41 = 0; m.n42 = 0; m.n43 = - 1; m.n44 = 0;
  290. return m;
  291. };
  292. THREE.Matrix4.makePerspective = function( fov, aspect, near, far ) {
  293. var ymax, ymin, xmin, xmax;
  294. ymax = near * Math.tan( fov * Math.PI / 360 );
  295. ymin = - ymax;
  296. xmin = ymin * aspect;
  297. xmax = ymax * aspect;
  298. return THREE.Matrix4.makeFrustum( xmin, xmax, ymin, ymax, near, far );
  299. };
  300. THREE.Matrix4.makeOrtho = function( left, right, top, bottom, near, far ) {
  301. var m, x, y, z, w, h, p;
  302. m = new THREE.Matrix4();
  303. w = right - left;
  304. h = bottom - top;
  305. p = far - near;
  306. x = ( right + left ) / w;
  307. y = ( bottom + top ) / h;
  308. z = ( far + near ) / p;
  309. m.n11 = 2 / w; m.n12 = 0; m.n13 = 0; m.n14 = -x;
  310. m.n21 = 0; m.n22 = 2 / h; m.n23 = 0; m.n24 = -y;
  311. m.n31 = 0; m.n32 = 0; m.n33 = -2 / p; m.n34 = -z;
  312. m.n41 = 0; m.n42 = 0; m.n43 = 0; m.n44 = 1;
  313. return m;
  314. };
粤ICP备19079148号