Commit 551fef1b authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'develop' into issue-474

Conflicts:
	src/main/java/org/orekit/utils/units/Lexer.java
	src/main/java/org/orekit/utils/units/Parser.java
	src/main/java/org/orekit/utils/units/Token.java
	src/test/java/org/orekit/utils/units/LexerTest.java
	src/test/java/org/orekit/utils/units/ParserTest.java
parents c0cfff58 4b384b92
......@@ -21,6 +21,12 @@
</properties>
<body>
<release version="11.0" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="776">
Fixed associativity in units parsing.
</action>
<action dev="bryan" type="update" issue="773">
TimeStampedFieldAngularCoordinates now implements FieldTimeStamped.
</action>
<action dev="bryan" type="update" issue="774">
TimeStampedFieldPVCoordinates now implements FieldTimeStamped.
</action>
......
......@@ -32,6 +32,7 @@ import org.orekit.errors.OrekitInternalError;
import org.orekit.errors.OrekitMessages;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.FieldTimeStamped;
import org.orekit.time.TimeStamped;
/** {@link TimeStamped time-stamped} version of {@link FieldAngularCoordinates}.
......@@ -41,7 +42,7 @@ import org.orekit.time.TimeStamped;
* @since 7.0
*/
public class TimeStampedFieldAngularCoordinates<T extends RealFieldElement<T>>
extends FieldAngularCoordinates<T> {
extends FieldAngularCoordinates<T> implements FieldTimeStamped<T> {
/** The date. */
private final FieldAbsoluteDate<T> date;
......@@ -179,9 +180,8 @@ public class TimeStampedFieldAngularCoordinates<T extends RealFieldElement<T>>
getRotation().applyInverseTo(getRotationAcceleration().negate()));
}
/** Get the date.
* @return date
*/
/** {@inheritDoc} */
@Override
public FieldAbsoluteDate<T> getDate() {
return date;
}
......
......@@ -115,7 +115,7 @@ class Lexer {
// look for power
if ((start < end - 1) &&
unitSpecification.charAt(start) == '*' &&
unitSpecification.charAt(start) == '*' &&
unitSpecification.charAt(start + 1) == '*') {
// power indicator as **
return emit(start + 2, TokenType.POWER, 0, 1);
......
......@@ -417,10 +417,10 @@ public class Unit implements Serializable {
* <p>
* All the SI prefix (from "y", yocto, to "Y", Yotta) are accepted. Beware
* that some combinations are forbidden, for example "Pa" is Pascal, not
* peta-years, and "as" is arcsecond for us, not atto-seconds, because many people
* in the space field use mas for milli-arcseconds and µas for micro-arcseconds.
* Beware that prefixes are case-sensitive! Prefix and units must be joined
* without blanks.
* peta-years, and "as" is arcsecond for this parser, not atto-seconds, because
* many people in the space field use mas for milli-arcseconds and µas for
* micro-arcseconds. Beware that prefixes are case-sensitive! Prefix and units
* must be joined without blanks.
* </p>
* <ul>
* <li>multiplication can specified with either "*", "×" or "." as the operator</li>
......@@ -433,12 +433,22 @@ public class Unit implements Serializable {
* </li>
* </ul>
* <p>
* Fractional exponents are allowed, but only with regular characters (because unicode
* does not provide a superscript '/'). Negative exponents can be used too.
* Exponents can be specified in different ways:
* <ul>
* <li>as an integer, as in "m^-2" or "m⁻²"</li>
* <li>directly as unicode characters for the few fractions that unicode supports, as in "Ω^⅞"</li>
* <li>as the special decimal value 0.5 which is used by CCSDS, as in "km**0.5"</li>
* <li>as a pair of parentheses surrounding two integers separated by a '/', as in "Pa^(11/12)"</li>
* </ul>
* For integer exponents, the digits must be ASCII digits from the Basic Latin block from
* unicode if explicit exponent maker "**" or "^" was used, or using unicode superscript
* digits if implicit exponentiation (i.e. no markers at all) is used. Unicode superscripts
* are not allowed fractional exponents because unicode does not provide a superscript '/'.
* Negative exponents can be used too.
* </p>
* <p>
* These rules mean all the following (silly) examples are parsed properly:
* MHz, km/√d, kg.m.s⁻¹, µas^(2/5)/(h**(2)×m)³, km/√(kg.s)
* MHz, km/√d, kg.m.s⁻¹, µas^/(h**(2)×m)³, km/√(kg.s), km**0.5
* </p>
* @param unitSpecification unit specification to parse
* @return parsed unit
......
......@@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.hipparchus.Field;
import org.hipparchus.RealFieldElement;
import org.hipparchus.analysis.differentiation.DSFactory;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.FieldDerivativeStructure;
......@@ -30,6 +32,7 @@ import org.hipparchus.geometry.euclidean.threed.FieldRotation;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Rotation;
import org.hipparchus.geometry.euclidean.threed.RotationConvention;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.random.RandomGenerator;
import org.hipparchus.random.Well1024a;
import org.hipparchus.util.Decimal64;
......@@ -41,6 +44,7 @@ import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.FieldTimeStamped;
import org.orekit.time.TimeScalesFactory;
public class TimeStampedFieldAngularCoordinatesTest {
......@@ -487,6 +491,30 @@ public class TimeStampedFieldAngularCoordinatesTest {
}
@Test
public void testIssue773() {
doTestIssue773(Decimal64Field.getInstance());
}
private <T extends RealFieldElement<T>> void doTestIssue773(final Field<T> field) {
// Epoch
final AbsoluteDate date = new AbsoluteDate();
// Coordinates
final TimeStampedAngularCoordinates angular =
new TimeStampedAngularCoordinates(date,
new Rotation(0., 0., 0., 0., false),
Vector3D.ZERO,
Vector3D.ZERO);
// Time stamped object
final FieldTimeStamped<T> timeStamped =
new TimeStampedFieldAngularCoordinates<>(field, angular);
// Verify
Assert.assertEquals(0.0, date.durationFrom(timeStamped.getDate().toAbsoluteDate()), Double.MIN_VALUE);
}
private FieldVector3D<DerivativeStructure> randomVector(Random random, double norm) {
double n = random.nextDouble() * norm;
double x = random.nextDouble();
......
......@@ -215,7 +215,7 @@ public class LexerTest {
@Test
public void testPushBackAtVirtualExponent() {
final Lexer lexer = new Lexer("m²/s");
expect(lexer, "m", TokenType.IDENTIFIER, 0, 1);
expect(lexer, "m", TokenType.IDENTIFIER, 0, 1);
expect(lexer, "", TokenType.POWER, 0, 1);
lexer.pushBack();
expect(lexer, "", TokenType.POWER, 0, 1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment