Package me.wobblyyyy.pathfinder.math
Class GearRatio
java.lang.Object
me.wobblyyyy.pathfinder.math.GearRatio
public class GearRatio
extends java.lang.Object
A virtual representation of an input/output gear ratio. A specified amount
of input rotation corresponds to a specified amount of output rotation.
The intention of the gear ratio class is to make it easier to figure out
gear ratios - putting in a double can be somewhat hard to interpret at
times.
- Since:
- 0.3.0
- Author:
- Colin Robertson
-
Field Summary
Fields Modifier and Type Field Description private doubleinputRotationsThe input component of the ratio.private doubleinputToOutputThe ratio of inputs to outputs.private doubleoutputRotationsThe output component of the ratio.private doubleoutputToInputThe ratio of outputs to inputs. -
Constructor Summary
Constructors Constructor Description GearRatio(double inputRotations, double outputRotations)Create a newGearRatioby providing both input and output values. -
Method Summary
Modifier and Type Method Description doublegetInputRotations()Get the input rotations component of the ratio.doublegetInputToOutputRatio()Get the ratio between input and output rotations.doublegetOutputRotations()Get the output rotations component of the ratio.doublegetOutputToInputRatio()Get the ratio between output and input rotations.doublehowManyIn(double output)How many input rotations is the specified output rotation worth? If you have a gear ratio of 2:1, and you fed this method 1, this method would return the following value: 2.doublehowManyOut(double input)How many output rotations is the specified input rotation worth? If you have a gear ratio of 2:1, and you fed this method 1, this method would return the following value: 0.5.static GearRatiooneInputEquals(double oneOutput)Create a newGearRatiowhere one input rotation equals the specified number of output rotations.static GearRatiooneOutputEquals(double oneInput)Create a newGearRatiowhere one output rotation equals the specified number of input rotations.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
inputRotations
private final double inputRotationsThe input component of the ratio. -
outputRotations
private final double outputRotationsThe output component of the ratio. -
inputToOutput
private final double inputToOutputThe ratio of inputs to outputs. 1 input = ? output. -
outputToInput
private final double outputToInputThe ratio of outputs to inputs. 1 output = ? input.
-
-
Constructor Details
-
GearRatio
public GearRatio(double inputRotations, double outputRotations)Create a newGearRatioby providing both input and output values. If, say, you have a 2:1 gear ratio, you can call this constructor and pass those parameters in that order.- Parameters:
inputRotations- the amount of input rotations that corresponds to however many output rotations.outputRotations- the amount of output rotations that corresponds to however many input rotations.- See Also:
oneInputEquals(double),oneOutputEquals(double)
-
-
Method Details
-
oneInputEquals
Create a newGearRatiowhere one input rotation equals the specified number of output rotations.- Parameters:
oneOutput- how much each input rotation should turn the output rotation value by.- Returns:
- a shiny new
GearRatio.
-
oneOutputEquals
Create a newGearRatiowhere one output rotation equals the specified number of input rotations.- Parameters:
oneInput- how much each output rotation should turn the input rotation value by.- Returns:
- a shiny new
GearRatio.
-
getInputRotations
public double getInputRotations()Get the input rotations component of the ratio. THIS IS NOT A RATIO! This is just how many input rotations equal however many output rotations - nothing more, nothing less.- Returns:
- the input component of the gear ratio.
-
getOutputRotations
public double getOutputRotations()Get the output rotations component of the ratio. THIS IS NOT A RATIO! This is just how many output rotations equal however many input rotations - nothing more, nothing less.- Returns:
- the output component of the gear ratio.
-
getInputToOutputRatio
public double getInputToOutputRatio()Get the ratio between input and output rotations. This ratio can best be expressed as output divided by input.- Returns:
- the ratio of input rotations to output rotations.
-
getOutputToInputRatio
public double getOutputToInputRatio()Get the ratio between output and input rotations. This ratio can best be expressed as input divided by output.- Returns:
- the ratio of output rotations to input rotations.
-
howManyOut
public double howManyOut(double input)How many output rotations is the specified input rotation worth? If you have a gear ratio of 2:1, and you fed this method 1, this method would return the following value: 0.5.- Parameters:
input- the amount of rotations to calculate for.- Returns:
- the calculated amount of output rotations.
-
howManyIn
public double howManyIn(double output)How many input rotations is the specified output rotation worth? If you have a gear ratio of 2:1, and you fed this method 1, this method would return the following value: 2.- Parameters:
output- the amount of rotations to calculate for.- Returns:
- the calculated amount of output rotations.
-