Skip to content

Commit

Permalink
Merge pull request Ninjabrain1#84 from ExeRSolver/yaw-based-error-cor…
Browse files Browse the repository at this point in the history
…rection

Update yaw-based angle correction
  • Loading branch information
Ninjabrain1 authored Feb 2, 2024
2 parents 3549b6b + b2ccef4 commit 144167a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public EnderEyeThrowType getType() {
private static double getCorrectedHorizontalAngle(double alpha, double crosshairCorrection) {
alpha += crosshairCorrection;

// Determined experimentally, exact cause unknown
alpha -= 0.00079 * Math.sin((alpha + 45) * Math.PI / 180.0);
// Caused by rounding in client-bound move entity packets
alpha -= 0.000824 * Math.sin((alpha + 45) * Math.PI / 180.0);

return alpha;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public EnderEyeThrowType getType() {
private static double getCorrectedHorizontalAngle(double alpha, double crosshairCorrection) {
alpha += crosshairCorrection;

// Determined experimentally, exact cause unknown
alpha -= 0.00079 * Math.sin((alpha + 45) * Math.PI / 180.0);
// Caused by rounding in client-bound move entity packets
alpha -= 0.000824 * Math.sin((alpha + 45) * Math.PI / 180.0);

return alpha;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void CrosshairCorrectionIntegrationTest(float crosshairCorrection) {

// Assert
TestUtils.awaitSwingEvents();
double experimentallyCorrectedHorizontalAngle = horizontalAngle - 0.00079 * Math.sin((horizontalAngle + 45) * Math.PI / 180.0);
double packetRoundingCorrectedHorizontalAngle = horizontalAngle - 0.000824 * Math.sin((horizontalAngle + 45) * Math.PI / 180.0);
Assertions.assertEquals(Math.round((horizontalAngle + crosshairCorrection) * 100f) / 100f, enderEyePanelTestAdapter.getPanel(0).getAngle(), 1e-4);
Assertions.assertEquals(experimentallyCorrectedHorizontalAngle + crosshairCorrection, integrationTestBuilder.dataState.getThrowList().get(0).horizontalAngle(), 1e-4);
Assertions.assertEquals(packetRoundingCorrectedHorizontalAngle + crosshairCorrection, integrationTestBuilder.dataState.getThrowList().get(0).horizontalAngle(), 1e-4);
}
}

0 comments on commit 144167a

Please sign in to comment.