mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[wpilib] Joystick.getMagnitude(): use hypot() function (#4816)
This commit is contained in:
@@ -116,7 +116,7 @@ BooleanEvent Joystick::Top(EventLoop* loop) const {
|
||||
}
|
||||
|
||||
double Joystick::GetMagnitude() const {
|
||||
return std::sqrt(std::pow(GetX(), 2) + std::pow(GetY(), 2));
|
||||
return std::hypot(GetX(), GetY());
|
||||
}
|
||||
|
||||
double Joystick::GetDirectionRadians() const {
|
||||
|
||||
@@ -291,7 +291,7 @@ public class Joystick extends GenericHID {
|
||||
* @return The magnitude of the direction vector
|
||||
*/
|
||||
public double getMagnitude() {
|
||||
return Math.sqrt(Math.pow(getX(), 2) + Math.pow(getY(), 2));
|
||||
return Math.hypot(getX(), getY());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user