MathFunctions

public class MathFunctions

This is the MathFunctions class. This contains many useful math related methods that I use in other classes to simplify code elsewhere.

Author

Anyi Lin - 10158 Scott's Bots

Aaron Yang - 10158 Scott's Bots

Harrison Womack - 10158 Scott's Bots

Constructors

Link copied to clipboard
public void MathFunctions()

Functions

Link copied to clipboard
public static Point addPoints(Point one, Point two)
This returns a Point that is the sum of the two input Point.
Link copied to clipboard
public static Pose addPoses(Pose one, Pose two)
This returns a Pose that is the sum of the two input Pose.
Link copied to clipboard
public static Vector addVectors(Vector one, Vector two)
This returns a Vector that is the sum of the two input Vectors.
Link copied to clipboard
public static double clamp(double num, double lower, double upper)
This clamps down a value to between the lower and upper bounds inclusive.
Link copied to clipboard
public static Point copyPoint(Point point)
Copies a Point, but with a different reference location in the memory.
Link copied to clipboard
public static Vector copyVector(Vector vector)
Copies a Vector, but with a different reference location in the memory.
Link copied to clipboard
public static double crossProduct(Vector one, Vector two)
This computes the first Vector crossed with the second Vector, so a cross product.
Link copied to clipboard
public static double distance(Pose one, Pose two)
This returns the distance between a Pose and another Pose.
public static double distance(Pose pose, Point point)
This returns the distance between a Pose and a Point,
Link copied to clipboard
public static double dotProduct(Vector one, Vector two)
This computes the dot product of the two Vectors.
Link copied to clipboard
public static double getSign(double get)
This returns the sign (positive/negative) of a number.
Link copied to clipboard
public static double getSmallestAngleDifference(double one, double two)
This returns the smallest angle between two angles.
Link copied to clipboard
public static double getTurnDirection(double startHeading, double endHeading)
This gets the direction to turn between a start heading and an end heading.
Link copied to clipboard
public Pose globalCoordinates(Pose currentPose)
Link copied to clipboard
public static double nCr(int n, int r)
This is a simple implementation of the choose function in math.
Link copied to clipboard
public static double normalizeAngle(double angleRadians)
This normalizes an angle to be between 0 and 2 pi radians, inclusive.
Link copied to clipboard
public static Vector normalizeVector(Vector vector)
This normalizes a Vector to be of magnitude 1, unless the Vector is the zero Vector.
Link copied to clipboard
public Pose pedroCoordinates(Pose currentPose)
Link copied to clipboard
public static Pose rotatePose(Pose pose, double theta, boolean rotateHeading)
This rotates the given pose by the given theta,
Link copied to clipboard
public static boolean roughlyEquals(double one, double two)
This returns whether a specified number is within a second specified number by plus/minus 0.0001.
public static boolean roughlyEquals(double one, double two, double accuracy)
This returns whether a specified value is within a second specified value by plus/minus a specified accuracy amount.
Link copied to clipboard
public static Point scalarMultiplyPoint(Point point, double scalar)
This multiplies a Point by a scalar and returns the result as a Point
Link copied to clipboard
public static Vector scalarMultiplyVector(Vector vector, double scalar)
This multiplies a Vector by a scalar and returns the result as a Vector.
Link copied to clipboard
public static Point subtractPoints(Point one, Point two)
This subtracts the second Point from the first Point and returns the result as a Point.
Link copied to clipboard
public static Pose subtractPoses(Pose one, Pose two)
This subtracts the second Pose from the first Pose and returns the result as a Pose.
Link copied to clipboard
public static Vector subtractVectors(Vector one, Vector two)
This subtracts the second Vector from the first Vector and returns the result as a Vector.