Package net.commoble.exmachina.internal.mechanical

# Record Class MechanicalGraph.GearRatio

java.lang.Object
java.lang.Record
net.commoble.exmachina.internal.mechanical.MechanicalGraph.GearRatio

Record Components:
  `ratio` - Fraction (simplified) of a gearshift representing relative teeth counts (e.g. 2/1)
  `inverseRatio` - Fraction of the teeth counts, inverted (e.g. 1/2)
  `gearMultiplier` - double value of the ratio
  `squareMultiplier` - double value of ratio*ratio
  `gearDivisor` - double value of inverseRatio
  `squareDivisor` - double value of inverseRatio * inverseRatio

Enclosing class:
  `MechanicalGraph`

public static record MechanicalGraph.GearRatio(org.apache.commons.lang3.math.Fraction ratio, org.apache.commons.lang3.math.Fraction inverseRatio, double gearMultiplier, double squareMultiplier, double gearDivisor, double squareDivisor) extends Record
Cached values for a gear fraction

## Field Summary

Fields
Modifier and Type
Field
Description
`static final MechanicalGraph.GearRatio`
`ZERO`

## Constructor Summary

Constructors
Constructor
Description
`GearRatio(org.apache.commons.lang3.math.Fraction ratio, org.apache.commons.lang3.math.Fraction inverseRatio, double gearMultiplier, double squareMultiplier, double gearDivisor, double squareDivisor)`
Creates an instance of a `GearRatio` record class.

## Method Summary

Modifier and Type
Method
Description
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`double`
`gearDivisor()`
Returns the value of the `gearDivisor` record component.
`double`
`gearMultiplier()`
Returns the value of the `gearMultiplier` record component.
`final int`
`hashCode()`
Returns a hash code value for this object.
`org.apache.commons.lang3.math.Fraction`
`inverseRatio()`
Returns the value of the `inverseRatio` record component.
`boolean`
`isValid()`
Returns if false, gear ratio is non-positive and the graph should be zeroed.
`static MechanicalGraph.GearRatio`
`of(org.apache.commons.lang3.math.Fraction ratio)`
Returns GearRatio using the given fraction, or the ZERO ratio if fraction is zero or too big to square.
`org.apache.commons.lang3.math.Fraction`
`ratio()`
Returns the value of the `ratio` record component.
`double`
`squareDivisor()`
Returns the value of the `squareDivisor` record component.
`double`
`squareMultiplier()`
Returns the value of the `squareMultiplier` record component.
`final String`
`toString()`
Returns a string representation of this record class.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### ZERO

public static final MechanicalGraph.GearRatio ZERO

## Constructor Details

### GearRatio

public GearRatio(org.apache.commons.lang3.math.Fraction ratio, org.apache.commons.lang3.math.Fraction inverseRatio, double gearMultiplier, double squareMultiplier, double gearDivisor, double squareDivisor)
Creates an instance of a `GearRatio` record class.

Parameters:
  `ratio` - the value for the `ratio` record component
  `inverseRatio` - the value for the `inverseRatio` record component
  `gearMultiplier` - the value for the `gearMultiplier` record component
  `squareMultiplier` - the value for the `squareMultiplier` record component
  `gearDivisor` - the value for the `gearDivisor` record component
  `squareDivisor` - the value for the `squareDivisor` record component

## Method Details

### of

public static MechanicalGraph.GearRatio of(org.apache.commons.lang3.math.Fraction ratio)
Returns GearRatio using the given fraction, or the ZERO ratio if fraction is zero or too big to square.

Parameters:
  `ratio` - Fraction of teeth counts
Returns:
  GearRatio using the given fraction, or the ZERO ratio if fraction is zero or too big to square

### isValid

public boolean isValid()
Returns if false, gear ratio is non-positive and the graph should be zeroed.

Returns:
  if false, gear ratio is non-positive and the graph should be zeroed

### toString

public final String toString()
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.

Specified by:
  `toString` in class `Record`
Returns:
  a string representation of this object

### hashCode

public final int hashCode()
Returns a hash code value for this object. The value is derived from the hash code of each of the record components.

Specified by:
  `hashCode` in class `Record`
Returns:
  a hash code value for this object

### equals

public final boolean equals(Object o)
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with `Objects::equals(Object,Object)`; primitive components are compared with '=='.

Specified by:
  `equals` in class `Record`
Parameters:
  `o` - the object with which to compare
Returns:
  `true` if this object is the same as the `o` argument; `false` otherwise.

### ratio

public org.apache.commons.lang3.math.Fraction ratio()
Returns the value of the `ratio` record component.

Returns:
  the value of the `ratio` record component

### inverseRatio

public org.apache.commons.lang3.math.Fraction inverseRatio()
Returns the value of the `inverseRatio` record component.

Returns:
  the value of the `inverseRatio` record component

### gearMultiplier

public double gearMultiplier()
Returns the value of the `gearMultiplier` record component.

Returns:
  the value of the `gearMultiplier` record component

### squareMultiplier

public double squareMultiplier()
Returns the value of the `squareMultiplier` record component.

Returns:
  the value of the `squareMultiplier` record component

### gearDivisor

public double gearDivisor()
Returns the value of the `gearDivisor` record component.

Returns:
  the value of the `gearDivisor` record component

### squareDivisor

public double squareDivisor()
Returns the value of the `squareDivisor` record component.

Returns:
  the value of the `squareDivisor` record component