| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Library VectorMath / Class mat4x4</title> |
| <link rel="stylesheet" type="text/css" |
| href="../styles.css" /> |
| <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css"> |
| <link rel="shortcut icon" href="../favicon.ico" /> |
| <script src="../client-static.js"></script> |
| |
| </head> |
| <body data-library="VectorMath" data-type="mat4x4"> |
| <div class="page"> |
| <div class="header"> |
| <a href="../index.html"><div class="logo"></div></a> |
| <a href="../index.html">Dart Documentation</a> |
| › <a href="../VectorMath.html">VectorMath</a> › <a href="../VectorMath/mat4x4.html">mat4x4</a></div> |
| <div class="nav"> |
| |
| <h2><div class="icon-library"></div><a href="../dart_core.html">dart:core</a></h2><h2><div class="icon-library"></div><a href="../dart_coreimpl.html">dart:coreimpl</a></h2><h2><div class="icon-library"></div><a href="../VectorMath.html">VectorMath</a></h2><ul class="icon"> |
| <li><a href="../VectorMath/vec2.html"><div class="icon-class"></div>vec2</a></li> |
| <li><a href="../VectorMath/vec3.html"><div class="icon-class"></div>vec3</a></li> |
| <li><a href="../VectorMath/vec4.html"><div class="icon-class"></div>vec4</a></li> |
| <li><a href="../VectorMath/mat2x2.html"><div class="icon-class"></div>mat2x2</a></li> |
| <li><a href="../VectorMath/mat2x3.html"><div class="icon-class"></div>mat2x3</a></li> |
| <li><a href="../VectorMath/mat2x4.html"><div class="icon-class"></div>mat2x4</a></li> |
| <li><a href="../VectorMath/mat3x2.html"><div class="icon-class"></div>mat3x2</a></li> |
| <li><a href="../VectorMath/mat3x3.html"><div class="icon-class"></div>mat3x3</a></li> |
| <li><a href="../VectorMath/mat3x4.html"><div class="icon-class"></div>mat3x4</a></li> |
| <li><a href="../VectorMath/mat4x2.html"><div class="icon-class"></div>mat4x2</a></li> |
| <li><a href="../VectorMath/mat4x3.html"><div class="icon-class"></div>mat4x3</a></li> |
| <li><div class="icon-class"></div><strong>mat4x4</strong></li> |
| <li><a href="../VectorMath/quat.html"><div class="icon-class"></div>quat</a></li> |
| </ul> |
| </div> |
| <div class="content"> |
| <h2>Class |
| <strong>mat4x4</strong></h2> |
| |
| <div class="doc"> |
| <p>mat4x4 is a column major matrix where each column is represented by <a class="crossref" href="../VectorMath/vec4.html">vec4</a>. This matrix has 4 columns and 4 rows.</p> |
| </div> |
| <h3>Constructors</h3> |
| <div class="method"><h4 id="mat4x4"> |
| <span class="show-code">Code</span> |
| new <strong>mat4x4</strong>([arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15]) <a class="anchor-link" href="#mat4x4" |
| title="Permalink to mat4x4.mat4x4">#</a></h4> |
| <div class="doc"> |
| <p>Constructs a new mat4x4. Supports GLSL like syntax so many possible inputs. Defaults to identity matrix.</p> |
| <pre class="source"> |
| mat4x4([Dynamic arg0, Dynamic arg1, Dynamic arg2, Dynamic arg3, Dynamic arg4, Dynamic arg5, Dynamic arg6, Dynamic arg7, Dynamic arg8, Dynamic arg9, Dynamic arg10, Dynamic arg11, Dynamic arg12, Dynamic arg13, Dynamic arg14, Dynamic arg15]) { |
| //Initialize the matrix as the identity matrix |
| col0 = new vec4(); |
| col1 = new vec4(); |
| col2 = new vec4(); |
| col3 = new vec4(); |
| col0[0] = 1.0; |
| col1[1] = 1.0; |
| col2[2] = 1.0; |
| col3[3] = 1.0; |
| if (arg0 is num && arg1 is num && arg2 is num && arg3 is num && arg4 is num && arg5 is num && arg6 is num && arg7 is num && arg8 is num && arg9 is num && arg10 is num && arg11 is num && arg12 is num && arg13 is num && arg14 is num && arg15 is num) { |
| col0[0] = arg0; |
| col0[1] = arg1; |
| col0[2] = arg2; |
| col0[3] = arg3; |
| col1[0] = arg4; |
| col1[1] = arg5; |
| col1[2] = arg6; |
| col1[3] = arg7; |
| col2[0] = arg8; |
| col2[1] = arg9; |
| col2[2] = arg10; |
| col2[3] = arg11; |
| col3[0] = arg12; |
| col3[1] = arg13; |
| col3[2] = arg14; |
| col3[3] = arg15; |
| return; |
| } |
| if (arg0 is num && arg1 == null && arg2 == null && arg3 == null && arg4 == null && arg5 == null && arg6 == null && arg7 == null && arg8 == null && arg9 == null && arg10 == null && arg11 == null && arg12 == null && arg13 == null && arg14 == null && arg15 == null) { |
| col0[0] = arg0; |
| col1[1] = arg0; |
| col2[2] = arg0; |
| col3[3] = arg0; |
| return; |
| } |
| if (arg0 is vec4 && arg1 is vec4 && arg2 is vec4 && arg3 is vec4) { |
| col0 = arg0; |
| col1 = arg1; |
| col2 = arg2; |
| col3 = arg3; |
| return; |
| } |
| if (arg0 is mat4x4) { |
| col0 = arg0.col0; |
| col1 = arg0.col1; |
| col2 = arg0.col2; |
| col3 = arg0.col3; |
| return; |
| } |
| if (arg0 is mat4x3) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col0[2] = arg0.col0[2]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col1[2] = arg0.col1[2]; |
| col2[0] = arg0.col2[0]; |
| col2[1] = arg0.col2[1]; |
| col2[2] = arg0.col2[2]; |
| col3[0] = arg0.col3[0]; |
| col3[1] = arg0.col3[1]; |
| col3[2] = arg0.col3[2]; |
| return; |
| } |
| if (arg0 is mat4x2) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col2[0] = arg0.col2[0]; |
| col2[1] = arg0.col2[1]; |
| col3[0] = arg0.col3[0]; |
| col3[1] = arg0.col3[1]; |
| return; |
| } |
| if (arg0 is mat3x4) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col0[2] = arg0.col0[2]; |
| col0[3] = arg0.col0[3]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col1[2] = arg0.col1[2]; |
| col1[3] = arg0.col1[3]; |
| col2[0] = arg0.col2[0]; |
| col2[1] = arg0.col2[1]; |
| col2[2] = arg0.col2[2]; |
| col2[3] = arg0.col2[3]; |
| return; |
| } |
| if (arg0 is mat3x3) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col0[2] = arg0.col0[2]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col1[2] = arg0.col1[2]; |
| col2[0] = arg0.col2[0]; |
| col2[1] = arg0.col2[1]; |
| col2[2] = arg0.col2[2]; |
| return; |
| } |
| if (arg0 is mat3x2) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col2[0] = arg0.col2[0]; |
| col2[1] = arg0.col2[1]; |
| return; |
| } |
| if (arg0 is mat2x4) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col0[2] = arg0.col0[2]; |
| col0[3] = arg0.col0[3]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col1[2] = arg0.col1[2]; |
| col1[3] = arg0.col1[3]; |
| return; |
| } |
| if (arg0 is mat2x3) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col0[2] = arg0.col0[2]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| col1[2] = arg0.col1[2]; |
| return; |
| } |
| if (arg0 is mat2x2) { |
| col0[0] = arg0.col0[0]; |
| col0[1] = arg0.col0[1]; |
| col1[0] = arg0.col1[0]; |
| col1[1] = arg0.col1[1]; |
| return; |
| } |
| if (arg0 is vec2 && arg1 == null && arg2 == null && arg3 == null && arg4 == null && arg5 == null && arg6 == null && arg7 == null && arg8 == null && arg9 == null && arg10 == null && arg11 == null && arg12 == null && arg13 == null && arg14 == null && arg15 == null) { |
| col0[0] = arg0[0]; |
| col1[1] = arg0[1]; |
| } |
| if (arg0 is vec3 && arg1 == null && arg2 == null && arg3 == null && arg4 == null && arg5 == null && arg6 == null && arg7 == null && arg8 == null && arg9 == null && arg10 == null && arg11 == null && arg12 == null && arg13 == null && arg14 == null && arg15 == null) { |
| col0[0] = arg0[0]; |
| col1[1] = arg0[1]; |
| col2[2] = arg0[2]; |
| } |
| if (arg0 is vec4 && arg1 == null && arg2 == null && arg3 == null && arg4 == null && arg5 == null && arg6 == null && arg7 == null && arg8 == null && arg9 == null && arg10 == null && arg11 == null && arg12 == null && arg13 == null && arg14 == null && arg15 == null) { |
| col0[0] = arg0[0]; |
| col1[1] = arg0[1]; |
| col2[2] = arg0[2]; |
| col3[3] = arg0[3]; |
| } |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="mat4x4"> |
| <span class="show-code">Code</span> |
| new <strong>mat4x4</strong>.outer(<a href="../VectorMath/vec4.html">vec4</a> u, <a href="../VectorMath/vec4.html">vec4</a> v) <a class="anchor-link" href="#mat4x4" |
| title="Permalink to mat4x4.mat4x4">#</a></h4> |
| <div class="doc"> |
| <p>Constructs a new mat4x4 from computing the outer product of |
| <span class="param">u</span> and |
| <span class="param">v</span>.</p> |
| <pre class="source"> |
| mat4x4.outer(vec4 u, vec4 v) { |
| col0[0] = u[0] * v[0]; |
| col0[1] = u[0] * v[1]; |
| col0[2] = u[0] * v[2]; |
| col0[3] = u[0] * v[3]; |
| col1[0] = u[1] * v[0]; |
| col1[1] = u[1] * v[1]; |
| col1[2] = u[1] * v[2]; |
| col1[3] = u[1] * v[3]; |
| col2[0] = u[2] * v[0]; |
| col2[1] = u[2] * v[1]; |
| col2[2] = u[2] * v[2]; |
| col2[3] = u[2] * v[3]; |
| col3[0] = u[3] * v[0]; |
| col3[1] = u[3] * v[1]; |
| col3[2] = u[3] * v[2]; |
| col3[3] = u[3] * v[3]; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="mat4x4"> |
| <span class="show-code">Code</span> |
| new <strong>mat4x4</strong>.zero() <a class="anchor-link" href="#mat4x4" |
| title="Permalink to mat4x4.mat4x4">#</a></h4> |
| <div class="doc"> |
| <p>Constructs a new mat4x4 filled with zeros.</p> |
| <pre class="source"> |
| mat4x4.zero() { |
| col0[0] = 0.0; |
| col0[1] = 0.0; |
| col0[2] = 0.0; |
| col0[3] = 0.0; |
| col1[0] = 0.0; |
| col1[1] = 0.0; |
| col1[2] = 0.0; |
| col1[3] = 0.0; |
| col2[0] = 0.0; |
| col2[1] = 0.0; |
| col2[2] = 0.0; |
| col2[3] = 0.0; |
| col3[0] = 0.0; |
| col3[1] = 0.0; |
| col3[2] = 0.0; |
| col3[3] = 0.0; |
| } |
| </pre> |
| </div> |
| </div> |
| <h3>Methods</h3> |
| <div class="method"><h4 id="toString"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/String.html">String</a> <strong>toString</strong>() <a class="anchor-link" href="#toString" |
| title="Permalink to mat4x4.toString">#</a></h4> |
| <div class="doc"> |
| <p>Returns a printable string</p> |
| <pre class="source"> |
| String toString() { |
| String s = ''; |
| s += '[0] ${getRow(0)}\n'; |
| s += '[1] ${getRow(1)}\n'; |
| s += '[2] ${getRow(2)}\n'; |
| s += '[3] ${getRow(3)}\n'; |
| return s; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:rows"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>get rows</strong>() <a class="anchor-link" href="#get:rows" |
| title="Permalink to mat4x4.get rows">#</a></h4> |
| <div class="doc"> |
| <p>Returns the number of rows in the matrix.</p> |
| <pre class="source"> |
| num get rows() => 4; |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:cols"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>get cols</strong>() <a class="anchor-link" href="#get:cols" |
| title="Permalink to mat4x4.get cols">#</a></h4> |
| <div class="doc"> |
| <p>Returns the number of columns in the matrix.</p> |
| <pre class="source"> |
| num get cols() => 4; |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:length"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>get length</strong>() <a class="anchor-link" href="#get:length" |
| title="Permalink to mat4x4.get length">#</a></h4> |
| <div class="doc"> |
| <p>Returns the number of columns in the matrix.</p> |
| <pre class="source"> |
| num get length() => 4; |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id=":index"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>operator []</strong>(<a href="../dart_core/int.html">int</a> column) <a class="anchor-link" href="#:index" |
| title="Permalink to mat4x4.operator []">#</a></h4> |
| <div class="doc"> |
| <p>Gets the |
| <span class="param">column</span> of the matrix</p> |
| <pre class="source"> |
| vec4 operator[](int column) { |
| assert(column >= 0 && column < 4); |
| switch (column) { |
| case 0: return col0; break; |
| case 1: return col1; break; |
| case 2: return col2; break; |
| case 3: return col3; break; |
| } |
| throw new IllegalArgumentException(column); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id=":setindex"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>operator []=</strong>(<a href="../dart_core/int.html">int</a> column, <a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#:setindex" |
| title="Permalink to mat4x4.operator []=">#</a></h4> |
| <div class="doc"> |
| <p>Assigns the |
| <span class="param">column</span> of the matrix |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| vec4 operator[]=(int column, vec4 arg) { |
| assert(column >= 0 && column < 4); |
| switch (column) { |
| case 0: col0 = arg; return col0; break; |
| case 1: col1 = arg; return col1; break; |
| case 2: col2 = arg; return col2; break; |
| case 3: col3 = arg; return col3; break; |
| } |
| throw new IllegalArgumentException(column); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:row0"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>get row0</strong>() <a class="anchor-link" href="#get:row0" |
| title="Permalink to mat4x4.get row0">#</a></h4> |
| <div class="doc"> |
| <p>Returns row 0</p> |
| <pre class="source"> |
| vec4 get row0() => getRow(0); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="set:row0"> |
| <span class="show-code">Code</span> |
| <strong>set row0</strong>(<a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#set:row0" |
| title="Permalink to mat4x4.set row0">#</a></h4> |
| <div class="doc"> |
| <p>Sets row 0 to |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| set row0(vec4 arg) => setRow(0, arg); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:row1"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>get row1</strong>() <a class="anchor-link" href="#get:row1" |
| title="Permalink to mat4x4.get row1">#</a></h4> |
| <div class="doc"> |
| <p>Returns row 1</p> |
| <pre class="source"> |
| vec4 get row1() => getRow(1); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="set:row1"> |
| <span class="show-code">Code</span> |
| <strong>set row1</strong>(<a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#set:row1" |
| title="Permalink to mat4x4.set row1">#</a></h4> |
| <div class="doc"> |
| <p>Sets row 1 to |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| set row1(vec4 arg) => setRow(1, arg); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:row2"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>get row2</strong>() <a class="anchor-link" href="#get:row2" |
| title="Permalink to mat4x4.get row2">#</a></h4> |
| <div class="doc"> |
| <p>Returns row 2</p> |
| <pre class="source"> |
| vec4 get row2() => getRow(2); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="set:row2"> |
| <span class="show-code">Code</span> |
| <strong>set row2</strong>(<a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#set:row2" |
| title="Permalink to mat4x4.set row2">#</a></h4> |
| <div class="doc"> |
| <p>Sets row 2 to |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| set row2(vec4 arg) => setRow(2, arg); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="get:row3"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>get row3</strong>() <a class="anchor-link" href="#get:row3" |
| title="Permalink to mat4x4.get row3">#</a></h4> |
| <div class="doc"> |
| <p>Returns row 3</p> |
| <pre class="source"> |
| vec4 get row3() => getRow(3); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="set:row3"> |
| <span class="show-code">Code</span> |
| <strong>set row3</strong>(<a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#set:row3" |
| title="Permalink to mat4x4.set row3">#</a></h4> |
| <div class="doc"> |
| <p>Sets row 3 to |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| set row3(vec4 arg) => setRow(3, arg); |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="setRow"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/void.html">void</a> <strong>setRow</strong>(<a href="../dart_core/int.html">int</a> row, <a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#setRow" |
| title="Permalink to mat4x4.setRow">#</a></h4> |
| <div class="doc"> |
| <p>Assigns the <code>column</code> of the matrix |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| void setRow(int row, vec4 arg) { |
| assert(row >= 0 && row < 4); |
| this[0][row] = arg[0]; |
| this[1][row] = arg[1]; |
| this[2][row] = arg[2]; |
| this[3][row] = arg[3]; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="getRow"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>getRow</strong>(<a href="../dart_core/int.html">int</a> row) <a class="anchor-link" href="#getRow" |
| title="Permalink to mat4x4.getRow">#</a></h4> |
| <div class="doc"> |
| <p>Gets the |
| <span class="param">row</span> of the matrix</p> |
| <pre class="source"> |
| vec4 getRow(int row) { |
| assert(row >= 0 && row < 4); |
| vec4 r = new vec4(); |
| r[0] = this[0][row]; |
| r[1] = this[1][row]; |
| r[2] = this[2][row]; |
| r[3] = this[3][row]; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="setColumn"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/void.html">void</a> <strong>setColumn</strong>(<a href="../dart_core/int.html">int</a> column, <a href="../VectorMath/vec4.html">vec4</a> arg) <a class="anchor-link" href="#setColumn" |
| title="Permalink to mat4x4.setColumn">#</a></h4> |
| <div class="doc"> |
| <p>Assigns the |
| <span class="param">column</span> of the matrix |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| void setColumn(int column, vec4 arg) { |
| assert(column >= 0 && column < 4); |
| this[column] = arg; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="getColumn"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>getColumn</strong>(<a href="../dart_core/int.html">int</a> column) <a class="anchor-link" href="#getColumn" |
| title="Permalink to mat4x4.getColumn">#</a></h4> |
| <div class="doc"> |
| <p>Gets the |
| <span class="param">column</span> of the matrix</p> |
| <pre class="source"> |
| vec4 getColumn(int column) { |
| assert(column >= 0 && column < 4); |
| return new vec4(this[column]); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id=":mul"> |
| <span class="show-code">Code</span> |
| <strong>operator *</strong>(arg) <a class="anchor-link" href="#:mul" |
| title="Permalink to mat4x4.operator *">#</a></h4> |
| <div class="doc"> |
| <p>Returns a new vector or matrix by multiplying <code>this</code> with |
| <span class="param">arg</span>.</p> |
| <pre class="source"> |
| Dynamic operator*(Dynamic arg) { |
| if (arg is num) { |
| mat4x4 r = new mat4x4(); |
| r[0][0] = this[0][0] * arg; |
| r[0][1] = this[0][1] * arg; |
| r[0][2] = this[0][2] * arg; |
| r[0][3] = this[0][3] * arg; |
| r[1][0] = this[1][0] * arg; |
| r[1][1] = this[1][1] * arg; |
| r[1][2] = this[1][2] * arg; |
| r[1][3] = this[1][3] * arg; |
| r[2][0] = this[2][0] * arg; |
| r[2][1] = this[2][1] * arg; |
| r[2][2] = this[2][2] * arg; |
| r[2][3] = this[2][3] * arg; |
| r[3][0] = this[3][0] * arg; |
| r[3][1] = this[3][1] * arg; |
| r[3][2] = this[3][2] * arg; |
| r[3][3] = this[3][3] * arg; |
| return r; |
| } |
| if (arg is vec4) { |
| vec4 r = new vec4(); |
| r[0] = dot(row0, arg); |
| r[1] = dot(row1, arg); |
| r[2] = dot(row2, arg); |
| r[3] = dot(row3, arg); |
| return r; |
| } |
| if (4 == arg.cols) { |
| Dynamic r = null; |
| if (arg.rows == 2) { |
| r = new mat4x2(); |
| } |
| if (arg.rows == 3) { |
| r = new mat4x3(); |
| } |
| if (arg.rows == 4) { |
| r = new mat4x4(); |
| } |
| for (int j = 0; j < arg.rows; j++) { |
| r[0][j] = dot(this.getRow(0), arg.getColumn(j)); |
| } |
| for (int j = 0; j < arg.rows; j++) { |
| r[1][j] = dot(this.getRow(1), arg.getColumn(j)); |
| } |
| for (int j = 0; j < arg.rows; j++) { |
| r[2][j] = dot(this.getRow(2), arg.getColumn(j)); |
| } |
| for (int j = 0; j < arg.rows; j++) { |
| r[3][j] = dot(this.getRow(3), arg.getColumn(j)); |
| } |
| return r; |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id=":add"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/mat4x4.html">mat4x4</a> <strong>operator +</strong>(<a href="../VectorMath/mat4x4.html">mat4x4</a> arg) <a class="anchor-link" href="#:add" |
| title="Permalink to mat4x4.operator +">#</a></h4> |
| <div class="doc"> |
| <p>Returns new matrix after component wise <code>this</code> + |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| mat4x4 operator+(mat4x4 arg) { |
| mat4x4 r = new mat4x4(); |
| r[0][0] = this[0][0] + arg[0][0]; |
| r[0][1] = this[0][1] + arg[0][1]; |
| r[0][2] = this[0][2] + arg[0][2]; |
| r[0][3] = this[0][3] + arg[0][3]; |
| r[1][0] = this[1][0] + arg[1][0]; |
| r[1][1] = this[1][1] + arg[1][1]; |
| r[1][2] = this[1][2] + arg[1][2]; |
| r[1][3] = this[1][3] + arg[1][3]; |
| r[2][0] = this[2][0] + arg[2][0]; |
| r[2][1] = this[2][1] + arg[2][1]; |
| r[2][2] = this[2][2] + arg[2][2]; |
| r[2][3] = this[2][3] + arg[2][3]; |
| r[3][0] = this[3][0] + arg[3][0]; |
| r[3][1] = this[3][1] + arg[3][1]; |
| r[3][2] = this[3][2] + arg[3][2]; |
| r[3][3] = this[3][3] + arg[3][3]; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id=":sub"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/mat4x4.html">mat4x4</a> <strong>operator -</strong>(<a href="../VectorMath/mat4x4.html">mat4x4</a> arg) <a class="anchor-link" href="#:sub" |
| title="Permalink to mat4x4.operator -">#</a></h4> |
| <div class="doc"> |
| <p>Returns new matrix after component wise <code>this</code> - |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| mat4x4 operator-(mat4x4 arg) { |
| mat4x4 r = new mat4x4(); |
| r[0][0] = this[0][0] - arg[0][0]; |
| r[0][1] = this[0][1] - arg[0][1]; |
| r[0][2] = this[0][2] - arg[0][2]; |
| r[0][3] = this[0][3] - arg[0][3]; |
| r[1][0] = this[1][0] - arg[1][0]; |
| r[1][1] = this[1][1] - arg[1][1]; |
| r[1][2] = this[1][2] - arg[1][2]; |
| r[1][3] = this[1][3] - arg[1][3]; |
| r[2][0] = this[2][0] - arg[2][0]; |
| r[2][1] = this[2][1] - arg[2][1]; |
| r[2][2] = this[2][2] - arg[2][2]; |
| r[2][3] = this[2][3] - arg[2][3]; |
| r[3][0] = this[3][0] - arg[3][0]; |
| r[3][1] = this[3][1] - arg[3][1]; |
| r[3][2] = this[3][2] - arg[3][2]; |
| r[3][3] = this[3][3] - arg[3][3]; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id=":negate"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/mat4x4.html">mat4x4</a> <strong>operator negate</strong>() <a class="anchor-link" href="#:negate" |
| title="Permalink to mat4x4.operator negate">#</a></h4> |
| <div class="doc"> |
| <p>Returns new matrix -this</p> |
| <pre class="source"> |
| mat4x4 operator negate() { |
| mat4x4 r = new mat4x4(); |
| r[0] = -this[0]; |
| r[1] = -this[1]; |
| r[2] = -this[2]; |
| r[3] = -this[3]; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="transposed"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/mat4x4.html">mat4x4</a> <strong>transposed</strong>() <a class="anchor-link" href="#transposed" |
| title="Permalink to mat4x4.transposed">#</a></h4> |
| <div class="doc"> |
| <p>Returns the tranpose of this.</p> |
| <pre class="source"> |
| mat4x4 transposed() { |
| mat4x4 r = new mat4x4(); |
| r[0][0] = this[0][0]; |
| r[1][0] = this[0][1]; |
| r[2][0] = this[0][2]; |
| r[3][0] = this[0][3]; |
| r[0][1] = this[1][0]; |
| r[1][1] = this[1][1]; |
| r[2][1] = this[1][2]; |
| r[3][1] = this[1][3]; |
| r[0][2] = this[2][0]; |
| r[1][2] = this[2][1]; |
| r[2][2] = this[2][2]; |
| r[3][2] = this[2][3]; |
| r[0][3] = this[3][0]; |
| r[1][3] = this[3][1]; |
| r[2][3] = this[3][2]; |
| r[3][3] = this[3][3]; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="absolute"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/mat4x4.html">mat4x4</a> <strong>absolute</strong>() <a class="anchor-link" href="#absolute" |
| title="Permalink to mat4x4.absolute">#</a></h4> |
| <div class="doc"> |
| <p>Returns the component wise absolute value of this.</p> |
| <pre class="source"> |
| mat4x4 absolute() { |
| mat4x4 r = new mat4x4(); |
| r[0][0] = this[0][0].abs(); |
| r[0][1] = this[0][1].abs(); |
| r[0][2] = this[0][2].abs(); |
| r[0][3] = this[0][3].abs(); |
| r[1][0] = this[1][0].abs(); |
| r[1][1] = this[1][1].abs(); |
| r[1][2] = this[1][2].abs(); |
| r[1][3] = this[1][3].abs(); |
| r[2][0] = this[2][0].abs(); |
| r[2][1] = this[2][1].abs(); |
| r[2][2] = this[2][2].abs(); |
| r[2][3] = this[2][3].abs(); |
| r[3][0] = this[3][0].abs(); |
| r[3][1] = this[3][1].abs(); |
| r[3][2] = this[3][2].abs(); |
| r[3][3] = this[3][3].abs(); |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="determinant"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>determinant</strong>() <a class="anchor-link" href="#determinant" |
| title="Permalink to mat4x4.determinant">#</a></h4> |
| <div class="doc"> |
| <p>Returns the determinant of this matrix.</p> |
| <pre class="source"> |
| num determinant() { |
| //2x2 sub-determinants |
| num det2_01_01 = this[0][0] * this[1][1] - this[0][1] * this[1][0]; |
| num det2_01_02 = this[0][0] * this[1][2] - this[0][2] * this[1][0]; |
| num det2_01_03 = this[0][0] * this[1][3] - this[0][3] * this[1][0]; |
| num det2_01_12 = this[0][1] * this[1][2] - this[0][2] * this[1][1]; |
| num det2_01_13 = this[0][1] * this[1][3] - this[0][3] * this[1][1]; |
| num det2_01_23 = this[0][2] * this[1][3] - this[0][3] * this[1][2]; |
| |
| //3x3 sub-determinants |
| num det3_201_012 = this[2][0] * det2_01_12 - this[2][1] * det2_01_02 + this[2][2] * det2_01_01; |
| num det3_201_013 = this[2][0] * det2_01_13 - this[2][1] * det2_01_03 + this[2][3] * det2_01_01; |
| num det3_201_023 = this[2][0] * det2_01_23 - this[2][2] * det2_01_03 + this[2][3] * det2_01_02; |
| num det3_201_123 = this[2][1] * det2_01_23 - this[2][2] * det2_01_13 + this[2][3] * det2_01_12; |
| |
| return ( - det3_201_123 * this[3][0] + det3_201_023 * this[3][1] - det3_201_013 * this[3][2] + det3_201_012 * this[3][3] ); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="trace"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>trace</strong>() <a class="anchor-link" href="#trace" |
| title="Permalink to mat4x4.trace">#</a></h4> |
| <div class="doc"> |
| <p>Returns the trace of the matrix. The trace of a matrix is the sum of the diagonal entries</p> |
| <pre class="source"> |
| num trace() { |
| num t = 0.0; |
| t += this[0][0]; |
| t += this[1][1]; |
| t += this[2][2]; |
| t += this[3][3]; |
| return t; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="infinityNorm"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>infinityNorm</strong>() <a class="anchor-link" href="#infinityNorm" |
| title="Permalink to mat4x4.infinityNorm">#</a></h4> |
| <div class="doc"> |
| <p>Returns infinity norm of the matrix. Used for numerical analysis.</p> |
| <pre class="source"> |
| num infinityNorm() { |
| num norm = 0.0; |
| { |
| num row_norm = 0.0; |
| row_norm += this[0][0].abs(); |
| row_norm += this[0][1].abs(); |
| row_norm += this[0][2].abs(); |
| row_norm += this[0][3].abs(); |
| norm = row_norm > norm ? row_norm : norm; |
| } |
| { |
| num row_norm = 0.0; |
| row_norm += this[1][0].abs(); |
| row_norm += this[1][1].abs(); |
| row_norm += this[1][2].abs(); |
| row_norm += this[1][3].abs(); |
| norm = row_norm > norm ? row_norm : norm; |
| } |
| { |
| num row_norm = 0.0; |
| row_norm += this[2][0].abs(); |
| row_norm += this[2][1].abs(); |
| row_norm += this[2][2].abs(); |
| row_norm += this[2][3].abs(); |
| norm = row_norm > norm ? row_norm : norm; |
| } |
| { |
| num row_norm = 0.0; |
| row_norm += this[3][0].abs(); |
| row_norm += this[3][1].abs(); |
| row_norm += this[3][2].abs(); |
| row_norm += this[3][3].abs(); |
| norm = row_norm > norm ? row_norm : norm; |
| } |
| return norm; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="relativeError"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>relativeError</strong>(<a href="../VectorMath/mat4x4.html">mat4x4</a> correct) <a class="anchor-link" href="#relativeError" |
| title="Permalink to mat4x4.relativeError">#</a></h4> |
| <div class="doc"> |
| <p>Returns relative error between <code>this</code> and |
| <span class="param">correct</span></p> |
| <pre class="source"> |
| num relativeError(mat4x4 correct) { |
| num this_norm = infinityNorm(); |
| num correct_norm = correct.infinityNorm(); |
| num diff_norm = (this_norm - correct_norm).abs(); |
| return diff_norm/correct_norm; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="absoluteError"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/num.html">num</a> <strong>absoluteError</strong>(<a href="../VectorMath/mat4x4.html">mat4x4</a> correct) <a class="anchor-link" href="#absoluteError" |
| title="Permalink to mat4x4.absoluteError">#</a></h4> |
| <div class="doc"> |
| <p>Returns absolute error between <code>this</code> and |
| <span class="param">correct</span></p> |
| <pre class="source"> |
| num absoluteError(mat4x4 correct) { |
| num this_norm = infinityNorm(); |
| num correct_norm = correct.infinityNorm(); |
| num diff_norm = (this_norm - correct_norm).abs(); |
| return diff_norm; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="getTranslation"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec3.html">vec3</a> <strong>getTranslation</strong>() <a class="anchor-link" href="#getTranslation" |
| title="Permalink to mat4x4.getTranslation">#</a></h4> |
| <div class="doc"> |
| <p>Returns the translation vector from this homogeneous transformation matrix.</p> |
| <pre class="source"> |
| vec3 getTranslation() { |
| return new vec3(col3.x, col3.y, col3.z); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="setTranslation"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/void.html">void</a> <strong>setTranslation</strong>(<a href="../VectorMath/vec3.html">vec3</a> T) <a class="anchor-link" href="#setTranslation" |
| title="Permalink to mat4x4.setTranslation">#</a></h4> |
| <div class="doc"> |
| <p>Sets the translation vector in this homogeneous transformation matrix.</p> |
| <pre class="source"> |
| void setTranslation(vec3 T) { |
| col3.xyz = T; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="getRotation"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/mat3x3.html">mat3x3</a> <strong>getRotation</strong>() <a class="anchor-link" href="#getRotation" |
| title="Permalink to mat4x4.getRotation">#</a></h4> |
| <div class="doc"> |
| <p>Returns the rotation matrix from this homogeneous transformation matrix.</p> |
| <pre class="source"> |
| mat3x3 getRotation() { |
| mat3x3 r = new mat3x3(); |
| r.col0 = new vec3(this.col0.x,this.col0.y,this.col0.z); |
| r.col1 = new vec3(this.col1.x,this.col1.y,this.col1.z); |
| r.col2 = new vec3(this.col2.x,this.col2.y,this.col2.z); |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="setRotation"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/void.html">void</a> <strong>setRotation</strong>(<a href="../VectorMath/mat3x3.html">mat3x3</a> rotation) <a class="anchor-link" href="#setRotation" |
| title="Permalink to mat4x4.setRotation">#</a></h4> |
| <div class="doc"> |
| <p>Sets the rotation matrix in this homogeneous transformation matrix.</p> |
| <pre class="source"> |
| void setRotation(mat3x3 rotation) { |
| this.col0.xyz = rotation.col0; |
| this.col1.xyz = rotation.col1; |
| this.col2.xyz = rotation.col2; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="transposeRotation"> |
| <span class="show-code">Code</span> |
| <a href="../dart_core/void.html">void</a> <strong>transposeRotation</strong>() <a class="anchor-link" href="#transposeRotation" |
| title="Permalink to mat4x4.transposeRotation">#</a></h4> |
| <div class="doc"> |
| <p>Transposes just the upper 3x3 rotation matrix.</p> |
| <pre class="source"> |
| void transposeRotation() { |
| num temp; |
| temp = this[0][0]; |
| this[0][0] = this[0][0]; |
| this[0][0] = temp; |
| temp = this[0][1]; |
| this[0][1] = this[1][0]; |
| this[1][0] = temp; |
| temp = this[0][2]; |
| this[0][2] = this[2][0]; |
| this[2][0] = temp; |
| temp = this[1][0]; |
| this[1][0] = this[0][1]; |
| this[0][1] = temp; |
| temp = this[1][1]; |
| this[1][1] = this[1][1]; |
| this[1][1] = temp; |
| temp = this[1][2]; |
| this[1][2] = this[2][1]; |
| this[2][1] = temp; |
| temp = this[2][0]; |
| this[2][0] = this[0][2]; |
| this[0][2] = temp; |
| temp = this[2][1]; |
| this[2][1] = this[1][2]; |
| this[1][2] = temp; |
| temp = this[2][2]; |
| this[2][2] = this[2][2]; |
| this[2][2] = temp; |
| } |
| </pre> |
| </div> |
| </div> |
| <h3>Fields</h3> |
| <div class="field"><h4 id="col0"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>col0</strong> <a class="anchor-link" |
| href="#col0" |
| title="Permalink to mat4x4.col0">#</a> |
| </h4> |
| <div class="doc"> |
| |
| <pre class="source"> |
| vec4 col0; |
| </pre> |
| </div> |
| </div> |
| <div class="field"><h4 id="col1"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>col1</strong> <a class="anchor-link" |
| href="#col1" |
| title="Permalink to mat4x4.col1">#</a> |
| </h4> |
| <div class="doc"> |
| |
| <pre class="source"> |
| vec4 col1; |
| </pre> |
| </div> |
| </div> |
| <div class="field"><h4 id="col2"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>col2</strong> <a class="anchor-link" |
| href="#col2" |
| title="Permalink to mat4x4.col2">#</a> |
| </h4> |
| <div class="doc"> |
| |
| <pre class="source"> |
| vec4 col2; |
| </pre> |
| </div> |
| </div> |
| <div class="field"><h4 id="col3"> |
| <span class="show-code">Code</span> |
| <a href="../VectorMath/vec4.html">vec4</a> <strong>col3</strong> <a class="anchor-link" |
| href="#col3" |
| title="Permalink to mat4x4.col3">#</a> |
| </h4> |
| <div class="doc"> |
| |
| <pre class="source"> |
| vec4 col3; |
| </pre> |
| </div> |
| </div> |
| </div> |
| <div class="clear"></div> |
| </div> |
| <div class="footer"></div> |
| </body></html> |
| |