角度

From Minecraft Parkour Wiki
Revision as of 16:08, 11 September 2021 by Pjx1314 (talk | contribs) (Created page with "例如,偏航角为5898195°时的乘数为1.003,这与小半角(135.0055°的乘数为1.00005)相比是巨大的。这个半角是目前最有效的存在,并使[https:...")
Other languages:

本文是鼠标运动的延续,重点介绍三角函数在Minecraft中的工作原理。


玩家的偏航角是一个浮点数,用于跟踪玩家的水平旋转(以度为单位)。它是无限的

玩家的朝向是将偏航角限制为[-180°, 180°],如F3所示。

有效角,或者简单地说,角度是一个整数 (从 )。



有效角

Minecraft 的三角函数依赖于有效角,这意味着玩家的偏航角必须转换为一个角度。

这种转换会导致不精准:一个有效角跨越 ~Failed to parse (syntax error): {\displaystyle 0.0055°} ).


Sin() and Cos() 原代码 (来自MathHelper):

private static final float[] SIN_TABLE = new float[65536];


public static float sin(float value) //in radians
{
    return SIN_TABLE[(int)(value * 10430.378F) & 65535];
}

public static float cos(float value) //in radians
{
    return SIN_TABLE[(int)(value * 10430.378F + 16384.0F) & 65535];
}


static
{
    for (int i = 0; i < 65536; ++i)
    {
        SIN_TABLE[i] = (float)Math.sin((double)i * Math.PI * 2.0D / 65536.0D);
    }
}

Note: & 65535给出除以 65536 的(正)余数() 为了将玩家的偏航转换为弧度(当调用sin和cos时),游戏使用了这两个公式:

//通用公式
f = this.rotationYaw * (float)Math.PI / 180.0F

////添加sprintjump boost时使用的公式
f = this.rotationYaw * 0.017453292F

两者都有相同的目的,但对于较大的值,结果可能不同。

在这种情况下,短跑跳跃将玩家稍微向一侧移动,这对于无转弯策略可能很有用。


半角

(int)(value * 10430.378F)(int)(value * 10430.378F + 16384.0F) 应该相隔 16384 个单位(90°),但由于浮点不精确,某些值可能会进一步相差 1 个或更多个单位,从而导致与预期计算的轻微偏移。

两个连续的角度(30237 和 30238)和中间的正半角。

半角 就是这样的值,可以在连续角的“中间”找到(因此得名)。

半角的存在完全是由于括号内的“+ 16384”。


半角在工具辅助跑酷之外没有太大用处:它们对跳跃距离的影响很小,并且它们几乎无法用于实时鼠标移动。


每个半角都有一个相关的乘数,代表其效益。

它对应于从 cos(f) 和 sin(f) 获得的单位向量的范数。

从数学上讲,它应该始终等于 1,但这在这种情况下并不成立。

  • “递增”半角的范数大于 1:它们会增加移动速度。
  • “递减”半角的范数小于 1:它们会降低移动速度。




当与给定的跳跃距离相乘时,它以其对应的半角给出了改进跳跃距离的上限。



有用的半角列表



大半角

2021年7月27日,凯米兹发现,当使用Optifine Fast Math(一种将有效角数量减少到4096个的功能)时, 某些偏航角会提供更高的速度。事实上,这并不是快速运算所特有的,很快人们就发现了原版的“大半角”。

大半角更有效,因为在该范围内可以使用的精度浮点数较少:角度最多可以移动 64 个单位,而不是移动一个单位。

例如,偏航角为5898195°时的乘数为1.003,这与小半角(135.0055°的乘数为1.00005)相比是巨大的。这个半角是目前最有效的存在,并使[https://youtu.be/bQfl2Lleafw

2.125bm 4+0.5]之类的跳跃成为可能。

Reaching such high values may require using macros or mods, as turning manually would take too long.


With Fast Math, half angles are further amplified and the player is able to move while their yaw is less than , compared to in vanilla.

For example, the yaw 121000000° gives a multiplier of 1.09, which is so ludicrous it makes flat momentum 5b possible. This mechanic should not be considered official as it relies on a mod, and using this exploit is likely not authorized on servers (even if Optifine is).

New versions of Optifine changed the effect of fast math, which eliminated a lot of FM half angles (since version U L5, released in december 2019).


Characterization

Decreasing half angles are abundant between -90° and 0°, because negative floats are truncated up while positive floats are truncated down.

Decreasing half angles exist rarely between 0° and 90°.

Increasing half angles exist rarely between 90° and 180°.

Large half angles are of the form , with and . They are all increasing until , at which point they may either be increasing or decreasing.