Skip to content

Commit

Permalink
Merge pull request #26 from poly-rabbotics/swerve-thread
Browse files Browse the repository at this point in the history
  • Loading branch information
an-prata authored Oct 12, 2023
2 parents 3714f9f + eaa2e98 commit b628d34
Show file tree
Hide file tree
Showing 8 changed files with 1,812 additions and 1,679 deletions.
482 changes: 241 additions & 241 deletions src/main/java/frc/robot/Robot.java

Large diffs are not rendered by default.

114 changes: 63 additions & 51 deletions src/main/java/frc/robot/subsystems/Angle.java
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() + "°";
}
}
Loading

0 comments on commit b628d34

Please sign in to comment.