Use Math.hypot instead of Math.sqrt(a^2 + b^2)

This commit is contained in:
Gold856
2025-03-30 01:30:43 -04:00
committed by Matt Morley
parent 38ee450117
commit e514071094
5 changed files with 7 additions and 11 deletions

View File

@@ -171,7 +171,7 @@ public class SimCameraProperties {
DriverStation.reportError(
"Requested invalid FOV! Clamping between (1, 179) degrees...", false);
}
double resDiag = Math.sqrt(resWidth * resWidth + resHeight * resHeight);
double resDiag = Math.hypot(resWidth, resHeight);
double diagRatio = Math.tan(fovDiag.getRadians() / 2);
var fovWidth = new Rotation2d(Math.atan(diagRatio * (resWidth / resDiag)) * 2);
var fovHeight = new Rotation2d(Math.atan(diagRatio * (resHeight / resDiag)) * 2);