<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3AResources%3Ascript_modules%3Amath</id>
	<title>Hpl2:Resources:script modules:math - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3AResources%3Ascript_modules%3Amath"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;action=history"/>
	<updated>2026-05-14T18:08:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;diff=3505&amp;oldid=prev</id>
		<title>Mudbill at 23:13, 5 August 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;diff=3505&amp;oldid=prev"/>
		<updated>2020-08-05T23:13:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 23:13, 5 August 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Math Functions =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Math Functions=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following block of code is a set of Math functions arranged by Apjjm. These functions were made using [&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http:&lt;/del&gt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;/wiki.frictionalgames.com/hpl2/resources/improvnotepad&lt;/del&gt;|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Apjjm's &lt;/del&gt;Improved Notepad++ HPS Support]], and concequently would be viewed best with this plugin. Copy and paste the code below either into your .hps file or into some external file if using a [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Hpl2:Resources:preprocess &lt;/del&gt;| Script Pre-Processer]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following block of code is a set of Math functions arranged by Apjjm. These functions were made using [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[HPL2&lt;/ins&gt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Improved Notepad++ Support&lt;/ins&gt;|Improved Notepad++ HPS Support]], and concequently would be viewed best with this plugin. Copy and paste the code below either into your .hps file or into some external file if using a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;HPL2/Script Pre-Processor&lt;/ins&gt;|Script Pre-Processer]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[http://pastebin.com/w5dGt6a5 Code download]  &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[http://pastebin.com/w5dGt6a5 Code download]  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-1757:rev-3505 --&gt;
&lt;/table&gt;</summary>
		<author><name>Mudbill</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;diff=1757&amp;oldid=prev</id>
		<title>Darkfire: Syntax highlightin fix</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;diff=1757&amp;oldid=prev"/>
		<updated>2020-07-22T22:34:42Z</updated>

		<summary type="html">&lt;p&gt;Syntax highlightin fix&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 22:34, 22 July 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Math Functions =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Math Functions =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following block of code is a set of Math functions arranged by Apjjm. These functions were made using [http://wiki.frictionalgames.com/hpl2/resources/improvnotepad|Apjjm's Improved Notepad++ HPS Support]], and concequently would be viewed best with this plugin. Copy and paste the code below either into your .hps file or into some external file if using a [[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Hpl2:Resources&lt;/ins&gt;:preprocess &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;| &lt;/ins&gt;Script Pre-Processer&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The following block of code is a set of Math functions arranged by Apjjm. These functions were made using [http://wiki.frictionalgames.com/hpl2/resources/improvnotepad|Apjjm's Improved Notepad++ HPS Support]], and concequently would be viewed best with this plugin.Copy and paste the code below either into your .hps file or into some external file if using a [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;//wiki.frictionalgames.com/hpl2/resources/&lt;/del&gt;preprocess Script Pre-Processer].&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[http://pastebin.com/w5dGt6a5 Code download]  &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[http://pastebin.com/w5dGt6a5 Code download]  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cpp&lt;/ins&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;----&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;//Begin Math&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;//Begin Math&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;//+ Constants&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;//+ Constants&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-760:rev-1757 --&gt;
&lt;/table&gt;</summary>
		<author><name>Darkfire</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;diff=760&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Resources:script_modules:math&amp;diff=760&amp;oldid=prev"/>
		<updated>2020-07-09T13:48:23Z</updated>

		<summary type="html">&lt;p&gt;Upload from wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Math Functions =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following block of code is a set of Math functions arranged by Apjjm. These functions were made using [http://wiki.frictionalgames.com/hpl2/resources/improvnotepad|Apjjm's Improved Notepad++ HPS Support]], and concequently would be viewed best with this plugin.Copy and paste the code below either into your .hps file or into some external file if using a [[http://wiki.frictionalgames.com/hpl2/resources/preprocess Script Pre-Processer].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://pastebin.com/w5dGt6a5 Code download] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
//Begin Math&lt;br /&gt;
//+ Constants&lt;br /&gt;
const float PI = 3.1415926535f;&lt;br /&gt;
const float HPI = PI * 0.5f;&lt;br /&gt;
const float PI2 = PI * 2.0f;&lt;br /&gt;
//-&lt;br /&gt;
//+ Sign Of&lt;br /&gt;
int sign(float &amp;amp;in x) { if(x==0.0f) return 0; return (x&amp;gt;0.0f)?1:-1; }&lt;br /&gt;
int sign(int &amp;amp;in x)   { if(x==0)    return 0; return (x&amp;gt;0)?1:-1; }&lt;br /&gt;
//-&lt;br /&gt;
//+ Abs&lt;br /&gt;
float abs(float &amp;amp;in x) { return (x&amp;gt;0.0f)?x:-x; }&lt;br /&gt;
int abs(int &amp;amp;in x)     { return (x&amp;gt;0)?x:-x; }&lt;br /&gt;
//-&lt;br /&gt;
//+ Approx&lt;br /&gt;
//Determines if two numbers are approximately equal (Differ by no more than epsilon)&lt;br /&gt;
bool approx(float &amp;amp;in x, float &amp;amp;in y, float &amp;amp;in epsilon) {&lt;br /&gt;
float delta = x-y; return ((delta&amp;gt;0?delta:-delta) &amp;lt;= (epsilon&amp;gt;0?epsilon:-epsilon)); }&lt;br /&gt;
//-&lt;br /&gt;
//+ Sqrt&lt;br /&gt;
//Prereq: Approx&lt;br /&gt;
//Returns the squareroot of x&lt;br /&gt;
const uint32 _SQRTITERATIONS=16; //Maximum number of iterations for sqrt computation&lt;br /&gt;
const float  _SQRTDELTA=0.00001f; //Margin of error allowable if complete before iteration ceiling&lt;br /&gt;
float sqrt(float &amp;amp;in x) {&lt;br /&gt;
  if(x&amp;lt;=0) return 0; //Early out - not valid input.&lt;br /&gt;
  uint32 i = 0; float o = x * 0.5f;&lt;br /&gt;
  while( i&amp;lt;_SQRTITERATIONS &amp;amp;&amp;amp; !approx(o*o,x,_SQRTDELTA) &amp;amp;&amp;amp; o != 0)&lt;br /&gt;
    { o = 0.5f * (o + x/o); i++; }&lt;br /&gt;
  return o;             }&lt;br /&gt;
//-&lt;br /&gt;
//+ Max/Min&lt;br /&gt;
//Max: Returns largest of two numbers&lt;br /&gt;
//Min: Returns smallest of two numbers&lt;br /&gt;
float max(float &amp;amp;in x, float &amp;amp;in y) { return x&amp;gt;y?x:y; }&lt;br /&gt;
int max(int &amp;amp;in x, int &amp;amp;in y) { return x&amp;gt;y?x:y; }&lt;br /&gt;
float min(float &amp;amp;in x, float &amp;amp;in y) { return x&amp;lt;y?x:y; }&lt;br /&gt;
int min(int &amp;amp;in x, int &amp;amp;in y) { return x&amp;lt;y?x:y; }&lt;br /&gt;
float clamp(float &amp;amp;in x, float &amp;amp;in upper, float &amp;amp;in lower) { return (x&amp;lt;lower?lower:(x&amp;lt;upper?x:upper)); }&lt;br /&gt;
int clamp(int &amp;amp;in x, int &amp;amp;in upper, int &amp;amp;in lower) { return (x&amp;lt;lower?lower:(x&amp;lt;upper?x:upper)); }&lt;br /&gt;
//-&lt;br /&gt;
//+ Factorial&lt;br /&gt;
uint32 fact(uint32 &amp;amp;in x) { if(x==0) return 1;&lt;br /&gt;
    uint32 y = x; for(uint32 i=x-1; i&amp;gt;0; i--) y*=i; return y; }&lt;br /&gt;
int fact(int &amp;amp;in x)       { if(x&amp;lt;=0) return 1;&lt;br /&gt;
    int y = x; for(int i=x-1; i&amp;gt;0; i--) y*=i; return y; }&lt;br /&gt;
//-&lt;br /&gt;
//+ Conversions&lt;br /&gt;
//Degrees to radians&lt;br /&gt;
float degtorad(float &amp;amp;in x) { return x * 0.0174532925f; }&lt;br /&gt;
//Radians to degrees&lt;br /&gt;
float radtodeg(float &amp;amp;in x) { return x * 57.2957795f; }&lt;br /&gt;
//-&lt;br /&gt;
//+ Trig Functions&lt;br /&gt;
//+ ..Helper&lt;br /&gt;
const float  _TRIGARCTANLIM=128.0f; //Value when x exceeds 90 is returned&lt;br /&gt;
const uint32 _TRIGITERATIONS=32; //Maximum number of iterations for sqrt computation&lt;br /&gt;
const float  _TRIGDELTA=0.00001f; //Smallest diff for trig vals&lt;br /&gt;
//Constrains X : -PI&amp;lt;X&amp;lt;PI&lt;br /&gt;
float trigClamp(float &amp;amp;in x) {&lt;br /&gt;
if(x&amp;gt; PI || x &amp;lt;-PI)&lt;br /&gt;
  { int t = x/PI2; return x-t*PI2; }&lt;br /&gt;
else return x;&lt;br /&gt;
}&lt;br /&gt;
//-&lt;br /&gt;
//+ ..Sin/Cos/Tan&lt;br /&gt;
//COSINE&lt;br /&gt;
float cos(float &amp;amp;in y) {&lt;br /&gt;
  float x = trigClamp(y);&lt;br /&gt;
  float t,s; t=1.0f; s = 1.0f; uint32 p=0;&lt;br /&gt;
  while( p&amp;lt;_TRIGITERATIONS)&lt;br /&gt;
   { p++; t = (-t * x * x) / ((2 * p - 1) * (2 * p)); s+=t; }&lt;br /&gt;
  return s;&lt;br /&gt;
}&lt;br /&gt;
//SINE&lt;br /&gt;
float sin(float &amp;amp;in y) {&lt;br /&gt;
  return cos(y-HPI);&lt;br /&gt;
}&lt;br /&gt;
//TAN (Tan(90 deg) Returns 0xFFFFFFFF [Use isInf()])&lt;br /&gt;
float tan(float &amp;amp;in y) {&lt;br /&gt;
  float x = trigClamp(y);&lt;br /&gt;
  float c = cos(x);&lt;br /&gt;
  if(c&amp;gt; -_TRIGDELTA/2 &amp;amp;&amp;amp; c &amp;lt;_TRIGDELTA/2) return float(0xFFFFFFFF); //Return #+INF                                        &lt;br /&gt;
  return cos(x-HPI)/c;&lt;br /&gt;
}&lt;br /&gt;
//-&lt;br /&gt;
//+ ..ARC Sin/Cos/Tan [APPROX]&lt;br /&gt;
float arccos(float &amp;amp;in x) {&lt;br /&gt;
return trigClamp((-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f); }&lt;br /&gt;
float arcsin(float &amp;amp;in x) { return trigClamp(HPI-arccos(x)); }&lt;br /&gt;
float arctan(float &amp;amp;in x) {  if(x&amp;gt; _TRIGARCTANLIM) return HPI;&lt;br /&gt;
else if(x &amp;lt;-_TRIGARCTANLIM) return -HPI; else return trigClamp(HPI-arccos(x/sqrt(x*x+1.1f))); }&lt;br /&gt;
float arctan2(float &amp;amp;in x, float &amp;amp;in y) {&lt;br /&gt;
float c1 = HPI * 0.5f;    float c2 = 3.0f * c1; float abs_y = abs(y); float angle;    &lt;br /&gt;
if (x&amp;gt;= 0) { float r = (x - abs_y) / (x + abs_y);    angle = c1 - c1 * r;    }&lt;br /&gt;
else { float r = (x + abs_y) / (abs_y - x);    angle = c2 - c1 * r;    }    &lt;br /&gt;
return y&amp;lt;0?-angle:angle; }&lt;br /&gt;
//Can somebody actually get a good expansion to work here?&lt;br /&gt;
//-&lt;br /&gt;
//-&lt;br /&gt;
//+ Rounding&lt;br /&gt;
int floor(float &amp;amp;in x) { return int(x); }&lt;br /&gt;
int ceil(float &amp;amp;in x)  { int y = int(x); return (y==x?y:y+1); }&lt;br /&gt;
int round(float &amp;amp;in x) { int y = int(x); return (y+0.5f&amp;gt;x)?y:(y+1);}&lt;br /&gt;
//-&lt;br /&gt;
//End&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>