Class FloatScalarRel<U extends Unit<U>,R extends FloatScalarRel<U,R>>

Type Parameters:
U - the unit
R - the Relative class for reference purposes
All Implemented Interfaces:
Serializable, Cloneable, Comparable<R>, Relative<U,R>, Value<U,R>
Direct Known Subclasses:
FloatAbsorbedDose, FloatAcceleration, FloatAmountOfSubstance, FloatAngularAcceleration, FloatAngularVelocity, FloatArea, FloatCatalyticActivity, FloatDensity, FloatDimensionless, FloatElectricalCapacitance, FloatElectricalCharge, FloatElectricalConductance, FloatElectricalCurrent, FloatElectricalInductance, FloatElectricalPotential, FloatElectricalResistance, FloatEnergy, FloatEquivalentDose, FloatFlowMass, FloatFlowVolume, FloatForce, FloatFrequency, FloatIlluminance, FloatLinearDensity, FloatLuminousFlux, FloatLuminousIntensity, FloatMagneticFlux, FloatMagneticFluxDensity, FloatMass, FloatMomentum, FloatPower, FloatPressure, FloatRadioActivity, FloatScalarRelWithAbs, FloatSIScalar, FloatSolidAngle, FloatSpeed, FloatTorque, FloatVolume

public abstract class FloatScalarRel<U extends Unit<U>,R extends FloatScalarRel<U,R>> extends FloatScalar<U,R> implements Relative<U,R>
The typed, abstract FloatScalarRel class that forms the basis of all FloatScalar definitions and extensions.
Note: A relative scalar class can implement the toAbs() method if it has an absolute equivalent.

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Author:
Alexander Verbraeck, Peter Knoppers
See Also:
  • Constructor Details

    • FloatScalarRel

      public FloatScalarRel(float value, U unit)
      Construct a new Relative Immutable FloatScalar.
      Parameters:
      value - float; the value of the new Relative Immutable FloatScalar
      unit - U; the unit of the new Relative Immutable FloatScalar
    • FloatScalarRel

      public FloatScalarRel(R value)
      Construct a new Relative Immutable FloatScalar from an existing Relative Immutable FloatScalar.
      Parameters:
      value - R, a relative typed FloatScalar; the reference
  • Method Details

    • instantiateRel

      public abstract R instantiateRel(float value, U unit)
      Construct a new Relative Immutable FloatScalar of the right type. Each extending class must implement this method.
      Parameters:
      value - float; the float value
      unit - U; the unit
      Returns:
      R a new relative instance of the FloatScalar of the right type
    • plus

      public final R plus(R increment)
      Add a Relative value to this Relative value. A new value is returned due to immutability.
      Specified by:
      plus in interface Relative<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Parameters:
      increment - R; the value to add
      Returns:
      R; the sum of this value and the operand as a new object
    • minus

      public final R minus(R decrement)
      Subtract a Relative value from this Relative value. A new value is returned due to immutability.
      Specified by:
      minus in interface Relative<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Parameters:
      decrement - R; the value to subtract
      Returns:
      R; the difference of this value and the operand
    • times

      public FloatSIScalar times(FloatScalarRel<?,?> otherScalar)
      Multiply this scalar by another scalar and create a new scalar.
      Parameters:
      otherScalar - FloatScalarRel<?, ?>; the value by which this scalar is multiplied
      Returns:
      FloatScalar<?>; a new scalar instance with correct SI dimensions
    • reciprocal

      public abstract FloatScalarRel<?,?> reciprocal()
      Create the reciprocal of this scalar with the correct dimensions.
      Returns:
      FloatScalar<?>; a new scalar instance with correct SI dimensions
    • divide

      public FloatSIScalar divide(FloatScalarRel<?,?> otherScalar)
      Divide this scalar by another scalar and create a new scalar.
      Parameters:
      otherScalar - FloatScalarRel<?, ?>; the value by which this scalar is divided
      Returns:
      FloatScalar<?>; a new scalar instance with correct SI dimensions
    • abs

      public R abs()
      Return a new Scalar/Vector/Matrix with absolute value(s).
      Specified by:
      abs in interface Value<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Returns:
      R; a new R with absolute value(s)
    • ceil

      public R ceil()
      Return a new Scalar/Vector/Matrix with the nearest integer value(s) above the current value(s).
      Specified by:
      ceil in interface Value<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Returns:
      R; a new R with absolute value(s)
    • floor

      public R floor()
      Return a new Scalar/Vector/Matrix with the nearest integer value(s) below the current value(s).
      Specified by:
      floor in interface Value<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Returns:
      R; a new R with absolute value(s)
    • rint

      public R rint()
      Return a new Scalar/Vector/Matrix with the nearest integer value(s). When the value is exactly in the middle between two integer values, the even one is returned.
      Specified by:
      rint in interface Value<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Returns:
      R; a new R with absolute value(s)
    • neg

      public R neg()
      Return a new Scalar/Vector/Matrix with negated value(s).
      Specified by:
      neg in interface Value<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Returns:
      R; a new R with negated value(s)
    • times

      public R times(double constant)
      Returns a new scalar/vector/matrix with value(s) multiplied by a factor.
      Specified by:
      times in interface Relative<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Parameters:
      constant - double; the multiplier
      Returns:
      T; a new scalar/vector/matrix
    • divide

      public R divide(double constant)
      Returns a new scalar/vector/matrix with value(s) divided by a factor.
      Specified by:
      divide in interface Relative<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Parameters:
      constant - double; the divisor
      Returns:
      T; the modified T
    • times

      public R times(float constant)
      Returns a new scalar/vector/matrix with value(s) multiplied by a factor.
      Specified by:
      times in interface Relative<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Parameters:
      constant - float; the multiplier
      Returns:
      T; a new scalar/vector/matrix
    • divide

      public R divide(float constant)
      Returns a new scalar/vector/matrix with value(s) divided by a factor.
      Specified by:
      divide in interface Relative<U extends Unit<U>,R extends FloatScalarRel<U,R>>
      Parameters:
      constant - float; the divisor
      Returns:
      T; the modified T