Angles: Difference between revisions
mNo edit summary |
m (small edits - link to F3, formatting.) |
||
Line 5: | Line 5: | ||
The player's '''yaw''' is a [https://en.wikipedia.org/wiki/Floating-point_arithmetic float] that keeps track of the player's horizontal rotation. It is '''unbounded'''. |
The player's '''yaw''' is a [https://en.wikipedia.org/wiki/Floating-point_arithmetic float] that keeps track of the player's horizontal rotation. It is '''unbounded'''. |
||
The player's '''facing''' is the restriction of the yaw to [-180, 180]. |
The player's '''facing''' is the restriction of the yaw to [-180°, 180°], as shown in [[Debug Screen|F3]]. |
||
A '''significant angle''', or simply '''angle''' is an integer (from <math display="inline">0</math> to <math display="inline">2^{16}-1</math>). |
A '''significant angle''', or simply '''angle''' is an integer (from <math display="inline">0</math> to <math display="inline">2^{16}-1</math>). |
||
Line 45: | Line 45: | ||
== Half Angles == |
== Half Angles == |
||
Ideally, <code>(int)(value * 10430.378F)</code> and <code>(int)(value * 10430.378F + 16384.0F)</code> |
Ideally, <code>(int)(value * 10430.378F)</code> and <code>(int)(value * 10430.378F + 16384.0F)</code> should be 16384 units apart (90°), but because of floating point imprecision, some values could end up 1 unit further, causing a slight shift from the intended calculation. |
||
'''Half angles''' are such values, and can found "between" consecutive angles (hence the name). |
'''Half angles''' are such values, and can found "between" consecutive angles (hence the name). |
||
Line 52: | Line 52: | ||
Half angles don't have much use outside of Tool-Assisted Parkour: their effect on jump distance is negligible, and they are hardly usable with mouse movement. |
Half angles don't have much use outside of Tool-Assisted Parkour: their effect on jump distance is negligible, and they are hardly usable with real-time mouse movement. |
||
* Positive half-angles increase the player's speed. They can be found (rarely) in the North-West quadrant (90° to 180°) |
* ''Positive'' half-angles increase the player's speed. They can be found (rarely) in the North-West quadrant (90° to 180°) |
||
* Negative half-angles decrease the player's speed. They can be found |
* ''Negative'' half-angles decrease the player's speed. They can be found in the South-East quadrant (-90° to 0°), as well as in the South-West quadrant (0° to 90°) in rare amounts. |
||
Each half-angle has an associated '''Multiplier''' that represents its effectiveness. |
Each half-angle has an associated '''Multiplier''' that represents its effectiveness. |
||
It corresponds to the norm of the unit vector obtained from cos(F) and sin(F). Mathematically, it should always be equal to 1, but that doesn't hold true in |
It corresponds to the norm of the unit vector obtained from cos(F) and sin(F). Mathematically, it should always be equal to 1, but that doesn't hold true in this context. |
||
Revision as of 22:27, 21 March 2021
This article is a continuation of Mouse Movement, with a focus on how trigonometry works in Minecraft.
The player's yaw is a float that keeps track of the player's horizontal rotation. It is unbounded.
The player's facing is the restriction of the yaw to [-180°, 180°], as shown in F3.
A significant angle, or simply angle is an integer (from to ).
Significant Angles
Minecraft relies on significant angles for its trigonometry, which means the player's yaw has to be converted to an angle.
This conversion induces imprecision: a significant angle spans across ~Failed to parse (syntax error): {\displaystyle 0.0055°} ).
Sin() and Cos() source code (from 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
gives the (positive) remainder of a division by 65536 ( )
Half Angles
Ideally, (int)(value * 10430.378F)
and (int)(value * 10430.378F + 16384.0F)
should be 16384 units apart (90°), but because of floating point imprecision, some values could end up 1 unit further, causing a slight shift from the intended calculation.
Half angles are such values, and can found "between" consecutive angles (hence the name).
Half angles don't have much use outside of Tool-Assisted Parkour: their effect on jump distance is negligible, and they are hardly usable with real-time mouse movement.
- Positive half-angles increase the player's speed. They can be found (rarely) in the North-West quadrant (90° to 180°)
- Negative half-angles decrease the player's speed. They can be found in the South-East quadrant (-90° to 0°), as well as in the South-West quadrant (0° to 90°) in rare amounts.
Each half-angle has an associated Multiplier that represents its effectiveness.
It corresponds to the norm of the unit vector obtained from cos(F) and sin(F). Mathematically, it should always be equal to 1, but that doesn't hold true in this context.
When multiplied with a given jump distance, it gives an upper bound for the improved jump distance with its corresponding half-angle.
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.