[wpimath] Clean up math comments (#4252)

This commit is contained in:
Tyler Veness
2022-05-20 15:16:56 -07:00
committed by GitHub
parent fff4d1f44e
commit 5aa67f56e6
25 changed files with 141 additions and 132 deletions

View File

@@ -141,7 +141,7 @@ class LinearFilterTest {
3,
// f(x) = ln(x)
(double x) -> Math.log(x),
// df/dx = 1 / x
// df/dx = 1/x
(double x) -> 1.0 / x,
h,
1.0,
@@ -174,7 +174,7 @@ class LinearFilterTest {
5,
// f(x) = ln(x)
(double x) -> Math.log(x),
// d²f/dx² = -1 /
// d²f/dx² = -1/
(double x) -> -1.0 / (x * x),
h,
1.0,
@@ -213,7 +213,7 @@ class LinearFilterTest {
2,
// f(x) = ln(x)
(double x) -> Math.log(x),
// df/dx = 1 / x
// df/dx = 1/x
(double x) -> 1.0 / x,
h,
1.0,
@@ -246,7 +246,7 @@ class LinearFilterTest {
4,
// f(x) = ln(x)
(double x) -> Math.log(x),
// d²f/dx² = -1 /
// d²f/dx² = -1/
(double x) -> -1.0 / (x * x),
h,
1.0,

View File

@@ -102,8 +102,8 @@ class SwerveDriveKinematicsTest {
var moduleStates = m_kinematics.toSwerveModuleStates(speeds);
/*
The circumference of the wheels about the COR is pi * diameter, or 2 * pi * radius
the radius is the sqrt(12^2in + 12^2in), or 16.9706in, so the circumference the wheels
The circumference of the wheels about the COR is π * diameter, or 2π * radius
the radius is the (12²in + 12²in), or 16.9706in, so the circumference the wheels
trace out is 106.629190516in. since we want our robot to rotate at 1 rotation per second,
our wheels must trace out 1 rotation (or 106.63 inches) per second.
*/
@@ -143,7 +143,7 @@ class SwerveDriveKinematicsTest {
This one is a bit trickier. Because we are rotating about the front-left wheel,
it should be parked at 0 degrees and 0 speed. The front-right and back-left wheels both travel
an arc with radius 24 (and circumference 150.796), and the back-right wheel travels an arc with
radius sqrt(24^2 + 24^2) and circumference 213.2584. As for angles, the front-right wheel
radius (24² + 24²) and circumference 213.2584. As for angles, the front-right wheel
should be pointing straight forward, the back-left wheel should be pointing straight right,
and the back-right wheel should be at a -45 degree angle
*/
@@ -169,12 +169,12 @@ class SwerveDriveKinematicsTest {
var chassisSpeeds = m_kinematics.toChassisSpeeds(flState, frState, blState, brState);
/*
We already know that our omega should be 2pi from the previous test. Next, we need to determine
We already know that our omega should be 2π from the previous test. Next, we need to determine
the vx and vy of our chassis center. Because our COR is at a 45 degree angle from the center,
we know that vx and vy must be the same. Furthermore, we know that the center of mass makes
a full revolution about the center of revolution once every second. Therefore, the center of
mass must be moving at 106.629in/sec. Recalling that the ratios of a 45/45/90 triagle are
1:sqrt(2)/2:sqrt(2)/2, we find that the COM vx is -75.398, and vy is 75.398.
1:(2)/2:(2)/2, we find that the COM vx is -75.398, and vy is 75.398.
*/
assertAll(

View File

@@ -15,16 +15,16 @@ import org.junit.jupiter.api.Test;
class RungeKuttaTimeVaryingTest {
private static Matrix<N1, N1> rungeKuttaTimeVaryingSolution(double t) {
return new MatBuilder<>(Nat.N1(), Nat.N1())
.fill(12.0 * Math.exp(t) / (Math.pow(Math.exp(t) + 1.0, 2.0)));
.fill(12.0 * Math.exp(t) / Math.pow(Math.exp(t) + 1.0, 2.0));
}
// Tests RK4 with a time varying solution. From
// http://www2.hawaii.edu/~jmcfatri/math407/RungeKuttaTest.html:
// x' = x (2 / (e^t + 1) - 1)
// x' = x (2/(eᵗ + 1) - 1)
//
// The true (analytical) solution is:
//
// x(t) = 12 * e^t / ((e^t + 1)^2)
// x(t) = 12eᵗ/(eᵗ + 1)²
@Test
void rungeKuttaTimeVaryingTest() {
final var y0 = rungeKuttaTimeVaryingSolution(5.0);