mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Merge branch 'main' into 2027
This commit is contained in:
@@ -8,7 +8,9 @@ package edu.wpi.first.math.util;
|
||||
public final class Units {
|
||||
private static final double kInchesPerFoot = 12.0;
|
||||
private static final double kMetersPerInch = 0.0254;
|
||||
private static final double kMetersPerMile = 1609.344;
|
||||
private static final double kSecondsPerMinute = 60;
|
||||
private static final double kMinutesPerHour = 60;
|
||||
private static final double kMillisecondsPerSecond = 1000;
|
||||
private static final double kKilogramsPerLb = 0.453592;
|
||||
|
||||
@@ -137,6 +139,26 @@ public final class Units {
|
||||
return radiansPerSecond * (kSecondsPerMinute / 2) / Math.PI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts miles per hour to meters per second.
|
||||
*
|
||||
* @param mph The miles per hour to convert to meters per second.
|
||||
* @return Meters per second converted from miles per hour.
|
||||
*/
|
||||
public static double milesPerHourToMetersPerSecond(double mph) {
|
||||
return mph * kMetersPerMile / (kSecondsPerMinute * kMinutesPerHour);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts meters per second to miles per hour.
|
||||
*
|
||||
* @param metersPerSecond The meters per second to convert to from miles per hour.
|
||||
* @return Miles per hour converted from meters per second.
|
||||
*/
|
||||
public static double metersPerSecondToMilesPerHour(double metersPerSecond) {
|
||||
return metersPerSecond / kMetersPerMile * (kSecondsPerMinute * kMinutesPerHour);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts given milliseconds to seconds.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user