https://wiki.reallusion.com/index.php?title=IC_Python_API:Basic_Math&feed=atom&action=history
IC Python API:Basic Math - Revision history
2024-03-29T14:11:29Z
Revision history for this page on the wiki
MediaWiki 1.26.2
https://wiki.reallusion.com/index.php?title=IC_Python_API:Basic_Math&diff=4347&oldid=prev
Chuck (RL): /* Repeat */
2020-03-10T04:22:49Z
<p><span dir="auto"><span class="autocomment">Repeat</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 04:22, 10 March 2020</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l47" >Line 47:</td>
<td colspan="2" class="diff-lineno">Line 47:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Repeat ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Repeat ==</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; 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;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; 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;"><div><ins style="font-weight: bold; text-decoration: none;">Loops the value t, so that it is never larger than length and never smaller than 0.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><syntaxhighlight lang="Python"></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><syntaxhighlight lang="Python"></div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Basic_Math&diff=4346&oldid=prev
Chuck (RL): /* Required Modules */
2020-03-10T04:22:07Z
<p><span dir="auto"><span class="autocomment">Required Modules</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 04:22, 10 March 2020</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l7" >Line 7:</td>
<td colspan="2" class="diff-lineno">Line 7:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We'll need the standard Reallusion Python API to access the '''RMath''' class to perform certain types of calculations.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>We'll need the standard Reallusion Python API to access the '''RMath''' class to perform certain types of calculations.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; 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;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; 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;"><div><ins style="font-weight: bold; text-decoration: none;"><syntaxhighlight lang="Python"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; 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;"><div><ins style="font-weight: bold; text-decoration: none;">import RLPy</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; 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;"><div><ins style="font-weight: bold; text-decoration: none;"></syntaxhighlight></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Lerp ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Lerp ==</div></td></tr>
</table>
Chuck (RL)
https://wiki.reallusion.com/index.php?title=IC_Python_API:Basic_Math&diff=4345&oldid=prev
Chuck (RL): Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}} This article will go over some basic math formulae for common numerical operations. == Required Modules..."
2020-03-10T04:21:07Z
<p>Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}} This article will go over some basic math formulae for common numerical operations. == Required Modules..."</p>
<p><b>New page</b></p><div>{{TOC}}<br />
{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}<br />
<br />
This article will go over some basic math formulae for common numerical operations.<br />
<br />
== Required Modules ==<br />
<br />
We'll need the standard Reallusion Python API to access the '''RMath''' class to perform certain types of calculations.<br />
<br />
== Lerp ==<br />
<br />
Linearly interpolates between a and b by t.<br />
<br />
<syntaxhighlight lang="Python"><br />
def lerp(a, b, t):<br />
return a + (b-a) * RLPy.RMath.Clamp(t, 0, 1)<br />
</syntaxhighlight><br />
<br />
=== Examples ===<br />
<br />
<syntaxhighlight lang="Python"><br />
print(lerp(25, 100, 0.5)) # 62.5<br />
print(lerp(0, 50, 0.25)) # 12.5<br />
</syntaxhighlight><br />
<br />
== Inverse Lerp ==<br />
<br />
Calculates the linear parameter t that produces the interpolant value within the range [a, b].<br />
<br />
<syntaxhighlight lang="Python"><br />
def inverse_lerp(a, b, value):<br />
if a != b:<br />
return RLPy.RMath.Clamp((value - a) / (b - a), 0, 1)<br />
return 0<br />
</syntaxhighlight><br />
<br />
=== Examples ===<br />
<br />
<syntaxhighlight lang="Python"><br />
print(inverse_lerp(0, 100, 50)) # 0.5<br />
print(inverse_lerp(0, 3, 0.345)) # 0.11500000208616257<br />
</syntaxhighlight><br />
<br />
== Repeat ==<br />
<br />
<syntaxhighlight lang="Python"><br />
def repeat(t, length):<br />
return RLPy.RMath.Clamp(t - RLPy.RMath.Floor(t / length) * length, 0, length)<br />
</syntaxhighlight><br />
<br />
=== Examples ===<br />
<br />
<syntaxhighlight lang="Python"><br />
print(repeat(24, 10)) # 4<br />
print(repeat(3, 12)) # 3<br />
</syntaxhighlight><br />
<br />
== Ping Pong ==<br />
<br />
PingPongs the value t, so that it is never larger than length and never smaller than 0.<br />
<br />
<syntaxhighlight lang="Python"><br />
def pingpong(t, length):<br />
t = repeat(t, length * 2)<br />
return length - abs(t-length)<br />
</syntaxhighlight><br />
<br />
=== Examples ===<br />
<br />
<syntaxhighlight lang="Python"><br />
print(pingpong(-150, 10)) # 10<br />
print(pingpong(4, 1)) # 0<br />
print(pingpong(30, 20)) # 10<br />
</syntaxhighlight></div>
Chuck (RL)