-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from poly-rabbotics/swerve-thread
- Loading branch information
Showing
8 changed files
with
1,812 additions
and
1,679 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,63 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
public final class Angle { | ||
public static final double TAU = Math.PI * 2; | ||
|
||
private double dec = 0.0; | ||
|
||
public double radians() { | ||
return dec * TAU; | ||
} | ||
|
||
public double degrees() { | ||
return dec * 360.0; | ||
} | ||
|
||
public Angle setRadians(double radians) { | ||
dec = radians / TAU; | ||
return this; | ||
} | ||
|
||
public Angle setDegrees(double degrees) { | ||
dec = degrees / 360.0; | ||
return this; | ||
} | ||
|
||
public Angle add(Angle other) { | ||
var angle = new Angle(); | ||
angle.dec = this.dec + other.dec; | ||
return angle; | ||
} | ||
|
||
public Angle sub(Angle other) { | ||
var angle = new Angle(); | ||
angle.dec = this.dec - other.dec; | ||
return angle; | ||
} | ||
|
||
/** | ||
* Creates a new identical angle so that modification of the original will not | ||
* effect the value returned from this function. | ||
*/ | ||
public Angle clone() { | ||
var ang = new Angle(); | ||
ang.dec = this.dec; | ||
return ang; | ||
} | ||
} | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
public final class Angle implements Cloneable { | ||
public static final double TAU = Math.PI * 2; | ||
|
||
private double dec = 0.0; | ||
|
||
public double radians() { | ||
return dec * TAU; | ||
} | ||
|
||
public double degrees() { | ||
return dec * 360.0; | ||
} | ||
|
||
public Angle setRadians(double radians) { | ||
dec = radians / TAU; | ||
return this; | ||
} | ||
|
||
public Angle setDegrees(double degrees) { | ||
dec = degrees / 360.0; | ||
return this; | ||
} | ||
|
||
public Angle add(Angle other) { | ||
var angle = new Angle(); | ||
angle.dec = this.dec + other.dec; | ||
return angle; | ||
} | ||
|
||
public Angle sub(Angle other) { | ||
var angle = new Angle(); | ||
angle.dec = this.dec - other.dec; | ||
return angle; | ||
} | ||
|
||
public Angle mul(double scalar) { | ||
var angle = new Angle(); | ||
angle.dec = this.dec * scalar; | ||
return angle; | ||
} | ||
|
||
public Angle div(double scalar) { | ||
return this.mul(1 / scalar); | ||
} | ||
|
||
@Override | ||
public Angle clone() { | ||
var ang = new Angle(); | ||
ang.dec = this.dec; | ||
return ang; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.degrees() + "°"; | ||
} | ||
} |
Oops, something went wrong.