{"id":227285,"date":"2014-06-23T18:26:03","date_gmt":"2014-06-23T14:26:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=227285"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=227285","title":{"rendered":"<span class=\"post_title\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a WebGL. \u0421\u0442\u0430\u0442\u044c\u044f \u21162. \u041c\u0430\u0442\u0440\u0438\u0446\u0430<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0412 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/227201\/\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a><\/p>\n<h4>\u041c\u0430\u0442\u0440\u0438\u0446\u0430.<\/h4>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b \u2014 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u0430\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u0436\u0438\u0437\u043d\u044c. \u0423 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u044f \u0431\u044b \u0438\u0445 \u0432\u0441\u0435 \u0441\u0432\u0435\u043b \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u2014 \u00ab\u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0443\u0445 \u043e\u0442 \u043a\u043e\u0442\u043b\u0435\u0442\u00bb, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0442\u043e\u0447\u0435\u043a \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u0440\u043e\u043a, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u043e\u0439 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 x,y,z \u0438\u043b\u0438 w. \u0423 \u043c\u0435\u043d\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u00abw\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443. <\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u0432 \u043d\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043c\u043e\u0436\u043d\u043e \u0441 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043e\u0441\u0435\u0439 \u0438 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0446\u0435\u043d\u0442\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0447\u0435\u043a. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0443\u044e \u0442\u0440\u0435\u043c \u2014 x,y,z. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0441\u0430\u043c \u043a\u043e\u0434.<\/p>\n<pre><code class=\"javascript\">function botuMatrix (source,columns) { \tthis.source = source; \tthis.columnNumbers = columns; \tthis.rowNumbers = source.length \/ columns; \tthis.rows = []; \tthis.minval = []; \tthis.maxval = []; \tthis.radius = []; \tthis.center = []; \tthis.column = [];  \t\t \tif (source.length &gt; 0) \t{ \t\tvar count = 0;  \t\twhile(count &lt; source.length) \t\t{ \t\t\tvar currentRow = this.source.slice(count,count + this.columnNumbers);\t\t \t\t    this.rows.push(currentRow); \t\t\t \t\t\tvar columnCount = 0; \t\t\twhile(columnCount &lt;= this.columnNumbers) \t\t\t{ \t\t\t\tif (!this.column[columnCount])  \t\t\t\t{ \t\t\t\t\tthis.column[columnCount] = []; \t\t\t\t} \t\t\t\tthis.column[columnCount].push(currentRow[columnCount]); \t\t\t\tcolumnCount += 1; \t\t\t} \t\t\t \t\t\tcount = count + this.columnNumbers;  \t\t}\t \t\tthis.rowNumbers = this.rows.length;  \t\t \t\tif (this.rows.length &gt; 0) \t\t{ \t\t\tcount = 0; \t\t\twhile(count &lt; this.rows.length) \t\t\t{ \t\t\t\tvar tempRow = this.rows[count].slice(0); \t\t\t\tif (count == 0 ) \t\t\t\t{ \t\t\t\t\tthis.minval = tempRow.slice(0); \t\t\t\t\tthis.maxval = tempRow.slice(0); \t\t\t\t\tthis.radius = tempRow.slice(0); \t\t\t\t\tthis.center = tempRow.slice(0); \t\t\t\t} \t\t\t \t\t\t\tif (count &gt; 0) \t\t\t\t{ \t\t\t\t\tvar rowcount = 0; \t\t\t\t\twhile(rowcount &lt; tempRow.length) \t\t\t\t\t{ \t\t\t\t\t\tthis.minval.splice(rowcount,1,Math.min(this.minval[rowcount],tempRow[rowcount])); \t\t\t\t\t \t\t\t\t\t\tthis.maxval.splice(rowcount,1,Math.max(this.maxval[rowcount],tempRow[rowcount])); \t\t\t\t\t\tthis.radius.splice(rowcount,1,(this.maxval[rowcount] - this.minval[rowcount]) \/ 2); \t\t\t\t\t\tthis.center.splice(rowcount,1,this.maxval[rowcount] - this.radius[rowcount]); \t\t\t\t\t\trowcount = rowcount + 1;  \t\t\t\t\t} \t\t\t\t} \t\t\t\ttempRow = null; \t\t\t\tcount = count + 1; \t\t\t} \t\t\ttempRow = null; \t\t} \t \t}  } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u044f \u0441\u043d\u0430\u0447\u0430\u043b\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0442\u0440\u043e\u043a \u0438 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u044d\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c. <br \/>  \u041f\u043e\u0442\u043e\u043c \u043d\u0435\u043a\u0438\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u2014 \u0446\u0435\u043d\u0442\u0440, \u0440\u0430\u0434\u0438\u0443\u0441 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435(\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442, \u0434\u0430\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (\u0444\u0443\u043d\u043a\u0446\u0438\u044e) \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u2014 \u0443\u0431\u0440\u0430\u0442\u044c. \u00ab\u0426\u0435\u043d\u0442\u0440\u00bb \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<h5>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439.<\/h5>\n<p>  \u0412\u043e\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<h6>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <\/h6>\n<p>  <\/p>\n<pre><code class=\"javascript\">move: function(value,xyzw){ \tthis.column[xyzw] = this.column[xyzw].map(function(i){return i+value;})\t \tthis.updateByColumn(); } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u0438\u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. xyzw \u2014 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, value \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 10 \u0435\u0434\u0438\u043d\u0438\u0446, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434: move(10,0);<br \/>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u2014 updateByColumn.<\/p>\n<h6>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438.<\/h6>\n<p>  <\/p>\n<pre><code class=\"javascript\">toPoint:function(point){     if (point)     {         if(point.length == this.columnNumbers) \t{ \t    this.rows = this.rows.map(function(rowArray)                                             { \t\t\t\t                return rowArray.map(function(rowElement,index) \t\t\t                             { \t\t\t\t\t\t         return rowElement + point[index]; \t\t\t\t\t             }) \t\t                            });             this.updateByRow(); \t}\t\t \t} } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c. \u041e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043d \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445, \u00ab\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445\u00bb \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432.<\/p>\n<p>  <\/p>\n<h6>\u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/h6>\n<p>  <\/p>\n<pre><code class=\"javascript\">\trotate:function(angle,point,xyzType){ \t\tfunction multPointByValue(point,value){ \t\t\treturn point.map(function(val){return value * val}); \t\t} \t\tthis.toPoint(multPointByValue(point,-1)); \t\tvar rotateSource = []; \t\tvar radians = angle * Math.PI \/ 180.0;  \t\t \t\tswitch(xyzType){ \t\t\tcase &quot;byX&quot;: \t\t\t\trotateSource = [1,0,0, \t\t\t\t\t\t\t\t0,Math.cos(radians),Math.sin(radians), \t\t\t\t\t\t\t\t0,-1 * Math.sin(radians),Math.cos(radians) \t\t\t\t]; \t\t\t\tbreak; \t\t\tcase &quot;byY&quot;: \t\t\t\trotateSource = [Math.cos(radians),0,-1 * Math.sin(radians), \t\t\t\t\t\t\t\t0,1,0, \t\t\t\t\t\t\t\tMath.sin(radians),0,Math.cos(radians) \t\t\t\t\t\t\t\t]; \t\t\t\tbreak; \t\t\tcase &quot;byZ&quot;: \t\t\t\trotateSource = [Math.cos(radians),Math.sin(radians),0, \t\t\t\t\t\t\t\t-1 * Math.sin(radians),Math.cos(radians),0, \t\t\t\t\t\t\t\t0,0,1]; \t\t\t\tbreak;\t\t\t  \t\t} \t\t \t\tvar rotateMatrix = new botuMatrix(rotateSource,3); \t\tthis.rows = this.rows.map(function(irow){ \t\t\treturn vectorByMatrix(irow,rotateMatrix); \t\t}); \t\trotateMatrix = null; \t\trotateSource = null; \t\tthis.updateByRow(); \t\tthis.toPoint(point); \t} <\/code><\/pre>\n<p>  \u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 point \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0443\u0433\u043e\u043b angle, \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043e\u0441\u0438 xyzType. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043a \u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0441\u0438 xyzType, \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442. \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u043e\u0447\u043a\u0443 (\u0441\u0442\u0440\u043e\u043a\u0443) \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. <\/p>\n<h6>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b<\/h6>\n<p>  \u0423 \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0412\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432, \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u043e\u0447\u0435\u043a-\u0441\u0442\u0440\u043e\u043a (rows), \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442-\u043a\u043e\u043b\u043e\u043d\u043e\u043a (columns). \u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f 2 \u043c\u0435\u0442\u043e\u0434\u0430<\/p>\n<pre><code class=\"javascript\">updateByColumn:function(){ \tvar columnCount = 0; \twhile(columnCount &lt; this.columnNumbers) \t{ \t\tvar rowCount = 0; \t\twhile(rowCount &lt; this.rowNumbers) \t\t{ \t\t\tthis.rows[rowCount][columnCount] = this.column[columnCount][rowCount]; \t\t\tthis.source[columnCount + rowCount * this.columnNumbers] = this.column[columnCount][rowCount];  \t\t\trowCount++; \t\t}\t\t\t \t\tcolumnCount++; \t}\t },  updateByRow:function(){        var rowCount = 0; \twhile(rowCount &lt; this.rowNumbers) \t{ \t\tvar columnCount = 0; \t\twhile(columnCount &lt; this.columnNumbers) \t\t{ \t\t\tthis.column[columnCount][rowCount] = this.rows[rowCount][columnCount]; \t\t\tthis.source[columnCount + rowCount * this.columnNumbers] = this.column[columnCount][rowCount];  \t\t\tcolumnCount++; \t\t} \t\tcolumnCount = null;\t \t\trowCount++; \t}\t \tcolumnCount = null; \trowCount = null; },\t <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f vectorByMatrix \u2014 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043c\u044b \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u044f \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e. \u0415\u0441\u043b\u0438 \u0431 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430, \u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0431\u044b \u0432 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"javascript\">function vectorByMatrix(vector,matrix) { \t\/\/alert(vector); \tvar resultVector = []; \tif (vector.length == matrix.rowNumbers) \t{ \t\tvar columnCount = 0; \t\twhile(columnCount &lt; matrix.columnNumbers){ \t\t\tvar rowCount = 0; \t\t\tvar value = 0; \t\t\twhile(rowCount &lt; matrix.rowNumbers) \t\t\t{  \t\t\t\tvalue += vector[rowCount] * matrix.column[columnCount][rowCount];\t \t\t\t\trowCount++; \t\t\t} \t\t\t\/\/alert(value); \t\t\tresultVector.push(value); \t\t\tcolumnCount++; \t\t} \t}  \treturn resultVector; } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"javascript\">function vectorByMatrix(vector,matrix) { \tvar resultVector = []; \tif (vector.length == matrix.rowNumbers) \t{ \t\tvar columnCount = 0; \t\twhile(columnCount &lt; matrix.columnNumbers){ \t\t\tvar rowCount = 0; \t\t\tvar value = 0; \t\t\twhile(rowCount &lt; matrix.rowNumbers) \t\t\t{  \t\t\t\tvalue += vector[rowCount] * matrix.column[columnCount][rowCount];\t \t\t\t\trowCount++; \t\t\t} \t\t\tresultVector.push(value); \t\t\tcolumnCount++; \t\t} \t}  \treturn resultVector; }   function botuMatrix (source,columns) { \tthis.source = source; \tthis.columnNumbers = columns; \tthis.rowNumbers = source.length \/ columns; \tthis.rows = []; \tthis.minval = []; \tthis.maxval = []; \tthis.radius = []; \tthis.center = []; \tthis.column = [];  \t\t \tif (source.length &gt; 0) \t{ \t\tvar count = 0;  \t\twhile(count &lt; source.length) \t\t{ \t\t\tvar currentRow = this.source.slice(count,count + this.columnNumbers);\t\t \t\t    this.rows.push(currentRow); \t\t\t \t\t\tvar columnCount = 0; \t\t\twhile(columnCount &lt;= this.columnNumbers) \t\t\t{ \t\t\t\tif (!this.column[columnCount])  \t\t\t\t{ \t\t\t\t\tthis.column[columnCount] = []; \t\t\t\t} \t\t\t\tthis.column[columnCount].push(currentRow[columnCount]); \t\t\t\tcolumnCount += 1; \t\t\t} \t\t\t \t\t\tcount = count + this.columnNumbers;  \t\t}\t \t\tthis.rowNumbers = this.rows.length;  \t\t \t\tif (this.rows.length &gt; 0) \t\t{ \t\t\tcount = 0; \t\t\twhile(count &lt; this.rows.length) \t\t\t{ \t\t\t\tvar tempRow = this.rows[count].slice(0); \t\t\t\tif (count == 0 ) \t\t\t\t{ \t\t\t\t\tthis.minval = tempRow.slice(0); \t\t\t\t\tthis.maxval = tempRow.slice(0); \t\t\t\t\tthis.radius = tempRow.slice(0); \t\t\t\t\tthis.center = tempRow.slice(0); \t\t\t\t} \t\t\t \t\t\t\tif (count &gt; 0) \t\t\t\t{ \t\t\t\t\tvar rowcount = 0; \t\t\t\t\twhile(rowcount &lt; tempRow.length) \t\t\t\t\t{ \t\t\t\t\t\tthis.minval.splice(rowcount,1,Math.min(this.minval[rowcount],tempRow[rowcount])); \t\t\t\t\t \t\t\t\t\t\tthis.maxval.splice(rowcount,1,Math.max(this.maxval[rowcount],tempRow[rowcount])); \t\t\t\t\t\tthis.radius.splice(rowcount,1,(this.maxval[rowcount] - this.minval[rowcount]) \/ 2); \t\t\t\t\t\tthis.center.splice(rowcount,1,this.maxval[rowcount] - this.radius[rowcount]); \t\t\t\t\t\trowcount = rowcount + 1;  \t\t\t\t\t} \t\t\t\t} \t\t\t\ttempRow = undefined; \t\t\t\tcount = count + 1; \t\t\t} \t\t\ttempRow = undefined; \t\t} \t \t}  }  botuMatrix.prototype = { \tmove: function(value,xyzw){ \t\tthis.column[xyzw] = this.column[xyzw].map(function(i){return i+value;})\t \t\tthis.updateByColumn(); \t}, \tupdateByColumn:function(){ \t\tvar columnCount = 0; \t\twhile(columnCount &lt; this.columnNumbers) \t\t{ \t\t\tvar rowCount = 0; \t\t\twhile(rowCount &lt; this.rowNumbers) \t\t\t{ \t\t\t\tthis.rows[rowCount][columnCount] = this.column[columnCount][rowCount]; \t\t\t\tthis.source[columnCount + rowCount * this.columnNumbers] = this.column[columnCount][rowCount];  \t\t\t\trowCount++; \t\t\t} \t\t\t \t\t\tcolumnCount++; \t\t}\t \t}, \tupdateByRow:function(){ \t\tvar rowCount = 0; \t\twhile(rowCount &lt; this.rowNumbers) \t\t{ \t\t\tvar columnCount = 0; \t\t\twhile(columnCount &lt; this.columnNumbers) \t\t\t{ \t\t\t\tthis.column[columnCount][rowCount] = this.rows[rowCount][columnCount]; \t\t\t\tthis.source[columnCount + rowCount * this.columnNumbers] = this.column[columnCount][rowCount];  \t\t\t\tcolumnCount++; \t\t\t} \t\t\tcolumnCount = undefined; \t\t\t \t\t\trowCount++; \t\t}\t \t\tcolumnCount = undefined; \t\trowCount = undefined; },\t \ttoPoint:function(point){ \t\tif (point) \t\t{ \t\t\tif(point.length == this.columnNumbers) \t\t\t{ \t\t\t\tthis.rows = this.rows.map(function(rowArray){ \t\t\t\t\treturn rowArray.map(function(rowElement,index) \t\t\t\t\t{ \t\t\t\t\t\treturn rowElement + point[index]; \t\t\t\t\t} \t\t\t\t\t) \t\t\t\t}); \t\t\t\tthis.updateByRow(); \t\t\t}\t\t \t\t} \t}, \t \tbyPoint:function(point){ \t\tif (point) \t\t{ \t\t\tif(point.length == this.columnNumbers) \t\t\t{ \t\t\t\tthis.rows = this.rows.map(function(rowArray){ \t\t\t\t\treturn rowArray.map(function(rowElement,index) \t\t\t\t\t{ \t\t\t\t\t\treturn rowElement * point[index]; \t\t\t\t\t} \t\t\t\t\t) \t\t\t\t}); \t\t\t\tthis.updateByRow(); \t\t\t}\t\t \t\t} \t},\t \t \t \trotate:function(angle,point,xyzType){ \t\tfunction multPointByValue(point,value){ \t\t\treturn point.map(function(val){return value * val}); \t\t} \t\tthis.toPoint(multPointByValue(point,-1)); \t\tvar rotateSource = []; \t\tvar radians = angle * Math.PI \/ 180.0;  \t\t \t\tswitch(xyzType){ \t\t\tcase &quot;byX&quot;: \t\t\t\trotateSource = [1,0,0, \t\t\t\t\t\t\t\t0,Math.cos(radians),Math.sin(radians), \t\t\t\t\t\t\t\t0,-1 * Math.sin(radians),Math.cos(radians) \t\t\t\t]; \t\t\t\tbreak; \t\t\tcase &quot;byY&quot;: \t\t\t\trotateSource = [Math.cos(radians),0,-1 * Math.sin(radians), \t\t\t\t\t\t\t\t0,1,0, \t\t\t\t\t\t\t\tMath.sin(radians),0,Math.cos(radians) \t\t\t\t\t\t\t\t]; \t\t\t\tbreak; \t\t\tcase &quot;byZ&quot;: \t\t\t\trotateSource = [Math.cos(radians),Math.sin(radians),0, \t\t\t\t\t\t\t\t-1 * Math.sin(radians),Math.cos(radians),0, \t\t\t\t\t\t\t\t0,0,1]; \t\t\t\tbreak;\t\t\t  \t\t} \t\t \t\tvar rotateMatrix = new botuMatrix(rotateSource,3); \t\tthis.rows = this.rows.map(function(irow){ \t\t\treturn vectorByMatrix(irow,rotateMatrix); \t\t}); \t\trotateMatrix = null; \t\trotateSource = null; \t\tthis.updateByRow(); \t\tthis.toPoint(point); \t}  \t } <\/code><\/pre>\n<h5>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u041a\u043b\u0430\u0441\u0441 botuMatrix \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432. \u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432.<\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u2014 \u043a\u0443\u0431, \u0448\u0430\u0440, \u043f\u043b\u043e\u0441\u043a\u0430\u044f \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/227285\/\"> http:\/\/habrahabr.ru\/post\/227285\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0412 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/227201\/\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a><\/p>\n<h4>\u041c\u0430\u0442\u0440\u0438\u0446\u0430.<\/h4>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b \u2014 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u0430\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u0436\u0438\u0437\u043d\u044c. \u0423 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u044f \u0431\u044b \u0438\u0445 \u0432\u0441\u0435 \u0441\u0432\u0435\u043b \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u2014 \u00ab\u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0443\u0445 \u043e\u0442 \u043a\u043e\u0442\u043b\u0435\u0442\u00bb, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0442\u043e\u0447\u0435\u043a \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u0440\u043e\u043a, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u043e\u0439 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 x,y,z \u0438\u043b\u0438 w. \u0423 \u043c\u0435\u043d\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u00abw\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443. <\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u0432 \u043d\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043c\u043e\u0436\u043d\u043e \u0441 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043e\u0441\u0435\u0439 \u0438 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0446\u0435\u043d\u0442\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-227285","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/227285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=227285"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/227285\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=227285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=227285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=227285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}