1   /* Copyright 2013-2019 CS Systèmes d'Information
2    * Licensed to CS Systèmes d'Information (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.rugged.linesensor;
18  
19  import org.orekit.time.AbsoluteDate;
20  
21  
22  /** Linear model for {@link LineDatation line datation}.
23   * <p>
24   * Instances of this class are guaranteed to be immutable.
25   * </p>
26   * @author Luc Maisonobe
27   */
28  public class LinearLineDatation implements LineDatation {
29  
30      /** Reference date. */
31      private final AbsoluteDate referenceDate;
32  
33      /** Line number at reference date. */
34      private final double referenceLine;
35  
36      /** Rate of lines scanning (lines / seconds). */
37      private final double rate;
38  
39      /** Simple constructor.
40       * @param referenceDate reference date
41       * @param referenceLine line number at reference date
42       * @param rate rate of lines scanning (lines / seconds)
43       */
44      public LinearLineDatation(final AbsoluteDate referenceDate, final double referenceLine,
45                                final double rate) {
46          this.referenceDate = referenceDate;
47          this.referenceLine = referenceLine;
48          this.rate          = rate;
49      }
50  
51      /** {@inheritDoc} */
52      @Override
53      public AbsoluteDate getDate(final double lineNumber) {
54          return referenceDate.shiftedBy((lineNumber - referenceLine) / rate);
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public double getLine(final AbsoluteDate date) {
60          return referenceLine + rate * date.durationFrom(referenceDate);
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public double getRate(final double lineNumber) {
66          return rate;
67      }
68  
69  }