RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.units.PerUnit< N extends Unit, D extends Unit > Class Template Reference
Inheritance diagram for org.wpilib.units.PerUnit< N extends Unit, D extends Unit >:
org.wpilib.units.Unit

Public Member Functions

PerUnit< N, D > getBaseUnit ()
N numerator ()
D denominator ()
PerUnit< D, N > reciprocal ()
N mult (D denom)
Measure<? extends PerUnit< N, D > > of (double magnitude)
Measure<? extends PerUnit< N, D > > ofBaseUnits (double baseUnitMagnitude)
final Per< N, D > ofNative (double magnitude)
final Per< N, D > ofNativeBaseUnits (double baseUnitMagnitude)
Measure<? extends PerUnit< N, D > > zero ()
Measure<? extends PerUnit< N, D > > one ()
Unit per (TimeUnit time)
double convertFrom (double magnitude, PerUnit<? extends N, ? extends D > otherUnit)
boolean equals (Object o)
int hashCode ()
Public Member Functions inherited from org.wpilib.units.Unit
boolean isBaseUnit ()
double fromBaseUnits (double valueInBaseUnits)
double toBaseUnits (double valueInNativeUnits)
UnaryFunction getConverterToBase ()
UnaryFunction getConverterFromBase ()
boolean equivalent (Unit other)
String name ()
String symbol ()
String toString ()

Static Public Member Functions

static< N extends Unit, D extends Unit > PerUnit< N, D > combine (N numerator, D denominator)

Protected Member Functions

 PerUnit (PerUnit< N, D > baseUnit, N numerator, D denominator)
Protected Member Functions inherited from org.wpilib.units.Unit
 Unit (Unit baseUnit, UnaryFunction toBaseConverter, UnaryFunction fromBaseConverter, String name, String symbol)
 Unit (Unit baseUnit, double baseUnitEquivalent, String name, String symbol)

Detailed Description

Generic combinatory unit type that represents the proportion of one unit to another, such as Meters per Second or Radians per Celsius.

Parameters
<N>the type of the numerator unit
<D>the type of the denominator unit

Definition at line 17 of file PerUnit.java.

Constructor & Destructor Documentation

◆ PerUnit()

org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.PerUnit ( PerUnit< N, D > baseUnit,
N numerator,
D denominator )
protected

Creates a new proportional unit derived from the ratio of one unit to another. Subclasses of PerUnit should use this constructor.

Parameters
baseUnitthe base unit. Set this to null if the unit being constructed is its own base unit
numeratorthe numerator unit
denominatorthe denominator unit

Definition at line 57 of file PerUnit.java.

Member Function Documentation

◆ combine()

static< N extends Unit, D extends Unit > PerUnit< N, D > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.combine ( N numerator,
D denominator )
static

Creates a new PerUnit unit derived from an arbitrary numerator and time denominator units.

  PerUnit.combine(Volts, Meters) // possible PID constant
Parameters
<N>the type of the numerator unit
<D>the type of the denominator unit
numeratorthe numerator unit
denominatorthe denominator for unit time
Returns
the combined unit

Definition at line 93 of file PerUnit.java.

◆ convertFrom()

double org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.convertFrom ( double magnitude,
PerUnit<? extends N, ? extends D > otherUnit )

Converts a measurement value in terms of another unit to this unit.

Parameters
magnitudethe magnitude of the measurement in terms of the other unit
otherUnitthe other unit
Returns
the value of the measurement in terms of this unit

Definition at line 234 of file PerUnit.java.

◆ denominator()

D org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.denominator ( )

Gets the denominator unit. For a PerUnit<A, B>, this will return the B unit.

Returns
the denominator unit

Definition at line 117 of file PerUnit.java.

◆ equals()

boolean org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.equals ( Object o)

Reimplemented from org.wpilib.units.Unit.

Definition at line 239 of file PerUnit.java.

◆ getBaseUnit()

PerUnit< N, D > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.getBaseUnit ( )

Gets the base unit of measurement that this unit is derived from. If the unit is the base unit, the unit will be returned.

NOTE: Subclasses must override this method to provide the correct return type. Failing to do say will make unit combinations that use it break at runtime!


  Unit baseUnit = new Unit(null, ...);
  baseUnit.getBaseUnit(); // returns baseUnit

  Unit derivedUnit = new Unit(baseUnit, ...);
  derivedUnit.getBaseUnit(); // returns baseUnit
Returns
the base unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 99 of file PerUnit.java.

◆ hashCode()

int org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.hashCode ( )

Reimplemented from org.wpilib.units.Unit.

Definition at line 255 of file PerUnit.java.

◆ mult()

N org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.mult ( D denom)

Multiplies this unit by a unit of its denominator.

Parameters
denomthe denominator-typed unit to multiply by
Returns
the result

Definition at line 143 of file PerUnit.java.

◆ numerator()

N org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.numerator ( )

Gets the numerator unit. For a PerUnit<A, B>, this will return the A unit.

Returns
the numerator unit

Definition at line 108 of file PerUnit.java.

◆ of()

Measure<? extends PerUnit< N, D > > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.of ( double magnitude)

Creates a new immutable measurement of the given magnitude in terms of this unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation.

Parameters
magnitudethe magnitude of the measurement.
Returns
the measurement object

Note: When called on an object of type PerUnit (and not a subclass!), this method will always return a org.wpilib.units.measure.Per instance. If you want to avoid casting, use ofNative(double) that returns a Per instance directly.

Parameters
magnitudethe magnitude of the measure
Returns
the ratio measure

Reimplemented from org.wpilib.units.Unit.

Definition at line 167 of file PerUnit.java.

◆ ofBaseUnits()

Measure<? extends PerUnit< N, D > > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.ofBaseUnits ( double baseUnitMagnitude)

Creates a new immutable measurement of the given magnitude in terms of this unit's base unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation.

Parameters
baseUnitMagnitudethe magnitude in terms of the base unit
Returns
the measurement object

Note: When called on an object of type PerUnit (and not a subclass!), this method will always return a org.wpilib.units.measure.Per instance. If you want to avoid casting, use ofNativeBaseUnits(double) that returns a Per instance directly.

Parameters
baseUnitMagnitudethe magnitude of the measure in terms of its base units.
Returns
the ratio measure

Reimplemented from org.wpilib.units.Unit.

Definition at line 182 of file PerUnit.java.

◆ ofNative()

final Per< N, D > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.ofNative ( double magnitude)

Creates a new immutable measurement of the given magnitude in terms of the ratio unit. This will always return a Per object and cannot be overridden by subclasses.

Parameters
magnitudethe magnitude of the measurement.
Returns
the measurement object
See also
of(double)

Definition at line 194 of file PerUnit.java.

◆ ofNativeBaseUnits()

final Per< N, D > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.ofNativeBaseUnits ( double baseUnitMagnitude)

Creates a new immutable measurement of the given magnitude in terms of the ratio unit's base unit. This will always return a Per object and cannot be overridden by subclasses.

Parameters
baseUnitMagnitudethe magnitude of the measure in terms of its base units.
Returns
the measurement object
See also
ofBaseUnits(double)

Definition at line 206 of file PerUnit.java.

◆ one()

Measure<? extends PerUnit< N, D > > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.one ( )

Gets a measure with a magnitude of 1.0 in terms of this unit. The returned object is guaranteed to be of the same type returned by of(double). Subclasses are encouraged to override this method to sharpen the return type.

Returns
a measure of magnitude 1.0 in terms of this unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 218 of file PerUnit.java.

◆ per()

Unit org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.per ( TimeUnit time)

Combines this unit with a unit of time. This often - but not always - results in a velocity. Subclasses should sharpen the return type to be unit-specific.

Parameters
timethe unit of time
Returns
the combined unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 223 of file PerUnit.java.

◆ reciprocal()

PerUnit< D, N > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.reciprocal ( )

Returns the reciprocal of this PerUnit.

Returns
the reciprocal

Definition at line 127 of file PerUnit.java.

◆ zero()

Measure<? extends PerUnit< N, D > > org.wpilib.units.PerUnit< N extends Unit, D extends Unit >.zero ( )

Gets a measure of zero magnitude in terms of this unit. The returned object is guaranteed to be of the same type returned by of(double). Subclasses are encouraged to override this method to sharpen the return type.

Returns
a zero-magnitude measure of this unit

Reimplemented from org.wpilib.units.Unit.

Definition at line 212 of file PerUnit.java.


The documentation for this class was generated from the following file: