Class GearBox

java.lang.Object
yams.core.gearing.GearBox

public class GearBox extends Object
GearBox class to calculate input and output conversion factors and check if the current configuration is supported.

A GearBox models a multi-stage gear reduction (or increase). Each stage is defined by a reduction, such as 5.0 or "5:1" for a 5:1 reduction. The overall reduction is the product of all individual stage reductions.

You can construct a GearBox in several ways:

  • fromTeeth(int...) provide the tooth counts of a train of meshing gears, from the driving gear to the last driven gear. Gears in between are idlers.
  • fromStages(String...) provide stage reductions as "IN:OUT" strings
  • fromReductionStages(double...) provide per-stage reductions directly

Example

// 5:1 single-stage gearbox (12-tooth driver meshing with a 60-tooth driven gear)
GearBox fiveToOne = GearBox.fromTeeth(12, 60);

// Still 5:1: every gear meshes with the next one, so the 30-tooth gear is an idler
GearBox withIdler = GearBox.fromTeeth(12, 30, 60);

// 25:1 two-stage gearbox (each stage is 5:1) using "IN:OUT" stage strings
GearBox twoStage = GearBox.fromStages("5:1", "5:1");

// Equivalent using reductions (driven teeth / driver teeth per stage)
GearBox fromRatios = GearBox.fromReductionStages(60.0 / 12.0, 60.0 / 12.0);

// Get the overall input-to-output conversion factor (< 1.0 means reduction)
double factor = fiveToOne.getInputToOutputConversionFactor(); // 0.2  (1/5)
// Get the overall output-to-input conversion factor (the reduction ratio itself)
double reduction = fiveToOne.getOutputToInputConversionFactor(); // 5.0
  • Constructor Details

    • GearBox

      public GearBox(double[] reductionStage)
      Construct the GearBox with the reduction stages given.
      Parameters:
      reductionStage - Reduction stages where the number is > 0 to indicate a reduction.
      Throws:
      NoStagesGivenException - if reductionStage is empty.
    • GearBox

      public GearBox(String[] reductionStage)
      Construct the GearBox with the reduction stages given.
      Parameters:
      reductionStage - List of stages in the format of "IN:OUT".
      Throws:
      InvalidStageGivenException - if any stage string does not contain a ':' separator.
      NoStagesGivenException - if reductionStage is empty.
  • Method Details

    • fromReductionStages

      public static GearBox fromReductionStages(double... reductionStages)
      Create the gearbox given the reduction stages of the gearbox.
      Parameters:
      reductionStages - Reduction stages where the number is > 0 to indicate a reduction.
      Returns:
      GearBox.
      Throws:
      NoStagesGivenException - if no reduction stages are given.
    • fromStages

      public static GearBox fromStages(String... stages)
      Create the gearbox given the reduction stages of the gearbox.
      Parameters:
      stages - Stages in the format of "IN:OUT". For example, "3:1"
      Returns:
      GearBox
      Throws:
      InvalidStageGivenException - if any stage string does not contain a ':' separator.
      NoStagesGivenException - if no stages are given.
    • fromTeeth

      public static GearBox fromTeeth(int... teeth)
      Create the gearbox given the teeth of each gear in a train of meshing gears. Every gear meshes with the next one, so the reduction is the last tooth count divided by the first and the gears in between are idlers. For compound stages, where two gears share a shaft, use fromReductionStages(double...) or fromStages(String...) instead.
      Parameters:
      teeth - Gear teeth from the driving gear to the last driven gear.
      Returns:
      GearBox
      Throws:
      IllegalArgumentException - if teeth is null.
      IllegalArgumentException - if teeth has fewer than two entries.
      IllegalArgumentException - if any tooth count is zero or negative.
    • times

      public GearBox times(double x)
      Multiply the gear reduction ratio by X.
      Parameters:
      x - X to multiply by.
      Returns:
      GearBox for chaining.
    • div

      public GearBox div(double x)
      Divide the gear reduction ratio by X.
      Parameters:
      x - X to divide by.
      Returns:
      GearBox for chaining.
    • getInputToOutputConversionFactor

      public double getInputToOutputConversionFactor()
      Get the conversion factor to transform the gearbox input into the gear box output rotations.
      Returns:
      OUT/IN or OUT:IN
    • getOutputToInputConversionFactor

      public double getOutputToInputConversionFactor()
      Get the conversion factor to transform the gearbox output value into the gear box input value.
      Returns:
      IN:OUT or IN/OUT