-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVectorCalculation.cs
30 lines (29 loc) · 1.36 KB
/
VectorCalculation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using PearlCalculatorLib.PearlCalculationLib.World;
using PearlCalculatorLib.PearlCalculationLib.MathLib;
namespace PearlCalculatorLib.PearlCalculationLib
{
public static class VectorCalculation
{
/// <summary>
/// Calculate the accelerating vector of the TNT
/// </summary>
/// <param name="pearlPosition">The Gobal Coordinate of the Ender Pearl(Might Occur Error when it is too far away from the TNT</param>
/// <param name="tntPosition">The Gobal Coordinate of the TNT(Might Occur Error when it is too far away from the TNT</param>
/// <returns>Return the accelerating vector of the TNT</returns>
public static Space3D CalculateMotion(Space3D pearlPosition , Space3D tntPosition)
{
//Don't ask me
//I have No Idea about it
//Ask Mojang instead
tntPosition.Y += 0.98F * 0.0625D;
Space3D distance = pearlPosition - tntPosition;
double distanceSqrt = MathHelper.Sqrt(distance.DistanceSq());
double d12 = distanceSqrt / 8;
Space3D vector = new Space3D(distance.X , pearlPosition.Y + (0.85F * 0.25F) - tntPosition.Y , distance.Z);
double d13 = MathHelper.Sqrt(vector.DistanceSq());
vector /= d13;
double d11 = 1.0D - d12;
return new Space3D(vector * d11);
}
}
}