9
edits
m (change headings to sentence casing) |
(Significantly reduce usage of <math> tags to reduce chance of "Math extension cannot connect to Restbase" error) |
||
| Line 1: | Line 1: | ||
The '''Iwerlipse''' (pronounced ee-ver-lipse /ˈivɜlɪps/) is the range of positions Mario can occupy while he is in the air and cannot turn, assuming that drag is constant. The boundary of the Iwerlipse is reached by '''Arctan Straining''' - the optimal way of air straining that gives the greatest distance along a chosen angle | The '''Iwerlipse''' (pronounced ee-ver-lipse /ˈivɜlɪps/) is the range of positions Mario can occupy while he is in the air and cannot turn, assuming that drag is constant. The boundary of the Iwerlipse is reached by '''Arctan Straining''' - the optimal way of air straining that gives the greatest distance along a chosen angle ''ω'' for a given number of frames ''T''. For a single frame ''T'' = 1, the Iwerlipse is an ellipse with half-width 10 (in the sideways direction) and half-height 1.5 (in the forwards direction). For general ''T'', it resembles an ellipse with half-width 10''T'' and half-height 3''T''(''T''+1)/4, but bulges at the corners, covering more area than an ellipse with the same dimensions. As shown by ''Grassdigger'', the shape is well approximated by a generalised superellipse, and thus ''Pannenkoek2012'' proposed calling this shape the Iwerlipse - a pun on the name of ''Iwer Sonsch'', who first discoverered that Arctan Straining was optimal in April 2018. | ||
==Basics== | ==Basics== | ||
Arctan Straining gives the maximum possible distance along a target angle | Arctan Straining gives the maximum possible distance along a target angle ''ω'' that differs from the facing angle ''θ'', over a finite number of frames ''T''. It is performed by choosing straining angles 𝜙<sub>t</sub> (intendedYaw) such that | ||
<div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | <div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | ||
| Line 17: | Line 17: | ||
</div> | </div> | ||
with | with ''t'' being the frame number between 1 and ''T''. (Usually only the top row of this equation is given, but since the arctan function only gives results between ±90°, we must add 180° to the result if the target angle is behind Mario.) | ||
Arctan straining is a result of two asymmetries in how Mario's forward velocity and sideways speed are updated | Arctan straining is a result of two asymmetries in how Mario's forward velocity and sideways speed are updated | ||
* Forward velocity accelerates gradually over time, while sideways speed is reset every frame | * Forward velocity accelerates gradually over time, while sideways speed is reset every frame. | ||
* Straining on a single frame has a weak effect on forward velocity (increasing velocity by a maximum of 1.5), but a strong effect on sideways speed for a single frame (setting sideways speed to a maximum of 10). | * Straining on a single frame has a weak effect on forward velocity (increasing velocity by a maximum of 1.5), but a strong effect on sideways speed for a single frame (setting sideways speed to a maximum of 10). | ||
| Line 27: | Line 27: | ||
In terms of total distance acquired along some direction, forward velocity is thus more effective over long periods of time, where it has time to accelerate to large values, whereas sideways speed is more effective over short periods of time. Optimal straining over many frames then involves straining mostly along the forwards direction to build up a large forward velocity, and then towards the end of the trajectory, transitioning into sideways straining to exploit the large sideways displacement obtainable in a single frame. | In terms of total distance acquired along some direction, forward velocity is thus more effective over long periods of time, where it has time to accelerate to large values, whereas sideways speed is more effective over short periods of time. Optimal straining over many frames then involves straining mostly along the forwards direction to build up a large forward velocity, and then towards the end of the trajectory, transitioning into sideways straining to exploit the large sideways displacement obtainable in a single frame. | ||
==Update | ==Update Equations== | ||
When Mario is in the air and cannot turn, the function <code>update_air_without_turn</code> is responsible for updating Mario's velocity variables from one frame, | When Mario is in the air and cannot turn, the function <code>update_air_without_turn</code> is responsible for updating Mario's velocity variables from one frame, ''t''-1, to the next, ''t''. Without loss of generality, we can choose coordinates so that Mario's facing angle is zero. In other words, he is facing along the z-axis, while his sideways speed is directed along the x-axis. Mario's forward velocity and position coordinates are then updated via | ||
<div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | <div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | ||
<math>\begin{align} | <math>\begin{align} | ||
v_t &= v_{t-1} - D(v_{t-1}, \phi_t) + 1.5\cos(\phi_t),\\ | v_t &= v_{t-1} - D(v_{t-1}, \phi_t) + 1.5\cos(\phi_t),\\ | ||
z_t &= z_{t-1} + v_t,\\ x_t &= x_{t-1} + 10\sin(\phi_t), | z_t &= z_{t-1} + v_t,\\ | ||
x_t &= x_{t-1} + 10\sin(\phi_t), | |||
\end{align}</math> | \end{align}</math> | ||
</div> | </div> | ||
where < | where 𝜙<sub>t</sub> is the straining angle (intendedYaw) on frame ''t''. The total effect of drag is determined by | ||
<math> | <math> | ||
| Line 51: | Line 52: | ||
</math> | </math> | ||
where < | where ''D''<sub>cap</sub> is a soft velocity cap equal to 48 for long jumps and 32 otherwise. In practice, these drag boundaries are far enough apart that the drag is often constant over large periods of time. In this case we can write Mario's position after ''T'' frames as | ||
In practice, these drag boundaries are far enough apart that the drag is often constant over large periods of time. In this case we can write Mario's position after | |||
<math>\begin{align} | <math>\begin{align} | ||
x_T &= x_0 + 10 \sum_{t=1}^{T} \sin(\phi_t),\\ | x_T &= x_0 + 10 \sum_{t=1}^{T} \sin(\phi_t),\\ | ||
z_T &= z_0 + v_0 T - | z_T &= z_0 + v_0 T - \frac{DT(T+1)}{2} + 1.5 \sum_{t=1}^T (T+1-t)\cos(\phi_t). | ||
\end{align}</math> | \end{align}</math> | ||
In deriving the expression for ''z<sub>T</sub>'' we have used that the sum of the first ''T'' integers is equal to the triangle number ''T''(''T''+1)/2, and we have grouped together terms of cos(𝜙<sub>t</sub>). Notice that, since forward straining produces an acceleration that is not reset between frames, earlier frames have a stronger effect on ''z<sub>T</sub>'' than later frames. The effective strength is 1.5(''T''+1-''t''), i.e. 1.5 multiplied by the number of frames remaining (including the current frame), since the forward velocity gained on one frame produces a displacement also on all remaining frames. | |||
==Arctan Straining Proof== | |||
The displacement vector after ''T'' frames is '''R''' = (''x<sub>T</sub>'' − ''x<sub>0</sub>'') '''x̂''' + (''z<sub>T</sub>'' − ''z<sub>0</sub>'') '''ẑ'''. Taking the dot product of this with the unit vector along the target angle ''ω'' gives the distance moved along this angle | |||
== | <math> | ||
\begin{align} | |||
S &= \left(v_0 T - \frac{DT(T+1)}{2}\right)\cos(\omega)\\ | |||
&+ \sum_{t=1}^T \left[10\sin(\phi_t)\sin(\omega) + 1.5(T+1-t)\cos(\phi_t)\cos(\omega)\right],\\ | |||
\end{align} | |||
</math> | |||
where the first line is a constant displacement due to our initial velocity and drag, and the second line gives the effective contribution from straining on each frame. Thanks to this separation, we can maximize the total distance by individually maximizing each contribution, d''S''/d𝜙<sub>t</sub> = 0, yielding | |||
<math>\ | <math> \tan(\phi_t - \theta) = \frac{10\tan(\omega - \theta)}{1.5(T+1-t)},</math> | ||
where we have also rotated the coordinate system back to allow for general facing angles θ. Since tan(''x'') = tan(''x''±180°), this equation has two unique solutions for 𝜙<sub>t</sub> which are given above. | |||
== Iwerlipse Equations == | |||
By writing sin(𝜙<sub>t</sub>) and cos(𝜙<sub>t</sub>) in terms of tan(𝜙<sub>t</sub>), and using the optimal straining relation, we obtain exact expressions for the boundary of the Iwerlipse after ''T'' frames | |||
< | |||
<div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | <div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | ||
| Line 111: | Line 86: | ||
</div> | </div> | ||
where | where ''β'' = 1.5/10tan(''ω''), and ⟨''z''⟩ = ''z''<sub>0</sub> + ''v''<sub>0</sub>''T'' - ''DT''(''T''+1)/2. We can restrict 0 < ''ω'' < 90°, with the four combinations of plus and minus signs giving the remaining quadrants. The Iwerlipse's half-width is ''x''<sub>max</sub> = 10''T'', while its half-height is ''z''<sub>max</sub> = 3''T''(''T''+1)/4. | ||
< | |||
We can restrict | |||
The Iwerlipse's half-width is < | |||
=== Approximations === | === Approximations === | ||
If | If ''T'' is large, the exact expressions involve large summation terms, so it may be useful to have approximate expressions that are easier to compute. | ||
By replacing the summations from | By replacing the summations from ''t'' = 1 to ''t'' = ''T'' with an integral from ''t'' = 1/2 to ''t'' = ''T'' + 1/2 (essentially performing the midpoint rule of numerical integration in reverse), we obtain | ||
<div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | <div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | ||
| Line 131: | Line 97: | ||
</div> | </div> | ||
with the notation | with the notation [F(t)]<sub>a</sub><sup>b</sup> = F(b) − F(a). This approximation converges to the true result very quickly - even for ''T'' = 2, the RMS error (normalized by ''x''<sub>max</sub> and ''z''<sub>max</sub>) is 4.3×10<sup>−3</sup>, while for ''T > 6'' it is less than 10<sup>−3</sup>. Similar expressions obtained using the Euler–Maclaurin formula converge more slowly, even with first-order correction terms. | ||
This approximation converges to the true result very quickly | |||
even for | |||
while for | |||
Similar expressions obtained using the Euler–Maclaurin formula converge more slowly, even with first-order correction terms. | |||
A simpler but less accurate approximation is obtained by fitting the Iwerlipse to a generalized superellipse | |||
<div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | <div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | ||
<math> \left(\frac{x_T - x_0}{x_\mathrm{max}}\right)^{m(T)} + \left(\frac{z_T - \langle z \rangle}{x_\mathrm{max}}\right)^{n(T)} = 1 | <math> \left(\frac{x_T - x_0}{x_\mathrm{max}}\right)^{m(T)} + \left(\frac{z_T - \langle z \rangle}{x_\mathrm{max}}\right)^{n(T)} = 1, </math> | ||
</div> | </div> | ||
with exponents ''m(T)'' and ''n(T)'' found by minimizing the error. These have been computed up to large ''T'', and can be obtained from a lookup table<ref>[https://drive.google.com/file/d/1xDmgHz878qiAS1ZF1Y5M0M1eiZUdZRSl/view?usp=sharing Showing Iwer's proof and deriving the Iwerlipse expressions.]</ref>. In the limit ''T'' ≫ 1, the exponents converge to ''m'' ≈ 2.520897 and ''n'' ≈ 2.064371, but unlike the integral approximation, the expression never converges to the exact result — there is always some small error. | |||
== Quarterstep Penalty == | |||
== Quarterstep | |||
If | If a number of quartersteps, ''q'' ∈ {0,1,2,3}, are lost on the final frame, the forward velocity gained on frame ''t'' no longer accumulates forward distance over ''T''+1-''t'' frames, but instead over ''T'' - ''q''/4 + 1 - ''t'' frames. The optimal straining relation then becomes: | ||
the forward velocity gained on frame | |||
but instead over | |||
The optimal straining relation becomes: | |||
<div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | <div style="background:#f9f9f9; border-left:3px solid #bbb; padding:0.4em 0.8em; margin:1em 0;"> | ||
| Line 157: | Line 113: | ||
</div> | </div> | ||
The optimal straining angle for the final frame is not affected, since in this case the ellipse shrinks in both directions rather than just vertically, i.e. a factor | The optimal straining angle for the final frame is not affected, since in this case the ellipse shrinks in both directions rather than just vertically, i.e. a factor (1-''q''/4) cancels in the numerator and denominator. | ||
== History == | == History == | ||
| Line 184: | Line 140: | ||
<div style="font-size:120%; font-weight:bold; margin-top:1em;">16 April 2018</div> | <div style="font-size:120%; font-weight:bold; margin-top:1em;">16 April 2018</div> | ||
Iwer states the optimal straining equation for the first time in the following form | Iwer states the optimal straining equation for the first time in the following form | ||
<math>\phi_{t'} - \theta = \operatorname{arccot}(0.15\,r\,t')</math> | <math>\phi_{t'} - \theta = \operatorname{arccot}(0.15\,r\,t')</math> | ||
This is equivalent to our expression above, since | This is equivalent to our expression above, since arccot(''x'') = arctan(1/''x''), | ||
with, | with, ''r'' = 1/tan(''ω''), and, ''t''' = ''T'' + 1 - ''t''. | ||
(If using this expression, we need to add 180° if the target angle is to the right of Mario, since | (If using this expression, we need to add 180° if the target angle is to the right of Mario, since arccot only gives results between 0° and 180°.) | ||
<div style="font-size:120%; font-weight:bold; margin-top:1em;">23 June 2018</div> | <div style="font-size:120%; font-weight:bold; margin-top:1em;">23 June 2018</div> | ||
| Line 219: | Line 175: | ||
sm64expert adds arctan straining to [https://github.com/mupen64/SM64LuaRedux SM64 Lua Redux]. | sm64expert adds arctan straining to [https://github.com/mupen64/SM64LuaRedux SM64 Lua Redux]. | ||
==See | ==See Also== | ||
[[Straining]] | [[Straining]] | ||
edits