blob: 2520361c97a73cdab22cd72271fad2099b7a8e90 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Library VectorMath / Class mat3x2</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="mat3x2">
<div class="page">
<div class="header">
<a href="../index.html"><div class="logo"></div></a>
<a href="../index.html">Dart Documentation</a>
&rsaquo; <a href="../VectorMath.html">VectorMath</a> &rsaquo; <a href="../VectorMath/mat3x2.html">mat3x2</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><div class="icon-class"></div><strong>mat3x2</strong></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><a href="../VectorMath/mat4x4.html"><div class="icon-class"></div>mat4x4</a></li>
<li><a href="../VectorMath/quat.html"><div class="icon-class"></div>quat</a></li>
</ul>
</div>
<div class="content">
<h2>Class
<strong>mat3x2</strong></h2>
<div class="doc">
<p>mat3x2 is a column major matrix where each column is represented by <a class="crossref" href="../VectorMath/vec2.html">vec2</a>. This matrix has 3 columns and 2 rows.</p>
</div>
<h3>Constructors</h3>
<div class="method"><h4 id="mat3x2">
<span class="show-code">Code</span>
new <strong>mat3x2</strong>([arg0, arg1, arg2, arg3, arg4, arg5]) <a class="anchor-link" href="#mat3x2"
title="Permalink to mat3x2.mat3x2">#</a></h4>
<div class="doc">
<p>Constructs a new mat3x2. Supports GLSL like syntax so many possible inputs. Defaults to identity matrix.</p>
<pre class="source">
mat3x2([Dynamic arg0, Dynamic arg1, Dynamic arg2, Dynamic arg3, Dynamic arg4, Dynamic arg5]) {
//Initialize the matrix as the identity matrix
col0 = new vec2();
col1 = new vec2();
col2 = new vec2();
col0[0] = 1.0;
col1[1] = 1.0;
if (arg0 is num &amp;&amp; arg1 is num &amp;&amp; arg2 is num &amp;&amp; arg3 is num &amp;&amp; arg4 is num &amp;&amp; arg5 is num) {
col0[0] = arg0;
col0[1] = arg1;
col1[0] = arg2;
col1[1] = arg3;
col2[0] = arg4;
col2[1] = arg5;
return;
}
if (arg0 is num &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null) {
col0[0] = arg0;
col1[1] = arg0;
return;
}
if (arg0 is vec3 &amp;&amp; arg1 is vec3 &amp;&amp; arg2 is vec3) {
col0 = arg0;
col1 = arg1;
col2 = arg2;
return;
}
if (arg0 is mat3x2) {
col0 = arg0.col0;
col1 = arg0.col1;
col2 = arg0.col2;
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 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null) {
col0[0] = arg0[0];
col1[1] = arg0[1];
}
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat3x2">
<span class="show-code">Code</span>
new <strong>mat3x2</strong>.outer(<a href="../VectorMath/vec3.html">vec3</a> u, <a href="../VectorMath/vec2.html">vec2</a> v) <a class="anchor-link" href="#mat3x2"
title="Permalink to mat3x2.mat3x2">#</a></h4>
<div class="doc">
<p>Constructs a new mat3x2 from computing the outer product of
<span class="param">u</span> and
<span class="param">v</span>.</p>
<pre class="source">
mat3x2.outer(vec3 u, vec2 v) {
col0[0] = u[0] * v[0];
col0[1] = u[0] * v[1];
col1[0] = u[1] * v[0];
col1[1] = u[1] * v[1];
col2[0] = u[2] * v[0];
col2[1] = u[2] * v[1];
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat3x2">
<span class="show-code">Code</span>
new <strong>mat3x2</strong>.zero() <a class="anchor-link" href="#mat3x2"
title="Permalink to mat3x2.mat3x2">#</a></h4>
<div class="doc">
<p>Constructs a new mat3x2 filled with zeros.</p>
<pre class="source">
mat3x2.zero() {
col0[0] = 0.0;
col0[1] = 0.0;
col1[0] = 0.0;
col1[1] = 0.0;
col2[0] = 0.0;
col2[1] = 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 mat3x2.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';
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 mat3x2.get rows">#</a></h4>
<div class="doc">
<p>Returns the number of rows in the matrix.</p>
<pre class="source">
num get rows() =&gt; 2;
</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 mat3x2.get cols">#</a></h4>
<div class="doc">
<p>Returns the number of columns in the matrix.</p>
<pre class="source">
num get cols() =&gt; 3;
</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 mat3x2.get length">#</a></h4>
<div class="doc">
<p>Returns the number of columns in the matrix.</p>
<pre class="source">
num get length() =&gt; 3;
</pre>
</div>
</div>
<div class="method"><h4 id=":index">
<span class="show-code">Code</span>
<a href="../VectorMath/vec2.html">vec2</a> <strong>operator []</strong>(<a href="../dart_core/int.html">int</a> column) <a class="anchor-link" href="#:index"
title="Permalink to mat3x2.operator []">#</a></h4>
<div class="doc">
<p>Gets the
<span class="param">column</span> of the matrix</p>
<pre class="source">
vec2 operator[](int column) {
assert(column &gt;= 0 &amp;&amp; column &lt; 3);
switch (column) {
case 0: return col0; break;
case 1: return col1; break;
case 2: return col2; break;
}
throw new IllegalArgumentException(column);
}
</pre>
</div>
</div>
<div class="method"><h4 id=":setindex">
<span class="show-code">Code</span>
<a href="../VectorMath/vec2.html">vec2</a> <strong>operator []=</strong>(<a href="../dart_core/int.html">int</a> column, <a href="../VectorMath/vec2.html">vec2</a> arg) <a class="anchor-link" href="#:setindex"
title="Permalink to mat3x2.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">
vec2 operator[]=(int column, vec2 arg) {
assert(column &gt;= 0 &amp;&amp; column &lt; 3);
switch (column) {
case 0: col0 = arg; return col0; break;
case 1: col1 = arg; return col1; break;
case 2: col2 = arg; return col2; break;
}
throw new IllegalArgumentException(column);
}
</pre>
</div>
</div>
<div class="method"><h4 id="get:row0">
<span class="show-code">Code</span>
<a href="../VectorMath/vec3.html">vec3</a> <strong>get row0</strong>() <a class="anchor-link" href="#get:row0"
title="Permalink to mat3x2.get row0">#</a></h4>
<div class="doc">
<p>Returns row 0</p>
<pre class="source">
vec3 get row0() =&gt; 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/vec3.html">vec3</a> arg) <a class="anchor-link" href="#set:row0"
title="Permalink to mat3x2.set row0">#</a></h4>
<div class="doc">
<p>Sets row 0 to
<span class="param">arg</span></p>
<pre class="source">
set row0(vec3 arg) =&gt; setRow(0, arg);
</pre>
</div>
</div>
<div class="method"><h4 id="get:row1">
<span class="show-code">Code</span>
<a href="../VectorMath/vec3.html">vec3</a> <strong>get row1</strong>() <a class="anchor-link" href="#get:row1"
title="Permalink to mat3x2.get row1">#</a></h4>
<div class="doc">
<p>Returns row 1</p>
<pre class="source">
vec3 get row1() =&gt; 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/vec3.html">vec3</a> arg) <a class="anchor-link" href="#set:row1"
title="Permalink to mat3x2.set row1">#</a></h4>
<div class="doc">
<p>Sets row 1 to
<span class="param">arg</span></p>
<pre class="source">
set row1(vec3 arg) =&gt; setRow(1, 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/vec3.html">vec3</a> arg) <a class="anchor-link" href="#setRow"
title="Permalink to mat3x2.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, vec3 arg) {
assert(row &gt;= 0 &amp;&amp; row &lt; 2);
this[0][row] = arg[0];
this[1][row] = arg[1];
this[2][row] = arg[2];
}
</pre>
</div>
</div>
<div class="method"><h4 id="getRow">
<span class="show-code">Code</span>
<a href="../VectorMath/vec3.html">vec3</a> <strong>getRow</strong>(<a href="../dart_core/int.html">int</a> row) <a class="anchor-link" href="#getRow"
title="Permalink to mat3x2.getRow">#</a></h4>
<div class="doc">
<p>Gets the
<span class="param">row</span> of the matrix</p>
<pre class="source">
vec3 getRow(int row) {
assert(row &gt;= 0 &amp;&amp; row &lt; 2);
vec3 r = new vec3();
r[0] = this[0][row];
r[1] = this[1][row];
r[2] = this[2][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/vec2.html">vec2</a> arg) <a class="anchor-link" href="#setColumn"
title="Permalink to mat3x2.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, vec2 arg) {
assert(column &gt;= 0 &amp;&amp; column &lt; 3);
this[column] = arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="getColumn">
<span class="show-code">Code</span>
<a href="../VectorMath/vec2.html">vec2</a> <strong>getColumn</strong>(<a href="../dart_core/int.html">int</a> column) <a class="anchor-link" href="#getColumn"
title="Permalink to mat3x2.getColumn">#</a></h4>
<div class="doc">
<p>Gets the
<span class="param">column</span> of the matrix</p>
<pre class="source">
vec2 getColumn(int column) {
assert(column &gt;= 0 &amp;&amp; column &lt; 3);
return new vec2(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 mat3x2.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) {
mat3x2 r = new mat3x2();
r[0][0] = this[0][0] * arg;
r[0][1] = this[0][1] * arg;
r[1][0] = this[1][0] * arg;
r[1][1] = this[1][1] * arg;
r[2][0] = this[2][0] * arg;
r[2][1] = this[2][1] * arg;
return r;
}
if (arg is vec3) {
vec2 r = new vec2();
r[0] = dot(row0, arg);
r[1] = dot(row1, arg);
return r;
}
if (2 == arg.cols) {
Dynamic r = null;
if (arg.rows == 2) {
r = new mat3x2();
}
if (arg.rows == 3) {
r = new mat3x3();
}
if (arg.rows == 4) {
r = new mat3x4();
}
for (int j = 0; j &lt; arg.rows; j++) {
r[0][j] = dot(this.getRow(0), arg.getColumn(j));
}
for (int j = 0; j &lt; arg.rows; j++) {
r[1][j] = dot(this.getRow(1), arg.getColumn(j));
}
for (int j = 0; j &lt; arg.rows; j++) {
r[2][j] = dot(this.getRow(2), 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/mat3x2.html">mat3x2</a> <strong>operator +</strong>(<a href="../VectorMath/mat3x2.html">mat3x2</a> arg) <a class="anchor-link" href="#:add"
title="Permalink to mat3x2.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">
mat3x2 operator+(mat3x2 arg) {
mat3x2 r = new mat3x2();
r[0][0] = this[0][0] + arg[0][0];
r[0][1] = this[0][1] + arg[0][1];
r[1][0] = this[1][0] + arg[1][0];
r[1][1] = this[1][1] + arg[1][1];
r[2][0] = this[2][0] + arg[2][0];
r[2][1] = this[2][1] + arg[2][1];
return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id=":sub">
<span class="show-code">Code</span>
<a href="../VectorMath/mat3x2.html">mat3x2</a> <strong>operator -</strong>(<a href="../VectorMath/mat3x2.html">mat3x2</a> arg) <a class="anchor-link" href="#:sub"
title="Permalink to mat3x2.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">
mat3x2 operator-(mat3x2 arg) {
mat3x2 r = new mat3x2();
r[0][0] = this[0][0] - arg[0][0];
r[0][1] = this[0][1] - arg[0][1];
r[1][0] = this[1][0] - arg[1][0];
r[1][1] = this[1][1] - arg[1][1];
r[2][0] = this[2][0] - arg[2][0];
r[2][1] = this[2][1] - arg[2][1];
return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id=":negate">
<span class="show-code">Code</span>
<a href="../VectorMath/mat3x2.html">mat3x2</a> <strong>operator negate</strong>() <a class="anchor-link" href="#:negate"
title="Permalink to mat3x2.operator negate">#</a></h4>
<div class="doc">
<p>Returns new matrix -this</p>
<pre class="source">
mat3x2 operator negate() {
mat3x2 r = new mat3x2();
r[0] = -this[0];
r[1] = -this[1];
r[2] = -this[2];
return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transposed">
<span class="show-code">Code</span>
<a href="../VectorMath/mat2x3.html">mat2x3</a> <strong>transposed</strong>() <a class="anchor-link" href="#transposed"
title="Permalink to mat3x2.transposed">#</a></h4>
<div class="doc">
<p>Returns the tranpose of this.</p>
<pre class="source">
mat2x3 transposed() {
mat2x3 r = new mat2x3();
r[0][0] = this[0][0];
r[1][0] = this[0][1];
r[2][0] = this[0][2];
r[0][1] = this[1][0];
r[1][1] = this[1][1];
r[2][1] = this[1][2];
return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="absolute">
<span class="show-code">Code</span>
<a href="../VectorMath/mat3x2.html">mat3x2</a> <strong>absolute</strong>() <a class="anchor-link" href="#absolute"
title="Permalink to mat3x2.absolute">#</a></h4>
<div class="doc">
<p>Returns the component wise absolute value of this.</p>
<pre class="source">
mat3x2 absolute() {
mat3x2 r = new mat3x2();
r[0][0] = this[0][0].abs();
r[0][1] = this[0][1].abs();
r[1][0] = this[1][0].abs();
r[1][1] = this[1][1].abs();
r[2][0] = this[2][0].abs();
r[2][1] = this[2][1].abs();
return r;
}
</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 mat3x2.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();
norm = row_norm &gt; norm ? row_norm : norm;
}
{
num row_norm = 0.0;
row_norm += this[1][0].abs();
row_norm += this[1][1].abs();
norm = row_norm &gt; norm ? row_norm : norm;
}
{
num row_norm = 0.0;
row_norm += this[2][0].abs();
row_norm += this[2][1].abs();
norm = row_norm &gt; 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/mat3x2.html">mat3x2</a> correct) <a class="anchor-link" href="#relativeError"
title="Permalink to mat3x2.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(mat3x2 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/mat3x2.html">mat3x2</a> correct) <a class="anchor-link" href="#absoluteError"
title="Permalink to mat3x2.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(mat3x2 correct) {
num this_norm = infinityNorm();
num correct_norm = correct.infinityNorm();
num diff_norm = (this_norm - correct_norm).abs();
return diff_norm;
}
</pre>
</div>
</div>
<h3>Fields</h3>
<div class="field"><h4 id="col0">
<span class="show-code">Code</span>
<a href="../VectorMath/vec2.html">vec2</a> <strong>col0</strong> <a class="anchor-link"
href="#col0"
title="Permalink to mat3x2.col0">#</a>
</h4>
<div class="doc">
<pre class="source">
vec2 col0;
</pre>
</div>
</div>
<div class="field"><h4 id="col1">
<span class="show-code">Code</span>
<a href="../VectorMath/vec2.html">vec2</a> <strong>col1</strong> <a class="anchor-link"
href="#col1"
title="Permalink to mat3x2.col1">#</a>
</h4>
<div class="doc">
<pre class="source">
vec2 col1;
</pre>
</div>
</div>
<div class="field"><h4 id="col2">
<span class="show-code">Code</span>
<a href="../VectorMath/vec2.html">vec2</a> <strong>col2</strong> <a class="anchor-link"
href="#col2"
title="Permalink to mat3x2.col2">#</a>
</h4>
<div class="doc">
<pre class="source">
vec2 col2;
</pre>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<div class="footer"></div>
</body></html>