Unit.java

  1. /* Copyright 2002-2024 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.utils.units;

  18. import java.io.Serializable;
  19. import java.util.List;

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.fraction.Fraction;
  22. import org.hipparchus.util.FastMath;
  23. import org.hipparchus.util.Precision;
  24. import org.orekit.errors.OrekitException;
  25. import org.orekit.errors.OrekitMessages;

  26. /** Basic handling of multiplicative units.
  27.  * <p>
  28.  * This class is by no means a complete handling of units. For complete
  29.  * support, look at libraries like {@code UOM}. This class handles only
  30.  * time, length, mass and current dimensions, as well as angles (which are
  31.  * dimensionless).
  32.  * </p>
  33.  * <p>
  34.  * Instances of this class are immutable.
  35.  * </p>
  36.  * @see <a href="https://github.com/netomi/uom">UOM</a>
  37.  * @author Luc Maisonobe
  38.  * @since 11.0
  39.  */
  40. public class Unit implements Serializable {

  41.     /** No unit. */
  42.     public static final Unit NONE = new Unit("n/a", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

  43.     /** Dimensionless unit. */
  44.     public static final Unit ONE = new Unit("1", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

  45.     /** Percentage unit. */
  46.     public static final Unit PERCENT = new Unit("%", 1.0e-2, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

  47.     /** Second unit. */
  48.     public static final Unit SECOND = new Unit("s", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO, Fraction.ZERO);

  49.     /** Minute unit. */
  50.     public static final Unit MINUTE = SECOND.scale("min", 60.0);

  51.     /** Hour unit. */
  52.     public static final Unit HOUR = MINUTE.scale("h", 60);

  53.     /** Day unit. */
  54.     public static final Unit DAY = HOUR.scale("d", 24.0);

  55.     /** Julian year unit.
  56.      * @see <a href="https://www.iau.org/publications/proceedings_rules/units/">SI Units at IAU</a>
  57.      */
  58.     public static final Unit YEAR = DAY.scale("a", 365.25);

  59.     /** Hertz unit. */
  60.     public static final Unit HERTZ = SECOND.power("Hz", Fraction.MINUS_ONE);

  61.     /** Metre unit. */
  62.     public static final Unit METRE = new Unit("m", 1.0, Fraction.ZERO, Fraction.ONE, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

  63.     /** Kilometre unit. */
  64.     public static final Unit KILOMETRE = METRE.scale("km", 1000.0);

  65.     /** Kilogram unit. */
  66.     public static final Unit KILOGRAM = new Unit("kg", 1.0, Fraction.ONE, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

  67.     /** Gram unit. */
  68.     public static final Unit GRAM = KILOGRAM.scale("g", 1.0e-3);

  69.     /** Ampere unit. */
  70.     public static final Unit AMPERE = new Unit("A", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO);

  71.     /** Radian unit. */
  72.     public static final Unit RADIAN = new Unit("rad", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE);

  73.     /** Degree unit. */
  74.     public static final Unit DEGREE = RADIAN.scale("°", FastMath.toRadians(1.0));

  75.     /** Arc minute unit. */
  76.     public static final Unit ARC_MINUTE = DEGREE.scale("′", 1.0 / 60.0);

  77.     /** Arc second unit. */
  78.     public static final Unit ARC_SECOND = ARC_MINUTE.scale("″", 1.0 / 60.0);

  79.     /** Revolution unit. */
  80.     public static final Unit REVOLUTION = RADIAN.scale("rev", 2.0 * FastMath.PI);

  81.     /** Newton unit. */
  82.     public static final Unit NEWTON = KILOGRAM.multiply(null, METRE).divide("N", SECOND.power(null, Fraction.TWO));

  83.     /** Pascal unit. */
  84.     public static final Unit PASCAL = NEWTON.divide("Pa", METRE.power(null, Fraction.TWO));

  85.     /** Bar unit. */
  86.     public static final Unit BAR = PASCAL.scale("bar", 100000.0);

  87.     /** Joule unit. */
  88.     public static final Unit JOULE = NEWTON.multiply("J", METRE);

  89.     /** Watt unit. */
  90.     public static final Unit WATT = JOULE.divide("W", SECOND);

  91.     /** Coulomb unit. */
  92.     public static final Unit COULOMB = SECOND.multiply("C", AMPERE);

  93.     /** Volt unit. */
  94.     public static final Unit VOLT = WATT.divide("V", AMPERE);

  95.     /** Ohm unit. */
  96.     public static final Unit OHM = VOLT.divide("Ω", AMPERE);

  97.     /** tesla unit. */
  98.     public static final Unit TESLA = VOLT.multiply(null, SECOND).divide("T", METRE.power(null, Fraction.TWO));

  99.     /** Solar Flux Unit. */
  100.     public static final Unit SOLAR_FLUX_UNIT = WATT.divide(null, METRE.power(null, Fraction.TWO).multiply(null, HERTZ)).scale("SFU", 1.0e-22);

  101.     /** Total Electron Content Unit. */
  102.     public static final Unit TOTAL_ELECTRON_CONTENT_UNIT = METRE.power(null, new Fraction(-2)).scale("TECU", 1.0e+16);

  103.     /** Earth Radii used as Bstar unit in CCSDS OMM. */
  104.     public static final Unit EARTH_RADII = new Unit("ER", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO);

  105.     /** Serializable UID. */
  106.     private static final long serialVersionUID = 20210402L;

  107.     /** Name name of the unit. */
  108.     private final String name;

  109.     /** Scaling factor to SI units. */
  110.     private final double scale;

  111.     /** Mass exponent. */
  112.     private final Fraction mass;

  113.     /** Length exponent. */
  114.     private final Fraction length;

  115.     /** Time exponent. */
  116.     private final Fraction time;

  117.     /** Current exponent. */
  118.     private final Fraction current;

  119.     /** Angle exponent. */
  120.     private final Fraction angle;

  121.     /** Simple constructor.
  122.      * @param name name of the unit
  123.      * @param scale scaling factor to SI units
  124.      * @param mass mass exponent
  125.      * @param length length exponent
  126.      * @param time time exponent
  127.      * @param current current exponent
  128.      * @param angle angle exponent
  129.      */
  130.     public Unit(final String name, final double scale,
  131.                 final Fraction mass, final Fraction length,
  132.                 final Fraction time, final Fraction current,
  133.                 final Fraction angle) {
  134.         this.name    = name;
  135.         this.scale   = scale;
  136.         this.mass    = mass;
  137.         this.length  = length;
  138.         this.time    = time;
  139.         this.current = current;
  140.         this.angle   = angle;
  141.     }

  142.     /** Get the name of the unit.
  143.      * @return name of the unit
  144.      */
  145.     public String getName() {
  146.         return name;
  147.     }

  148.     /** Get the scaling factor to SI units.
  149.      * @return scaling factor to SI units
  150.      */
  151.     public double getScale() {
  152.         return scale;
  153.     }

  154.     /** Get the mass exponent.
  155.      * @return mass exponent
  156.      */
  157.     public Fraction getMass() {
  158.         return mass;
  159.     }

  160.     /** Get the length exponent.
  161.      * @return length exponent
  162.      */
  163.     public Fraction getLength() {
  164.         return length;
  165.     }

  166.     /** Get the time exponent.
  167.      * @return time exponent
  168.      */
  169.     public Fraction getTime() {
  170.         return time;
  171.     }

  172.     /** Get the current exponent.
  173.      * @return current exponent
  174.      */
  175.     public Fraction getCurrent() {
  176.         return current;
  177.     }

  178.     /** Get the angle exponent.
  179.      * @return angle exponent
  180.      */
  181.     public Fraction getAngle() {
  182.         return angle;
  183.     }

  184.     /** Check if a unit has the same dimension as another unit.
  185.      * @param other other unit to check against
  186.      * @return true if unit has the same dimension as the other unit
  187.      */
  188.     public boolean sameDimension(final Unit other) {
  189.         return time.equals(other.time) && length.equals(other.length)   &&
  190.                mass.equals(other.mass) && current.equals(other.current) &&
  191.                angle.equals(other.angle);
  192.     }

  193.     /** Create the SI unit with same dimension.
  194.      * @return a new unit, with same dimension as instance and scaling factor set to 1.0
  195.      */
  196.     public Unit sameDimensionSI() {
  197.         final StringBuilder builder = new StringBuilder();
  198.         append(builder, KILOGRAM.name, mass);
  199.         append(builder, METRE.name,    length);
  200.         append(builder, SECOND.name,   time);
  201.         append(builder, AMPERE.name,   current);
  202.         append(builder, RADIAN.name,   angle);
  203.         if (builder.length() == 0) {
  204.             builder.append('1');
  205.         }
  206.         return new Unit(builder.toString(), 1.0, mass, length, time, current, angle);
  207.     }

  208.     /** Ensure some units are compatible with reference units.
  209.      * @param description description of the units list (for error message generation)
  210.      * @param reference reference units
  211.      * @param units units to check
  212.      * @param allowScaleDifferences if true, unit with same dimension but different
  213.      * scale (like {@link #KILOMETRE} versus {@link #METRE}) are allowed, otherwise they will trigger an exception
  214.      * @exception OrekitException if units are not compatible (number of elements, dimensions or scaling)
  215.      */
  216.     public static void ensureCompatible(final String description, final List<Unit> reference,
  217.                                         final boolean allowScaleDifferences, final List<Unit> units) {
  218.         if (units.size() != reference.size()) {
  219.             throw new OrekitException(OrekitMessages.WRONG_NB_COMPONENTS,
  220.                                       description, reference.size(), units.size());
  221.         }
  222.         for (int i = 0; i < reference.size(); ++i) {
  223.             if (!reference.get(i).sameDimension(units.get(i))) {
  224.                 throw new OrekitException(OrekitMessages.INCOMPATIBLE_UNITS,
  225.                                           reference.get(i).getName(),
  226.                                           units.get(i).getName());
  227.             }
  228.             if (!(allowScaleDifferences ||
  229.                   Precision.equals(reference.get(i).getScale(), units.get(i).getScale(), 1))) {
  230.                 throw new OrekitException(OrekitMessages.INCOMPATIBLE_UNITS,
  231.                                           reference.get(i).getName(),
  232.                                           units.get(i).getName());
  233.             }
  234.         }
  235.     }

  236.     /** Append a dimension contribution to a unit name.
  237.      * @param builder builder for unit name
  238.      * @param dim name of the dimension
  239.      * @param exp exponent of the dimension
  240.      */
  241.     private void append(final StringBuilder builder, final String dim, final Fraction exp) {
  242.         if (!exp.isZero()) {
  243.             if (builder.length() > 0) {
  244.                 builder.append('.');
  245.             }
  246.             builder.append(dim);
  247.             if (exp.getDenominator() == 1) {
  248.                 if (exp.getNumerator() != 1) {
  249.                     builder.append(Integer.toString(exp.getNumerator()).
  250.                                    replace('-', '⁻').
  251.                                    replace('0', '⁰').
  252.                                    replace('1', '¹').
  253.                                    replace('2', '²').
  254.                                    replace('3', '³').
  255.                                    replace('4', '⁴').
  256.                                    replace('5', '⁵').
  257.                                    replace('6', '⁶').
  258.                                    replace('7', '⁷').
  259.                                    replace('8', '⁸').
  260.                                    replace('9', '⁹'));
  261.                 }
  262.             } else {
  263.                 builder.
  264.                     append("^(").
  265.                     append(exp.getNumerator()).
  266.                     append('/').
  267.                     append(exp.getDenominator()).
  268.                     append(')');
  269.             }
  270.         }
  271.     }

  272.     /** Create an alias for a unit.
  273.      * @param newName name of the new unit
  274.      * @return a new unit representing same unit as the instance but with a different name
  275.      */
  276.     public Unit alias(final String newName) {
  277.         return new Unit(newName, scale, mass, length, time, current, angle);
  278.     }

  279.     /** Scale a unit.
  280.      * @param newName name of the new unit
  281.      * @param factor scaling factor
  282.      * @return a new unit representing scale times the instance
  283.      */
  284.     public Unit scale(final String newName, final double factor) {
  285.         return new Unit(newName, factor * scale, mass, length, time, current, angle);
  286.     }

  287.     /** Create power of unit.
  288.      * @param newName name of the new unit
  289.      * @param exponent exponent to apply
  290.      * @return a new unit representing the power of the instance
  291.      */
  292.     public Unit power(final String newName, final Fraction exponent) {

  293.         final int num = exponent.getNumerator();
  294.         final int den = exponent.getDenominator();
  295.         double s = (num == 1) ? scale : FastMath.pow(scale, num);
  296.         if (den > 1) {
  297.             if (den == 2) {
  298.                 s = FastMath.sqrt(s);
  299.             } else if (den == 3) {
  300.                 s = FastMath.cbrt(s);
  301.             } else {
  302.                 s = FastMath.pow(s, 1.0 / den);
  303.             }
  304.         }

  305.         return new Unit(newName, s,
  306.                         mass.multiply(exponent), length.multiply(exponent),
  307.                         time.multiply(exponent), current.multiply(current),
  308.                         angle.multiply(exponent));
  309.     }

  310.     /** Create root of unit.
  311.      * @param newName name of the new unit
  312.      * @return a new unit representing the square root of the instance
  313.      */
  314.     public Unit sqrt(final String newName) {
  315.         return new Unit(newName, FastMath.sqrt(scale),
  316.                         mass.divide(2), length.divide(2),
  317.                         time.divide(2), current.divide(2),
  318.                         angle.divide(2));
  319.     }

  320.     /** Create product of units.
  321.      * @param newName name of the new unit
  322.      * @param other unit to multiply with
  323.      * @return a new unit representing the this times the other unit
  324.      */
  325.     public Unit multiply(final String newName, final Unit other) {
  326.         return new Unit(newName, scale * other.scale,
  327.                         mass.add(other.mass), length.add(other.length),
  328.                         time.add(other.time), current.add(other.current),
  329.                         angle.add(other.angle));
  330.     }

  331.     /** Create quotient of units.
  332.      * @param newName name of the new unit
  333.      * @param other unit to divide with
  334.      * @return a new unit representing the this divided by the other unit
  335.      */
  336.     public Unit divide(final String newName, final Unit other) {
  337.         return new Unit(newName, scale / other.scale,
  338.                         mass.subtract(other.mass), length.subtract(other.length),
  339.                         time.subtract(other.time), current.subtract(other.current),
  340.                         angle.subtract(other.angle));
  341.     }

  342.     /** Convert a value to SI units.
  343.      * @param value value instance unit
  344.      * @return value in SI units
  345.      */
  346.     public double toSI(final double value) {
  347.         return value * scale;
  348.     }

  349.     /** Convert a value to SI units.
  350.      * @param value value instance unit
  351.      * @return value in SI units
  352.      */
  353.     public double toSI(final Double value) {
  354.         return value == null ? Double.NaN : value.doubleValue() * scale;
  355.     }

  356.     /** Convert a value to SI units.
  357.      * @param <T> type of the field elements
  358.      * @param value value instance unit
  359.      * @return value in SI units
  360.      * @since 12.1
  361.      */
  362.     public <T extends CalculusFieldElement<T>> T toSI(final T value) {
  363.         return value.multiply(scale);
  364.     }

  365.     /** Convert a value from SI units.
  366.      * @param value value SI unit
  367.      * @return value in instance units
  368.      */
  369.     public double fromSI(final double value) {
  370.         return value / scale;
  371.     }

  372.     /** Convert a value from SI units.
  373.      * @param value value SI unit
  374.      * @return value in instance units
  375.      */
  376.     public double fromSI(final Double value) {
  377.         return value == null ? Double.NaN : value.doubleValue() / scale;
  378.     }

  379.     /** Convert a value from SI units.
  380.      * @param <T> type of the field elements
  381.      * @param value value SI unit
  382.      * @return value in instance units
  383.      */
  384.     public <T extends CalculusFieldElement<T>> T fromSI(final T value) {
  385.         return value.divide(scale);
  386.     }

  387.     /** Parse a unit.
  388.      * <p>
  389.      * The grammar for unit specification allows chains units multiplication and
  390.      * division, as well as putting powers on units.
  391.      * </p>
  392.      * <p>The symbols used for units are the SI units with some extensions.
  393.      * </p>
  394.      * <dl>
  395.      *   <dt>year</dt>
  396.      *   <dd>the accepted non-SI unit for Julian year is "a" but we also accept "yr"</dd>
  397.      *   <dt>day</dt>
  398.      *   <dd>the accepted non-SI unit for day is "d" but we also accept "day"</dd>
  399.      *   <dt>dimensionless</dt>
  400.      *   <dd>both "1" and "#" (U+0023, NUMBER SIGN) are accepted</dd>
  401.      *   <dt>mass</dt>
  402.      *   <dd>"g" is the standard symbol, despite the unit is "kg" (it is the only
  403.      *       unit that has a prefix in its name, so all multiples must be based on "g")</dd>
  404.      *   <dt>degrees</dt>
  405.      *   <dd>the base symbol for degrees is "°" (U+00B0, DEGREE SIGN), but we also accept
  406.      *       "◦" (U+25E6, WHITE BULLET) and "deg"</dd>
  407.      *   <dt>arcminute</dt>
  408.      *   <dd>The base symbol for arcminute is "′" (U+2032, PRIME) but we also accept "'" (U+0027, APOSTROPHE)</dd>
  409.      *   <dt>arcsecond</dt>
  410.      *   <dd>The base symbol for arcsecond is "″" (U+2033, DOUBLE PRIME) but we also accept
  411.      *   "''" (two occurrences of U+0027, APOSTROPHE), "\"" (U+0022, QUOTATION MARK) and "as"</dd>
  412.      * </dl>
  413.      * <p>
  414.      * All the SI prefix (from "y", yocto, to "Y", Yotta) are accepted, as well
  415.      * as integer prefixes. The standard symbol for micro 10⁻⁶ is "µ" (U+00B5, MICRO SIGN),
  416.      * but we also accept "μ" (U+03BC, GREEK SMALL LETTER MU). Beware that some combinations
  417.      * are forbidden, for example "Pa" is Pascal, not peta-years, and "as" is arcsecond for
  418.      * this parser, not atto-seconds, because many people in the space field use mas for
  419.      * milliarcseconds and µas for microarcseconds. Beware that prefixes are case-sensitive!
  420.      * Integer prefixes can be used to specify units like "30s", but only once at the beginning
  421.      * of the specification (i.e. "2rev/d²" is accepted, but "rev/(2d)²" is refused). Conforming
  422.      * with SI brochure "The International System of Units" (9th edition, 2019), each SI
  423.      * prefix is part of the unit and precedes the unit symbol without a separator
  424.      * (i.e. MHz is seen as one identifier).
  425.      * </p>
  426.      * <dl>
  427.      *   <dt>multiplication</dt>
  428.      *   <dd>can specified with either "*" (U+002A, ASTERISK), "×" (U+00D7, MULTIPLICATION SIGN),
  429.      *   "." (U+002E, FULL STOP) or "·" (U+00B7, MIDDLE DOT) as the operator</dd>
  430.      *   <dt>division</dt>
  431.      *   <dd>can be specified with either "/" (U+002F, SOLIDUS) or "⁄" (U+2044, FRACTION SLASH)
  432.      *   as the operator</dd>
  433.      *   <dt>powers</dt>
  434.      *   <dd>can be specified either by
  435.      *     <ul>
  436.      *       <li>prefixing with the unicode "√" (U+221A, SQUARE ROOT) character</li>
  437.      *       <li>postfixing with "**", "^" or implicitly using unicode superscripts</li>
  438.      *     </ul>
  439.      *   </dd>
  440.      * </dl>
  441.      * <p>
  442.      * Exponents can be specified in different ways:
  443.      * <ul>
  444.      *   <li>as an integer, as in "m^-2" or "m⁻²"</li>
  445.      *   <li>directly as unicode characters for the few fractions that unicode supports, as in "Ω^⅞"</li>
  446.      *   <li>as the special decimal value 0.5 which is used by CCSDS, as in "km**0.5"</li>
  447.      *   <li>as a pair of parentheses surrounding two integers separated by a solidus or fraction slash,
  448.      *   as in "Pa^(11/12)"</li>
  449.      * </ul>
  450.      * For integer exponents, the digits must be ASCII digits from the Basic Latin block from
  451.      * unicode if explicit exponent marker "**" or "^" is used, or using unicode superscript
  452.      * digits if implicit exponentiation (i.e. no markers at all) is used. Unicode superscripts
  453.      * are not allowed for fractional exponents because unicode does not provide a superscript solidus.
  454.      * Negative exponents can be used too.
  455.      * <p>
  456.      * These rules mean all the following (silly) examples are parsed properly:
  457.      * MHz, km/√d, kg.m.s⁻¹, µas^⅖/(h**(2)×m)³, km/√(kg.s), km**0.5, 2rev/d²
  458.      * </p>
  459.      * @param unitSpecification unit specification to parse
  460.      * @return parsed unit
  461.      */
  462.     public static Unit parse(final String unitSpecification) {

  463.         // parse the specification
  464.         final List<PowerTerm> terms = Parser.buildTermsList(unitSpecification);

  465.         if (terms == null) {
  466.             // special handling of "n/a"
  467.             return Unit.NONE;
  468.         }

  469.         // build compound unit
  470.         Unit unit = Unit.ONE;
  471.         for (final PowerTerm term : terms) {
  472.             try {
  473.                 Unit u = PrefixedUnit.valueOf(term.getBase().toString());
  474.                 if (!Fraction.ONE.equals(term.getExponent())) {
  475.                     u = u.power(null, term.getExponent());
  476.                 }
  477.                 u = u.scale(null, term.getScale());
  478.                 unit = unit.multiply(null, u);
  479.             } catch (IllegalArgumentException iae) {
  480.                 throw new OrekitException(OrekitMessages.UNKNOWN_UNIT, term.getBase());
  481.             }
  482.         }

  483.         // give final name to unit
  484.         return unit.alias(unitSpecification);

  485.     }

  486.     /** Check if the instance represents the same unit as another instance.
  487.      * <p>
  488.      * The name is not considered so aliases are considered equal.
  489.      * </p>
  490.      * @param unit other unit
  491.      * @return true if the instance and the other unit refer to the same unit
  492.      */
  493.     public boolean equals(final Object unit) {

  494.         if (unit == this) {
  495.             // first fast check
  496.             return true;
  497.         }

  498.         if (unit instanceof Unit) {
  499.             final Unit u = (Unit) unit;
  500.             return Precision.equals(scale, u.scale, 1) &&
  501.                    mass.equals(u.mass) && length.equals(u.length) && time.equals(u.time) &&
  502.                    current.equals(u.current) && angle.equals(u.angle);
  503.         }

  504.         return false;

  505.     }

  506.     /** Get a hashcode for this unit.
  507.      * @return hashcode
  508.      */
  509.     public int hashCode() {
  510.         return 0x67e7 ^
  511.                (Double.hashCode(scale) << 12) ^
  512.                (mass.hashCode()        << 10) ^
  513.                (length.hashCode()      <<  8) ^
  514.                (time.hashCode()        <<  6) ^
  515.                (current.hashCode()     <<  4) ^
  516.                (angle.hashCode()       <<  2);
  517.     }

  518.     /** {@inheritDoc} */
  519.     @Override
  520.     public String toString() {
  521.         return getName();
  522.     }

  523. }