212 lines
9.8 KiB
HTML
212 lines
9.8 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||
|
<meta name="generator" content="Doxygen 1.8.18"/>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
<title>AngelScript: math functions</title>
|
||
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="jquery.js"></script>
|
||
|
<script type="text/javascript" src="dynsections.js"></script>
|
||
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="resize.js"></script>
|
||
|
<script type="text/javascript" src="navtreedata.js"></script>
|
||
|
<script type="text/javascript" src="navtree.js"></script>
|
||
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
||
|
<script type="text/javascript" src="search/search.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
$(document).ready(function() { init_search(); });
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||
|
<div id="titlearea">
|
||
|
<table cellspacing="0" cellpadding="0">
|
||
|
<tbody>
|
||
|
<tr style="height: 56px;">
|
||
|
<td id="projectlogo"><img alt="Logo" src="aslogo_small.png"/></td>
|
||
|
<td id="projectalign" style="padding-left: 0.5em;">
|
||
|
<div id="projectname">AngelScript
|
||
|
</div>
|
||
|
</td>
|
||
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
||
|
<span class="left">
|
||
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
alt=""/>
|
||
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
||
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
||
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
||
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
||
|
</span><span class="right">
|
||
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
||
|
</span>
|
||
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<!-- end header part -->
|
||
|
<!-- Generated by Doxygen 1.8.18 -->
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
</div><!-- top -->
|
||
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||
|
<div id="nav-tree">
|
||
|
<div id="nav-tree-contents">
|
||
|
<div id="nav-sync" class="sync"></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="splitbar" style="-moz-user-select:none;"
|
||
|
class="ui-resizable-handle">
|
||
|
</div>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||
|
$(document).ready(function(){initNavTree('doc_addon_math.html',''); initResizable(); });
|
||
|
/* @license-end */
|
||
|
</script>
|
||
|
<div id="doc-content">
|
||
|
<!-- window showing the filter options -->
|
||
|
<div id="MSearchSelectWindow"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||
|
</div>
|
||
|
|
||
|
<!-- iframe showing the search results (closed by default) -->
|
||
|
<div id="MSearchResultsWindow">
|
||
|
<iframe src="javascript:void(0)" frameborder="0"
|
||
|
name="MSearchResults" id="MSearchResults">
|
||
|
</iframe>
|
||
|
</div>
|
||
|
|
||
|
<div class="PageDoc"><div class="header">
|
||
|
<div class="headertitle">
|
||
|
<div class="title">math functions </div> </div>
|
||
|
</div><!--header-->
|
||
|
<div class="contents">
|
||
|
<div class="textblock"><p><b>Path:</b> /sdk/add_on/scriptmath/</p>
|
||
|
<p>This add-on registers the math functions from the standard C runtime library with the script engine. Use <code>RegisterScriptMath(asIScriptEngine*)</code> to perform the registration.</p>
|
||
|
<p>By defining the preprocessor word AS_USE_FLOAT=0, the functions will be registered to take and return doubles instead of floats.</p>
|
||
|
<p>The function <code>RegisterScriptMathComplex(asIScriptEngine*)</code> registers a type that represents a complex number, i.e. a number with real and imaginary parts.</p>
|
||
|
<h1><a class="anchor" id="doc_addon_math_1"></a>
|
||
|
Public script interface</h1>
|
||
|
<pre>
|
||
|
// Trigonometric functions
|
||
|
float cos(float rad);
|
||
|
float sin(float rad);
|
||
|
float tan(float rad);</pre><pre> // Inverse trigonometric functions
|
||
|
float acos(float val);
|
||
|
float asin(float val);
|
||
|
float atan(float val);
|
||
|
float atan2(float y, float x);</pre><pre> // Hyperbolic functions
|
||
|
float cosh(float rad);
|
||
|
float sinh(float rad);
|
||
|
float tanh(float rad);</pre><pre> // Logarithmic functions
|
||
|
float log(float val);
|
||
|
float log10(float val);</pre><pre> // Power to
|
||
|
float pow(float val, float exp);</pre><pre> // Square root
|
||
|
float sqrt(float val);</pre><pre> // Absolute value
|
||
|
float abs(float val);</pre><pre> // Ceil and floor functions
|
||
|
float ceil(float val);
|
||
|
float floor(float val);</pre><pre> // Returns the fraction
|
||
|
float fraction(float val);</pre><pre> // Approximate float comparison, to deal with numeric imprecision
|
||
|
bool closeTo(float a, float b, float epsilon = 0.00001f);
|
||
|
bool closeTo(double a, double b, double epsilon = 0.0000000001);</pre><pre> // Conversion between floating point and IEEE 754 representations
|
||
|
float fpFromIEEE(uint raw);
|
||
|
double fpFromIEEE(uint64 raw);
|
||
|
uint fpToIEEE(float fp);
|
||
|
uint64 fpToIEEE(double fp);
|
||
|
</pre><h2><a class="anchor" id="doc_addon_math_funcs"></a>
|
||
|
Functions</h2>
|
||
|
<p><b>cos, sin, tan</b></p>
|
||
|
<p>Calculates the trigonometric functions cosine, sine, and tangent. The input angle should be given in radian.</p>
|
||
|
<p><b>acos, asin, atan</b></p>
|
||
|
<p>Calculates the inverse of the trigonometric functions cosine, sine, and tangent. The returned angle is given in radian.</p>
|
||
|
<p><b>atan2</b></p>
|
||
|
<p>Calculates the inverse of the trigonometric function tangent. The input is the y and x proportions. The returned angle is given in radian.</p>
|
||
|
<p><b>cosh, sinh, tanh</b></p>
|
||
|
<p>Calculates the hyperbolic of the cosine, sine, and tangent. The input angle should be given in radian.</p>
|
||
|
<p><b>log, log10</b></p>
|
||
|
<p>Calculates the logarithm of the input value. log is the natural logarithm and log10 is the base-10 logarithm.</p>
|
||
|
<p><b>pow</b></p>
|
||
|
<p>Calculates the based raised to the power of exponent.</p>
|
||
|
<p><b>sqrt</b></p>
|
||
|
<p>Calculates the square root of the value.</p>
|
||
|
<p><b>abs</b></p>
|
||
|
<p>Returns the absolute value.</p>
|
||
|
<p><b>ceil, floor</b></p>
|
||
|
<p>ceil returns the closest integer number that is higher or equal to the input. Floor returns the closest integer number that is lower or equal to the input.</p>
|
||
|
<p><b>fraction</b></p>
|
||
|
<p>Returns the fraction of the number, i.e. what remains after taking away the integral number.</p>
|
||
|
<p><b>closeTo</b></p>
|
||
|
<p>Due to numerical errors with the binary representation of real numbers it is often difficult to do direct comparisons of two float values. The closeTo function will return true of the two values are almost equal, allowing for a small difference up to the size of the epsilon value.</p>
|
||
|
<p><b>fpFromIEEE, fpToIEEE</b></p>
|
||
|
<p>Translates the float to and from IEEE 754 representation. This can be used if one wishes to directly inspect or manipulate the floating point value in the binary representation.</p>
|
||
|
<h2><a class="anchor" id="doc_addon_math_complex"></a>
|
||
|
The complex type</h2>
|
||
|
<pre>
|
||
|
// This type represents a complex number with real and imaginary parts
|
||
|
class complex
|
||
|
{
|
||
|
// Constructors
|
||
|
complex();
|
||
|
complex(const complex &in);
|
||
|
complex(float r);
|
||
|
complex(float r, float i);</pre><pre> // Equality operator
|
||
|
bool opEquals(const complex &in) const;</pre><pre> // Compound assignment operators
|
||
|
complex &opAddAssign(const complex &in);
|
||
|
complex &opSubAssign(const complex &in);
|
||
|
complex &opMulAssign(const complex &in);
|
||
|
complex &opDivAssign(const complex &in);</pre><pre> // Math operators
|
||
|
complex opAdd(const complex &in) const;
|
||
|
complex opSub(const complex &in) const;
|
||
|
complex opMul(const complex &in) const;
|
||
|
complex opDiv(const complex &in) const;</pre><pre> // Returns the absolute value (magnitude)
|
||
|
float abs() const;</pre><pre> // Swizzle operators
|
||
|
complex get_ri() const;
|
||
|
void set_ri(const complex &in);
|
||
|
complex get_ir() const;
|
||
|
void set_ir(const complex &in);</pre><pre> // The real and imaginary parts
|
||
|
float r;
|
||
|
float i;
|
||
|
}
|
||
|
</pre><p><b>complex</b></p>
|
||
|
<p>The constructors allow for implicit construction, making a copy, implicit conversion from float, and explicit initialization from two float values.</p>
|
||
|
<p><b>=, !=</b></p>
|
||
|
<p>Compares two complex values.</p>
|
||
|
<p><b>=, +=, -=, *=, /=</b></p>
|
||
|
<p>Assign and compound assignment of complex values.</p>
|
||
|
<p><b>+, -, *, /</b></p>
|
||
|
<p>Math operators on complex values.</p>
|
||
|
<p><b>abs</b></p>
|
||
|
<p>Returns the absolute (magnitude) of the complex value.</p>
|
||
|
<p><b>r, i</b></p>
|
||
|
<p>Retrieves the real and imaginary part of the complex value.</p>
|
||
|
<p><b>ri, ir</b></p>
|
||
|
<p>Swizzle operators return a complex value with the ordering of the real and imaginary parts as indicated by the name. </p>
|
||
|
</div></div><!-- contents -->
|
||
|
</div><!-- PageDoc -->
|
||
|
</div><!-- doc-content -->
|
||
|
<!-- start footer part -->
|
||
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||
|
<ul>
|
||
|
<li class="footer">Generated on Sat Dec 5 2020 23:20:24 for AngelScript by
|
||
|
<a href="http://www.doxygen.org/index.html">
|
||
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.18 </li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|