Angles: Difference between revisions

From Minecraft Parkour Wiki
Content added Content deleted
(added half angles (still incomplete))
mNo edit summary
Line 4: Line 4:
An angle is an '''integer''' (from <math display="inline">0</math> to <math display="inline">2^{16}-1</math>)
An angle is an '''integer''' (from <math display="inline">0</math> to <math display="inline">2^{16}-1</math>)


== Angles and Half Angles ==
Minecraft uses angles for movement calculations, which means the Player's yaw has to be converted before being usable.


This conversion induces some imprecision, as information is lost by casting a '''float''' to an '''int'''.
A single angle spans approximately 0.0055°




This conversion also means two close (but different) facings can result in the same angle being used.


In fact, a single angle spans across ~<math>0.0055°</math>.


== Angles and Half Angles ==
Minecraft uses angles for movement calculations, which means the Player's yaw has to be converted before being usable.

This conversion induces some imprecision.




Line 43: Line 41:
}
}
}
}
</syntaxhighlight>'''Note:''' "& 65535" is the same as "% 65536", which is the remainder of a division by 65536 ( <math>2^{16}</math>)
</syntaxhighlight>'''Note:''' ''<code>& 65535</code>'' is the same as ''<code>% 65536</code>'', which is the remainder of a division by 65536 ( <math>2^{16}</math>)


<br />By analyzing the '''sin()''' and '''cos()''' function from the source code, we can notice [...]
<br />By analyzing the '''sin()''' and '''cos()''' function from the source code, we can notice that the yaw-to-angle conversion is not exactly the same for both functions.

Because floats are rather imprecise for larger values, this means


That's because '''floats''' are rather imprecise for larger values.




'''Half angles''' are specific values for which the corresponding angle are interpreted differently by cos() and sin().
'''Half angles''' are specific values for which the corresponding angle are interpreted differently by cos() and sin().

These half angles are found between angles (hence the name) and can be used to slightly increase jump distance in Tool-Assisted Parkour.
[[File:Half angle visualized.png|none|thumb|582x582px|Two consecutive angles (30237 and 30238) and a positive half angle in between.]]
[[File:Half angle visualized.png|none|thumb|582x582px|Two consecutive angles (30237 and 30238) and a positive half angle in between.]]




'''Note:''' Fast Math is an Optifine feature that reduces the number of angles to 4096 ( <math>2^{12}</math>)
'''Note:''' Fast Math is an Optifine feature that reduces the number of angles to 4096 ( <math>2^{12}</math>). With Fast Math, half angles are fewer in number, but are up to 16x more effective. For example, it makes a [https://youtu.be/19CNqn5r95o no-sprint 3b] jump possible with only flat momentum.

Revision as of 18:36, 22 February 2020

a

The Player's yaw (facing) is a float (from to )

An angle is an integer (from to )

Angles and Half Angles

Minecraft uses angles for movement calculations, which means the Player's yaw has to be converted before being usable.

This conversion induces some imprecision, as information is lost by casting a float to an int.


This conversion also means two close (but different) facings can result in the same angle being used.

In fact, a single angle spans across ~Failed to parse (syntax error): {\displaystyle 0.0055°} .


Trigonometric functions: (from MathHelper):

public class MathHelper
{
    private static final float[] SIN_TABLE = new float[65536];


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

    public static float cos(float value)
    {
        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 is the same as % 65536, which is the remainder of a division by 65536 ( )


By analyzing the sin() and cos() function from the source code, we can notice that the yaw-to-angle conversion is not exactly the same for both functions.

Because floats are rather imprecise for larger values, this means


Half angles are specific values for which the corresponding angle are interpreted differently by cos() and sin().

These half angles are found between angles (hence the name) and can be used to slightly increase jump distance in Tool-Assisted Parkour.

Two consecutive angles (30237 and 30238) and a positive half angle in between.


Note: Fast Math is an Optifine feature that reduces the number of angles to 4096 ( ). With Fast Math, half angles are fewer in number, but are up to 16x more effective. For example, it makes a no-sprint 3b jump possible with only flat momentum.