| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>VectorMath</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"> |
| <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></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><strong>VectorMath</strong></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><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>Library <strong>VectorMath</strong></h2> |
| <div class="doc"></div> |
| <h3>Functions</h3> |
| <div class="method"><h4 id="relativeError"> |
| <span class="show-code">Code</span> |
| <a href="dart_core/num.html">num</a> <strong>relativeError</strong>(calculated, correct) <a class="anchor-link" href="#relativeError" |
| title="Permalink to null.relativeError">#</a></h4> |
| <div class="doc"> |
| <p>Returns relative error between |
| <span class="param">calculated</span> and |
| <span class="param">correct</span>. The type of |
| <span class="param">calculated</span> and |
| <span class="param">correct</span> must match and can be any vector, matrix, or quaternion.</p> |
| <pre class="source"> |
| num relativeError(Dynamic calculated, Dynamic correct) { |
| if (calculated is num && correct is num) { |
| num diff = (calculated - correct).abs(); |
| return diff/correct; |
| } |
| return calculated.relativeError(correct); |
| } |
| </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>(calculated, correct) <a class="anchor-link" href="#absoluteError" |
| title="Permalink to null.absoluteError">#</a></h4> |
| <div class="doc"> |
| <p>Returns absolute error between |
| <span class="param">calculated</span> and |
| <span class="param">correct</span>. The type of |
| <span class="param">calculated</span> and |
| <span class="param">correct</span> must match and can be any vector, matrix, or quaternion.</p> |
| <pre class="source"> |
| num absoluteError(Dynamic calculated, Dynamic correct) { |
| if (calculated is num && correct is num) { |
| num diff = (calculated - correct).abs(); |
| return diff; |
| } |
| return calculated.absoluteError(correct); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="dot"> |
| <span class="show-code">Code</span> |
| <a href="dart_core/num.html">num</a> <strong>dot</strong>(x, y) <a class="anchor-link" href="#dot" |
| title="Permalink to null.dot">#</a></h4> |
| <div class="doc"> |
| <p>Returns the dot product between vectors |
| <span class="param">x</span> and |
| <span class="param">y</span>. The dimension of |
| <span class="param">x</span> and |
| <span class="param">y</span> must match.</p> |
| <pre class="source"> |
| num dot(Dynamic x, Dynamic y) { |
| return x.dot(y); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="length"> |
| <span class="show-code">Code</span> |
| <a href="dart_core/num.html">num</a> <strong>length</strong>(x) <a class="anchor-link" href="#length" |
| title="Permalink to null.length">#</a></h4> |
| <div class="doc"> |
| <p>Returns the length of vector |
| <span class="param">x</span></p> |
| <pre class="source"> |
| num length(Dynamic x) { |
| return x.length(); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="distance"> |
| <span class="show-code">Code</span> |
| <a href="dart_core/num.html">num</a> <strong>distance</strong>(x, y) <a class="anchor-link" href="#distance" |
| title="Permalink to null.distance">#</a></h4> |
| <div class="doc"> |
| <p>Returns the distance between vectors |
| <span class="param">x</span> and |
| <span class="param">y</span>. The dimension of |
| <span class="param">x</span> and |
| <span class="param">y</span> must match.</p> |
| <pre class="source"> |
| num distance(Dynamic x, Dynamic y) { |
| return length(x-y); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="cross"> |
| <span class="show-code">Code</span> |
| <a href="VectorMath/vec3.html">vec3</a> <strong>cross</strong>(<a href="VectorMath/vec3.html">vec3</a> x, <a href="VectorMath/vec3.html">vec3</a> y) <a class="anchor-link" href="#cross" |
| title="Permalink to null.cross">#</a></h4> |
| <div class="doc"> |
| <p>Returns the cross product between |
| <span class="param">x</span> and |
| <span class="param">y</span>. Both |
| <span class="param">x</span> and |
| <span class="param">y</span> must be 3D vectors (<a class="crossref" href="VectorMath/vec3.html">vec3</a>)</p> |
| <pre class="source"> |
| vec3 cross(vec3 x, vec3 y) { |
| return x.cross(y); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="normalize"> |
| <span class="show-code">Code</span> |
| <strong>normalize</strong>(x) <a class="anchor-link" href="#normalize" |
| title="Permalink to null.normalize">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">x</span> normalized. Supports <code>num</code>, <a class="crossref" href="VectorMath/vec2.html">vec2</a>, <a class="crossref" href="VectorMath/vec3.html">vec3</a>, and <a class="crossref" href="VectorMath/vec4.html">vec4</a> input types. The return type will match the type of |
| <span class="param">x</span></p> |
| <pre class="source"> |
| Dynamic normalize(Dynamic x) { |
| if (x is num) { |
| return 1.0 * sign(x); |
| } |
| Dynamic r; |
| if (x is vec2) { |
| r = new vec2(x); |
| r.normalize(); |
| } |
| if (x is vec3) { |
| r = new vec3(x); |
| r.normalize(); |
| } |
| if (x is vec4) { |
| r = new vec4(x); |
| r.normalize(); |
| } |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="sin"> |
| <span class="show-code">Code</span> |
| <strong>sin</strong>(arg) <a class="anchor-link" href="#sin" |
| title="Permalink to null.sin">#</a></h4> |
| <div class="doc"> |
| <p>Returns sine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic sin(Dynamic arg) { |
| if (arg is num) { |
| return Math.sin(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.sin(arg.x), Math.sin(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.sin(arg.x), Math.sin(arg.y), Math.sin(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.sin(arg.x), Math.sin(arg.y), Math.sin(arg.z), Math.sin(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="cos"> |
| <span class="show-code">Code</span> |
| <strong>cos</strong>(arg) <a class="anchor-link" href="#cos" |
| title="Permalink to null.cos">#</a></h4> |
| <div class="doc"> |
| <p>Returns cosine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic cos(Dynamic arg) { |
| if (arg is num) { |
| return Math.cos(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.cos(arg.x), Math.cos(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.cos(arg.x), Math.cos(arg.y), Math.cos(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.cos(arg.x), Math.cos(arg.y), Math.cos(arg.z), Math.cos(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="tan"> |
| <span class="show-code">Code</span> |
| <strong>tan</strong>(arg) <a class="anchor-link" href="#tan" |
| title="Permalink to null.tan">#</a></h4> |
| <div class="doc"> |
| <p>Returns tangent of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic tan(Dynamic arg) { |
| if (arg is num) { |
| return Math.tan(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.tan(arg.x), Math.tan(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.tan(arg.x), Math.tan(arg.y), Math.tan(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.tan(arg.x), Math.tan(arg.y), Math.tan(arg.z), Math.tan(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="asin"> |
| <span class="show-code">Code</span> |
| <strong>asin</strong>(arg) <a class="anchor-link" href="#asin" |
| title="Permalink to null.asin">#</a></h4> |
| <div class="doc"> |
| <p>Returns arc sine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic asin(Dynamic arg) { |
| if (arg is num) { |
| return Math.asin(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.asin(arg.x), Math.asin(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.asin(arg.x), Math.asin(arg.y), Math.asin(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.asin(arg.x), Math.asin(arg.y), Math.asin(arg.z), Math.asin(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="acos"> |
| <span class="show-code">Code</span> |
| <strong>acos</strong>(arg) <a class="anchor-link" href="#acos" |
| title="Permalink to null.acos">#</a></h4> |
| <div class="doc"> |
| <p>Returns arc cosine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic acos(Dynamic arg) { |
| if (arg is num) { |
| return Math.acos(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.acos(arg.x), Math.acos(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.acos(arg.x), Math.acos(arg.y), Math.acos(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.acos(arg.x), Math.acos(arg.y), Math.acos(arg.z), Math.acos(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="sinh"> |
| <span class="show-code">Code</span> |
| <strong>sinh</strong>(arg) <a class="anchor-link" href="#sinh" |
| title="Permalink to null.sinh">#</a></h4> |
| <div class="doc"> |
| <p>Returns hyperbolic sine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic sinh(Dynamic arg) { |
| if (arg is num) { |
| return Math.sinh(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.sinh(arg.x), Math.sinh(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.sinh(arg.x), Math.sinh(arg.y), Math.sinh(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.sinh(arg.x), Math.sinh(arg.y), Math.sinh(arg.z), Math.sinh(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="cosh"> |
| <span class="show-code">Code</span> |
| <strong>cosh</strong>(arg) <a class="anchor-link" href="#cosh" |
| title="Permalink to null.cosh">#</a></h4> |
| <div class="doc"> |
| <p>Returns hyperbolic cosine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic cosh(Dynamic arg) { |
| if (arg is num) { |
| return Math.cosh(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.cosh(arg.x), Math.cosh(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.cosh(arg.x), Math.cosh(arg.y), Math.cosh(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.cosh(arg.x), Math.cosh(arg.y), Math.cosh(arg.z), Math.cosh(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="tanh"> |
| <span class="show-code">Code</span> |
| <strong>tanh</strong>(arg) <a class="anchor-link" href="#tanh" |
| title="Permalink to null.tanh">#</a></h4> |
| <div class="doc"> |
| <p>Returns hyperbolic tangent of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic tanh(Dynamic arg) { |
| if (arg is num) { |
| return Math.tanh(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.tanh(arg.x), Math.tanh(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.tanh(arg.x), Math.tanh(arg.y), Math.tanh(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.tanh(arg.x), Math.tanh(arg.y), Math.tanh(arg.z), Math.tanh(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="asinh"> |
| <span class="show-code">Code</span> |
| <strong>asinh</strong>(arg) <a class="anchor-link" href="#asinh" |
| title="Permalink to null.asinh">#</a></h4> |
| <div class="doc"> |
| <p>Returns arc hyperbolic sine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic asinh(Dynamic arg) { |
| if (arg is num) { |
| return Math.asinh(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.asinh(arg.x), Math.asinh(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.asinh(arg.x), Math.asinh(arg.y), Math.asinh(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.asinh(arg.x), Math.asinh(arg.y), Math.asinh(arg.z), Math.asinh(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="acosh"> |
| <span class="show-code">Code</span> |
| <strong>acosh</strong>(arg) <a class="anchor-link" href="#acosh" |
| title="Permalink to null.acosh">#</a></h4> |
| <div class="doc"> |
| <p>Returns arc hyperbolic cosine of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic acosh(Dynamic arg) { |
| if (arg is num) { |
| return Math.acosh(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.acosh(arg.x), Math.acosh(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.acosh(arg.x), Math.acosh(arg.y), Math.acosh(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.acosh(arg.x), Math.acosh(arg.y), Math.acosh(arg.z), Math.acosh(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="atanh"> |
| <span class="show-code">Code</span> |
| <strong>atanh</strong>(arg) <a class="anchor-link" href="#atanh" |
| title="Permalink to null.atanh">#</a></h4> |
| <div class="doc"> |
| <p>Returns arc hyperbolic tangent of |
| <span class="param">arg</span>. Return type matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic atanh(Dynamic arg) { |
| if (arg is num) { |
| return Math.atanh(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.atanh(arg.x), Math.atanh(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.atanh(arg.x), Math.atanh(arg.y), Math.atanh(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.atanh(arg.x), Math.atanh(arg.y), Math.atanh(arg.z), Math.atanh(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="radians"> |
| <span class="show-code">Code</span> |
| <strong>radians</strong>(arg) <a class="anchor-link" href="#radians" |
| title="Permalink to null.radians">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">arg</span> converted from degrees to radians. Return types matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic radians(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.radians(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.radians(arg.x), _ScalerHelpers.radians(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.radians(arg.x), _ScalerHelpers.radians(arg.y), _ScalerHelpers.radians(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.radians(arg.x), _ScalerHelpers.radians(arg.y), _ScalerHelpers.radians(arg.z), _ScalerHelpers.radians(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="degrees"> |
| <span class="show-code">Code</span> |
| <strong>degrees</strong>(arg) <a class="anchor-link" href="#degrees" |
| title="Permalink to null.degrees">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">arg</span> converted from radians to degrees. Return types matches the type of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic degrees(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.degrees(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.degrees(arg.x), _ScalerHelpers.degrees(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.degrees(arg.x), _ScalerHelpers.degrees(arg.y), _ScalerHelpers.degrees(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.degrees(arg.x), _ScalerHelpers.degrees(arg.y), _ScalerHelpers.degrees(arg.z), _ScalerHelpers.degrees(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="pow"> |
| <span class="show-code">Code</span> |
| <strong>pow</strong>(x, y) <a class="anchor-link" href="#pow" |
| title="Permalink to null.pow">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">x</span> raised to the exponent |
| <span class="param">y</span>. Supports vectors and numbers.</p> |
| <pre class="source"> |
| Dynamic pow(Dynamic x, Dynamic y) { |
| if (x is num) { |
| return Math.pow(x, y); |
| } |
| if (x is vec2) { |
| return new vec2(Math.pow(x.x, y.x), Math.pow(x.y, y.y)); |
| } |
| if (x is vec3) { |
| return new vec3(Math.pow(x.x, y.x), Math.pow(x.y, y.y), Math.pow(x.z, y.z)); |
| } |
| if (x is vec4) { |
| return new vec4(Math.pow(x.x, y.x), Math.pow(x.y, y.y), Math.pow(x.z, y.z), Math.pow(x.w, y.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="exp"> |
| <span class="show-code">Code</span> |
| <strong>exp</strong>(arg) <a class="anchor-link" href="#exp" |
| title="Permalink to null.exp">#</a></h4> |
| <div class="doc"> |
| <p>Returns <em>e</em> raised to the exponent |
| <span class="param">arg</span>. Supports vectors and numbers.</p> |
| <pre class="source"> |
| Dynamic exp(Dynamic arg) { |
| if (arg is num) { |
| return Math.exp(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.exp(arg.x), Math.exp(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.exp(arg.x), Math.exp(arg.y), Math.exp(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.exp(arg.x), Math.exp(arg.y), Math.exp(arg.z), Math.exp(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="log"> |
| <span class="show-code">Code</span> |
| <strong>log</strong>(arg) <a class="anchor-link" href="#log" |
| title="Permalink to null.log">#</a></h4> |
| <div class="doc"> |
| <p>Returns the logarithm of |
| <span class="param">arg</span> base <em>e</em>. Supports vectors and numbers.</p> |
| <pre class="source"> |
| Dynamic log(Dynamic arg) { |
| if (arg is num) { |
| return Math.log(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.log(arg.x), Math.log(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.log(arg.x), Math.log(arg.y), Math.log(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.log(arg.x), Math.log(arg.y), Math.log(arg.z), Math.log(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="exp2"> |
| <span class="show-code">Code</span> |
| <strong>exp2</strong>(arg) <a class="anchor-link" href="#exp2" |
| title="Permalink to null.exp2">#</a></h4> |
| <div class="doc"> |
| <p>Returns <em>2</em> raised to the exponent |
| <span class="param">arg</span>. Supports vectors and numbers.</p> |
| <pre class="source"> |
| Dynamic exp2(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.exp2(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.exp2(arg.x), _ScalerHelpers.exp2(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.exp2(arg.x), _ScalerHelpers.exp2(arg.y), _ScalerHelpers.exp2(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.exp2(arg.x), _ScalerHelpers.exp2(arg.y), _ScalerHelpers.exp2(arg.z), _ScalerHelpers.exp2(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="log2"> |
| <span class="show-code">Code</span> |
| <strong>log2</strong>(arg) <a class="anchor-link" href="#log2" |
| title="Permalink to null.log2">#</a></h4> |
| <div class="doc"> |
| <p>Returns the logarithm of |
| <span class="param">arg</span> base <em>2</em>. Supports vectors and numbers.</p> |
| <pre class="source"> |
| Dynamic log2(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.log2(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.log2(arg.x), _ScalerHelpers.log2(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.log2(arg.x), _ScalerHelpers.log2(arg.y), _ScalerHelpers.log2(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.log2(arg.x), _ScalerHelpers.log2(arg.y), _ScalerHelpers.log2(arg.z), _ScalerHelpers.log2(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="sqrt"> |
| <span class="show-code">Code</span> |
| <strong>sqrt</strong>(arg) <a class="anchor-link" href="#sqrt" |
| title="Permalink to null.sqrt">#</a></h4> |
| <div class="doc"> |
| <p>Returns the square root of |
| <span class="param">arg</span>.</p> |
| <pre class="source"> |
| Dynamic sqrt(Dynamic arg) { |
| if (arg is num) { |
| return Math.sqrt(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.sqrt(arg.x), Math.sqrt(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.sqrt(arg.x), Math.sqrt(arg.y), Math.sqrt(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.sqrt(arg.x), Math.sqrt(arg.y), Math.sqrt(arg.z), Math.sqrt(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="inversesqrt"> |
| <span class="show-code">Code</span> |
| <strong>inversesqrt</strong>(arg) <a class="anchor-link" href="#inversesqrt" |
| title="Permalink to null.inversesqrt">#</a></h4> |
| <div class="doc"> |
| <p>Returns the inverse square root of |
| <span class="param">arg</span>. Supports vectors and numbers.</p> |
| <pre class="source"> |
| Dynamic inversesqrt(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.inversesqrt(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.inversesqrt(arg.x), _ScalerHelpers.inversesqrt(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.inversesqrt(arg.x), _ScalerHelpers.inversesqrt(arg.y), _ScalerHelpers.inversesqrt(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.inversesqrt(arg.x), _ScalerHelpers.inversesqrt(arg.y), _ScalerHelpers.inversesqrt(arg.z), _ScalerHelpers.inversesqrt(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="abs"> |
| <span class="show-code">Code</span> |
| <strong>abs</strong>(arg) <a class="anchor-link" href="#abs" |
| title="Permalink to null.abs">#</a></h4> |
| <div class="doc"> |
| <p>Returns absolute value of |
| <span class="param">arg</span>.</p> |
| <pre class="source"> |
| Dynamic abs(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.abs(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.abs(arg.x), _ScalerHelpers.abs(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.abs(arg.x), _ScalerHelpers.abs(arg.y), _ScalerHelpers.abs(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.abs(arg.x), _ScalerHelpers.abs(arg.y), _ScalerHelpers.abs(arg.z), _ScalerHelpers.abs(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="sign"> |
| <span class="show-code">Code</span> |
| <strong>sign</strong>(arg) <a class="anchor-link" href="#sign" |
| title="Permalink to null.sign">#</a></h4> |
| <div class="doc"> |
| <p>Returns 1.0 or 0.0 or -1.0 depending on sign of |
| <span class="param">arg</span>.</p> |
| <pre class="source"> |
| Dynamic sign(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.sign(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.sign(arg.x), _ScalerHelpers.sign(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.sign(arg.x), _ScalerHelpers.sign(arg.y), _ScalerHelpers.sign(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.sign(arg.x), _ScalerHelpers.sign(arg.y), _ScalerHelpers.sign(arg.z), _ScalerHelpers.sign(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="floor"> |
| <span class="show-code">Code</span> |
| <strong>floor</strong>(arg) <a class="anchor-link" href="#floor" |
| title="Permalink to null.floor">#</a></h4> |
| <div class="doc"> |
| <p>Returns floor value of |
| <span class="param">arg</span>.</p> |
| <pre class="source"> |
| Dynamic floor(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.floor(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.floor(arg.x), _ScalerHelpers.floor(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.floor(arg.x), _ScalerHelpers.floor(arg.y), _ScalerHelpers.floor(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.floor(arg.x), _ScalerHelpers.floor(arg.y), _ScalerHelpers.floor(arg.z), _ScalerHelpers.floor(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="trunc"> |
| <span class="show-code">Code</span> |
| <strong>trunc</strong>(arg) <a class="anchor-link" href="#trunc" |
| title="Permalink to null.trunc">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">arg</span> truncated.</p> |
| <pre class="source"> |
| Dynamic trunc(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.truncate(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.truncate(arg.x), _ScalerHelpers.truncate(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.truncate(arg.x), _ScalerHelpers.truncate(arg.y), _ScalerHelpers.truncate(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.truncate(arg.x), _ScalerHelpers.truncate(arg.y), _ScalerHelpers.truncate(arg.z), _ScalerHelpers.truncate(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="round"> |
| <span class="show-code">Code</span> |
| <strong>round</strong>(arg) <a class="anchor-link" href="#round" |
| title="Permalink to null.round">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">arg</span> rounded to nearest integer.</p> |
| <pre class="source"> |
| Dynamic round(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.round(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.round(arg.x), _ScalerHelpers.round(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.round(arg.x), _ScalerHelpers.round(arg.y), _ScalerHelpers.round(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.round(arg.x), _ScalerHelpers.round(arg.y), _ScalerHelpers.round(arg.z), _ScalerHelpers.round(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="roundEven"> |
| <span class="show-code">Code</span> |
| <strong>roundEven</strong>(arg) <a class="anchor-link" href="#roundEven" |
| title="Permalink to null.roundEven">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">arg</span> rounded to nearest even integer.</p> |
| <pre class="source"> |
| Dynamic roundEven(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.roundEven(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.roundEven(arg.x), _ScalerHelpers.roundEven(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.roundEven(arg.x), _ScalerHelpers.roundEven(arg.y), _ScalerHelpers.roundEven(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.roundEven(arg.x), _ScalerHelpers.roundEven(arg.y), _ScalerHelpers.roundEven(arg.z), _ScalerHelpers.roundEven(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="ceil"> |
| <span class="show-code">Code</span> |
| <strong>ceil</strong>(arg) <a class="anchor-link" href="#ceil" |
| title="Permalink to null.ceil">#</a></h4> |
| <div class="doc"> |
| <p>Returns ceiling of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic ceil(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.ceil(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.ceil(arg.x), _ScalerHelpers.ceil(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.ceil(arg.x), _ScalerHelpers.ceil(arg.y), _ScalerHelpers.ceil(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.ceil(arg.x), _ScalerHelpers.ceil(arg.y), _ScalerHelpers.ceil(arg.z), _ScalerHelpers.ceil(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="fract"> |
| <span class="show-code">Code</span> |
| <strong>fract</strong>(arg) <a class="anchor-link" href="#fract" |
| title="Permalink to null.fract">#</a></h4> |
| <div class="doc"> |
| <p>Returns fraction of |
| <span class="param">arg</span></p> |
| <pre class="source"> |
| Dynamic fract(Dynamic arg) { |
| if (arg is num) { |
| return _ScalerHelpers.fract(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(_ScalerHelpers.fract(arg.x), _ScalerHelpers.fract(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(_ScalerHelpers.fract(arg.x), _ScalerHelpers.fract(arg.y), _ScalerHelpers.fract(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(_ScalerHelpers.fract(arg.x), _ScalerHelpers.fract(arg.y), _ScalerHelpers.fract(arg.z), _ScalerHelpers.fract(arg.w)); |
| } |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="mod"> |
| <span class="show-code">Code</span> |
| <strong>mod</strong>(x, y) <a class="anchor-link" href="#mod" |
| title="Permalink to null.mod">#</a></h4> |
| <div class="doc"> |
| <p>Returns |
| <span class="param">x</span> mod |
| <span class="param">y</span></p> |
| <pre class="source"> |
| Dynamic mod(Dynamic x, Dynamic y) { |
| if (x is num) { |
| return _ScalerHelpers.mod(x, y); |
| } |
| if (x is vec2) { |
| return new vec2(_ScalerHelpers.mod(x.x, y.x), _ScalerHelpers.mod(x.y, y.y)); |
| } |
| if (x is vec3) { |
| return new vec3(_ScalerHelpers.mod(x.x, y.x), _ScalerHelpers.mod(x.y, y.y), _ScalerHelpers.mod(x.z, y.z)); |
| } |
| if (x is vec4) { |
| return new vec4(_ScalerHelpers.mod(x.x, y.x), _ScalerHelpers.mod(x.y, y.y), _ScalerHelpers.mod(x.z, y.z), _ScalerHelpers.mod(x.w, y.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="min"> |
| <span class="show-code">Code</span> |
| <strong>min</strong>(x, y) <a class="anchor-link" href="#min" |
| title="Permalink to null.min">#</a></h4> |
| <div class="doc"> |
| <p>Returns component wise minimum of |
| <span class="param">x</span> and |
| <span class="param">y</span></p> |
| <pre class="source"> |
| Dynamic min(Dynamic x, Dynamic y) { |
| if (x is num) { |
| return Math.min(x, y); |
| } |
| if (x is vec2) { |
| return new vec2(Math.min(x.x, y.x), Math.min(x.y, y.y)); |
| } |
| if (x is vec3) { |
| return new vec3(Math.min(x.x, y.x), Math.min(x.y, y.y), Math.min(x.z, y.z)); |
| } |
| if (x is vec4) { |
| return new vec4(Math.min(x.x, y.x), Math.min(x.y, y.y), Math.min(x.z, y.z), Math.min(x.w, y.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="max"> |
| <span class="show-code">Code</span> |
| <strong>max</strong>(x, y) <a class="anchor-link" href="#max" |
| title="Permalink to null.max">#</a></h4> |
| <div class="doc"> |
| <p>Returns component wise maximum of |
| <span class="param">x</span> and |
| <span class="param">y</span></p> |
| <pre class="source"> |
| Dynamic max(Dynamic x, Dynamic y) { |
| if (x is num) { |
| return Math.max(x, y); |
| } |
| if (x is vec2) { |
| return new vec2(Math.max(x.x, y.x), Math.max(x.y, y.y)); |
| } |
| if (x is vec3) { |
| return new vec3(Math.max(x.x, y.x), Math.max(x.y, y.y), Math.max(x.z, y.z)); |
| } |
| if (x is vec4) { |
| return new vec4(Math.max(x.x, y.x), Math.max(x.y, y.y), Math.max(x.z, y.z), Math.max(x.w, y.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="clamp"> |
| <span class="show-code">Code</span> |
| <strong>clamp</strong>(x, min_, max_) <a class="anchor-link" href="#clamp" |
| title="Permalink to null.clamp">#</a></h4> |
| <div class="doc"> |
| <p>Component wise clamp of |
| <span class="param">x</span> between |
| <span class="param">min_</span> and |
| <span class="param">max_</span></p> |
| <pre class="source"> |
| Dynamic clamp(Dynamic x, Dynamic min_, Dynamic max_) { |
| if (x is num) { |
| return _ScalerHelpers.clamp(x, min_, max_); |
| } |
| if (x is vec2) { |
| return new vec2(_ScalerHelpers.clamp(x.x, min_.x, max_.x), _ScalerHelpers.clamp(x.y, min_.y, max_.y)); |
| } |
| if (x is vec3) { |
| return new vec3(_ScalerHelpers.clamp(x.x, min_.x, max_.x), _ScalerHelpers.clamp(x.y, min_.y, max_.y), _ScalerHelpers.clamp(x.z, min_.z, max_.z)); |
| } |
| if (x is vec4) { |
| return new vec4(_ScalerHelpers.clamp(x.x, min_.x, max_.x), _ScalerHelpers.clamp(x.y, min_.y, max_.y), _ScalerHelpers.clamp(x.z, min_.z, max_.z), _ScalerHelpers.clamp(x.w, min_.w, max_.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="mix"> |
| <span class="show-code">Code</span> |
| <strong>mix</strong>(x, y, t) <a class="anchor-link" href="#mix" |
| title="Permalink to null.mix">#</a></h4> |
| <div class="doc"> |
| <p>Linear interpolation between |
| <span class="param">x</span> and |
| <span class="param">y</span> with |
| <span class="param">t</span>. |
| <span class="param">t</span> must be between 0.0 and 1.0.</p> |
| <pre class="source"> |
| Dynamic mix(Dynamic x, Dynamic y, Dynamic t) { |
| if (x is num) { |
| return _ScalerHelpers.mix(x, y, t); |
| } |
| if (x is vec2) { |
| return new vec2(_ScalerHelpers.mix(x.x, y.x, t.x), _ScalerHelpers.mix(x.y, y.y, t.y)); |
| } |
| if (x is vec3) { |
| return new vec3(_ScalerHelpers.mix(x.x, y.x, t.x), _ScalerHelpers.mix(x.y, y.y, t.y), _ScalerHelpers.mix(x.z, y.z, t.z)); |
| } |
| if (x is vec4) { |
| return new vec4(_ScalerHelpers.mix(x.x, y.x, t.x), _ScalerHelpers.mix(x.y, y.y, t.y), _ScalerHelpers.mix(x.z, y.z, t.z), _ScalerHelpers.mix(x.w, y.w, t.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="step"> |
| <span class="show-code">Code</span> |
| <strong>step</strong>(x, y) <a class="anchor-link" href="#step" |
| title="Permalink to null.step">#</a></h4> |
| <div class="doc"> |
| <p>Returns 0.0 if x < |
| <span class="param">y</span> and 1.0 otherwise.</p> |
| <pre class="source"> |
| Dynamic step(Dynamic x, Dynamic y) { |
| if (x is num) { |
| return _ScalerHelpers.step(x, y); |
| } |
| if (x is vec2) { |
| return new vec2(_ScalerHelpers.step(x.x, y.x), _ScalerHelpers.step(x.y, y.y)); |
| } |
| if (x is vec3) { |
| return new vec3(_ScalerHelpers.step(x.x, y.x), _ScalerHelpers.step(x.y, y.y), _ScalerHelpers.step(x.z, y.z)); |
| } |
| if (x is vec4) { |
| return new vec4(_ScalerHelpers.step(x.x, y.x), _ScalerHelpers.step(x.y, y.y), _ScalerHelpers.step(x.z, y.z), _ScalerHelpers.step(x.w, y.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="smoothstep"> |
| <span class="show-code">Code</span> |
| <strong>smoothstep</strong>(edge0, edge1, x) <a class="anchor-link" href="#smoothstep" |
| title="Permalink to null.smoothstep">#</a></h4> |
| <div class="doc"> |
| <p>Hermite intpolation between |
| <span class="param">edge0</span> and |
| <span class="param">edge1</span>. |
| <span class="param">edge0</span> < |
| <span class="param">x</span> < |
| <span class="param">edge1</span>.</p> |
| <pre class="source"> |
| Dynamic smoothstep(Dynamic edge0, Dynamic edge1, Dynamic x) { |
| if (x is num) { |
| return _ScalerHelpers.smoothstep(edge0, edge1, x); |
| } |
| if (x is vec2) { |
| return new vec2(_ScalerHelpers.smoothstep(edge0.x, edge1.x, x.x), _ScalerHelpers.smoothstep(edge0.y, edge1.y, x.y)); |
| } |
| if (x is vec3) { |
| return new vec3(_ScalerHelpers.smoothstep(edge0.x, edge1.x, x.x), _ScalerHelpers.smoothstep(edge0.y, edge1.y, x.y), _ScalerHelpers.smoothstep(edge0.z, edge1.z, x.z)); |
| } |
| if (x is vec4) { |
| return new vec4(_ScalerHelpers.smoothstep(edge0.x, edge1.x, x.x), _ScalerHelpers.smoothstep(edge0.y, edge1.y, x.y), _ScalerHelpers.smoothstep(edge0.z, edge1.z, x.z), _ScalerHelpers.smoothstep(edge0.w, edge1.w, x.w)); |
| } |
| throw new IllegalArgumentException(x); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="atan"> |
| <span class="show-code">Code</span> |
| <strong>atan</strong>(arg, [arg2]) <a class="anchor-link" href="#atan" |
| title="Permalink to null.atan">#</a></h4> |
| <div class="doc"> |
| <p>Returns atan( |
| <span class="param">arg</span>) or atan( |
| <span class="param">arg</span>/ |
| <span class="param">arg2</span>)</p> |
| <p>Arguments can be of type <code>num</code>, <a class="crossref" href="VectorMath/vec2.html">vec2</a>, <a class="crossref" href="VectorMath/vec3.html">vec3</a> or <a class="crossref" href="VectorMath/vec4.html">vec4</a> |
| Return type matches input argument type</p> |
| <pre class="source"> |
| Dynamic atan(Dynamic arg, [Dynamic arg2]) { |
| if (arg2 == null) { |
| if (arg is num) { |
| return Math.atan(arg); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.atan(arg.x), Math.atan(arg.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.atan(arg.x), Math.atan(arg.y), Math.atan(arg.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.atan(arg.x), Math.atan(arg.y), Math.atan(arg.z), Math.atan(arg.w)); |
| } |
| } else { |
| if (arg is num) { |
| return Math.atan2(arg, arg2); |
| } |
| if (arg is vec2) { |
| return new vec2(Math.atan2(arg.x, arg2.x), Math.atan2(arg.y, arg2.y)); |
| } |
| if (arg is vec3) { |
| return new vec3(Math.atan2(arg.x, arg2.x), Math.atan2(arg.y, arg2.y), Math.atan2(arg.z, arg2.z)); |
| } |
| if (arg is vec4) { |
| return new vec4(Math.atan2(arg.x, arg2.x), Math.atan2(arg.y, arg2.y), Math.atan2(arg.z, arg2.z), Math.atan2(arg.w, arg2.w)); |
| } |
| } |
| |
| throw new IllegalArgumentException(arg); |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="makeLookAt"> |
| <span class="show-code">Code</span> |
| <a href="VectorMath/mat4x4.html">mat4x4</a> <strong>makeLookAt</strong>(<a href="VectorMath/vec3.html">vec3</a> eyePosition, <a href="VectorMath/vec3.html">vec3</a> lookAtPosition, <a href="VectorMath/vec3.html">vec3</a> upDirection) <a class="anchor-link" href="#makeLookAt" |
| title="Permalink to null.makeLookAt">#</a></h4> |
| <div class="doc"> |
| <p>Returns an OpenGL LookAt matrix</p> |
| <pre class="source"> |
| mat4x4 makeLookAt(vec3 eyePosition, vec3 lookAtPosition, vec3 upDirection) { |
| vec3 z = lookAtPosition - eyePosition; |
| z.normalize(); |
| vec3 x = upDirection.cross(z); |
| x.normalize(); |
| vec3 y = z.cross(x); |
| y.normalize(); |
| mat4x4 r = new mat4x4(); |
| r[0].xyz = x; |
| r[1].xyz = y; |
| r[2].xyz = z; |
| r[3].w = 1.0; |
| vec3 rotatedEye = r * eyePosition; |
| r[3].xyz = rotatedEye; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="makePerspective"> |
| <span class="show-code">Code</span> |
| <a href="VectorMath/mat4x4.html">mat4x4</a> <strong>makePerspective</strong>(<a href="dart_core/num.html">num</a> fov_y_radians, <a href="dart_core/num.html">num</a> aspect_ratio, <a href="dart_core/num.html">num</a> znear, <a href="dart_core/num.html">num</a> zfar) <a class="anchor-link" href="#makePerspective" |
| title="Permalink to null.makePerspective">#</a></h4> |
| <div class="doc"> |
| <p>Returns an OpenGL perspective camera projection matrix</p> |
| <pre class="source"> |
| mat4x4 makePerspective(num fov_y_radians, num aspect_ratio, num znear, num zfar) { |
| num tan_fov = tan(fov_y_radians * 0.5); |
| num height = 1.0/tan_fov; |
| num width = height / aspect_ratio; |
| num zf_sub_zn = zfar - znear; |
| |
| mat4x4 r = new mat4x4(); |
| r[0].x = width; |
| r[1].y = height; |
| r[2].z = zfar/zf_sub_zn; |
| r[3].z = 1.0; |
| r[3].w = 0.0; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="makeOrthographic"> |
| <span class="show-code">Code</span> |
| <a href="VectorMath/mat4x4.html">mat4x4</a> <strong>makeOrthographic</strong>(<a href="dart_core/num.html">num</a> left, <a href="dart_core/num.html">num</a> right, <a href="dart_core/num.html">num</a> bottom, <a href="dart_core/num.html">num</a> top, <a href="dart_core/num.html">num</a> znear, <a href="dart_core/num.html">num</a> zfar) <a class="anchor-link" href="#makeOrthographic" |
| title="Permalink to null.makeOrthographic">#</a></h4> |
| <div class="doc"> |
| <p>Returns an OpenGL orthographic camera projection matrix</p> |
| <pre class="source"> |
| mat4x4 makeOrthographic(num left, num right, num bottom, num top, num znear, num zfar) { |
| num rml = right - left; |
| num rpl = right + left; |
| num tmb = top - bottom; |
| num tpb = top + bottom; |
| num fmn = zfar - znear; |
| num fpn = zfar + znear; |
| |
| mat4x4 r = new mat4x4(); |
| r[0].x = 2.0/rml; |
| r[1].y = 2.0/tmb; |
| r[2].z = 2.0/fmn; |
| r[3].x = rpl/rml; |
| r[3].y = tpb/tmb; |
| r[3].z = fpn/fmn; |
| r[3].w = 1.0; |
| |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="makePlaneProjection"> |
| <span class="show-code">Code</span> |
| <a href="VectorMath/mat4x4.html">mat4x4</a> <strong>makePlaneProjection</strong>(<a href="VectorMath/vec3.html">vec3</a> planeNormal, <a href="VectorMath/vec3.html">vec3</a> planePoint) <a class="anchor-link" href="#makePlaneProjection" |
| title="Permalink to null.makePlaneProjection">#</a></h4> |
| <div class="doc"> |
| <p>Returns a transformation matrix that transforms points onto the plane specified with |
| <span class="param">planeNormal</span> and |
| <span class="param">planePoint</span></p> |
| <pre class="source"> |
| mat4x4 makePlaneProjection(vec3 planeNormal, vec3 planePoint) { |
| vec4 v = new vec4(planeNormal, 0.0); |
| mat4x4 outer = new mat4x4.outer(v, v); |
| mat4x4 r = new mat4x4(); |
| r = r - outer; |
| vec3 scaledNormal = (planeNormal * dot(planePoint, planeNormal)); |
| vec4 T = new vec4(scaledNormal, 1.0); |
| r.col3 = T; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <div class="method"><h4 id="makePlaneReflection"> |
| <span class="show-code">Code</span> |
| <a href="VectorMath/mat4x4.html">mat4x4</a> <strong>makePlaneReflection</strong>(<a href="VectorMath/vec3.html">vec3</a> planeNormal, <a href="VectorMath/vec3.html">vec3</a> planePoint) <a class="anchor-link" href="#makePlaneReflection" |
| title="Permalink to null.makePlaneReflection">#</a></h4> |
| <div class="doc"> |
| <p>Returns a transformation matrix that transforms points by reflecting them in the plane specified with |
| <span class="param">planeNormal</span> and |
| <span class="param">planePoint</span></p> |
| <pre class="source"> |
| mat4x4 makePlaneReflection(vec3 planeNormal, vec3 planePoint) { |
| vec4 v = new vec4(planeNormal, 0.0); |
| mat4x4 outer = new mat4x4.outer(v,v); |
| outer = outer * 2.0; |
| mat4x4 r = new mat4x4(); |
| r = r - outer; |
| vec3 scaledNormal = (planeNormal * 2.0 * dot(planePoint, planeNormal)); |
| vec4 T = new vec4(scaledNormal, 1.0); |
| r.col3 = T; |
| return r; |
| } |
| </pre> |
| </div> |
| </div> |
| <h3>Classes</h3> |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/vec2.html"><strong>vec2</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/vec3.html"><strong>vec3</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/vec4.html"><strong>vec4</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat2x2.html"><strong>mat2x2</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat2x3.html"><strong>mat2x3</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat2x4.html"><strong>mat2x4</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat3x2.html"><strong>mat3x2</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat3x3.html"><strong>mat3x3</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat3x4.html"><strong>mat3x4</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat4x2.html"><strong>mat4x2</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat4x3.html"><strong>mat4x3</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/mat4x4.html"><strong>mat4x4</strong></a> |
| </h4> |
| </div> |
| |
| <div class="type"> |
| <h4> |
| <a href="VectorMath/quat.html"><strong>quat</strong></a> |
| </h4> |
| </div> |
| |
| </div> |
| <div class="clear"></div> |
| </div> |
| <div class="footer"></div> |
| </body></html> |
| |