org.orekit.time.FieldTimeStampedPair Maven / Gradle / Ivy
Show all versions of orekit Show documentation
/* Copyright 2002-2024 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.time;
import org.hipparchus.CalculusFieldElement;
/**
* Pair of time stamped values being defined at the same date.
*
* @param first time stamped value
* @param second time stamped value
* @param type of the field element
*
* @author Vincent Cucchietti
* @see FieldTimeStamped
*/
public class FieldTimeStampedPair, S extends FieldTimeStamped,
KK extends CalculusFieldElement> implements FieldTimeStamped {
/** Default date equality threshold of 1 ns. */
public static final double DEFAULT_DATE_EQUALITY_THRESHOLD = 1e-9;
/** First time stamped value. */
private final F first;
/** Second time stamped value. */
private final S second;
/**
* Constructor.
*
* First and second value must have the same date.
*
* @param first first time stamped value
* @param second second time stamped value
*/
public FieldTimeStampedPair(final F first, final S second) {
this(first, second, DEFAULT_DATE_EQUALITY_THRESHOLD);
}
/**
* Constructor.
*
* First and second value must have the same date.
*
* @param first first time stamped value
* @param second second time stamped value
* @param dateEqualityThreshold threshold below which dates are considered equal
*/
public FieldTimeStampedPair(final F first, final S second, final double dateEqualityThreshold) {
TimeStampedPair.checkDatesConsistency(first.getDate().toAbsoluteDate(), second.getDate().toAbsoluteDate(),
dateEqualityThreshold);
this.first = first;
this.second = second;
}
/** {@inheritDoc} */
@Override
public FieldAbsoluteDate getDate() {
return first.getDate();
}
/** Get first time stamped value.
* @return first time stamped value
*/
public F getFirst() {
return first;
}
/** Get second time stamped value.
* @return second time stamped value
*/
public S getSecond() {
return second;
}
}