View Javadoc
1   /*
2    * Copyright (C) 2019 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.navigation.inertial;
17  
18  import com.irurueta.units.Acceleration;
19  
20  import java.io.Serial;
21  
22  /**
23   * Contains acceleration due to gravity resolved about ECI frame.
24   */
25  public class ECIGravitation extends GravityOrGravitation<ECIGravitation> {
26  
27      /**
28       * Serialization version. This is used to ensure compatibility of deserialization of permanently stored serialized
29       * instances.
30       */
31      @Serial
32      private static final long serialVersionUID = 0L;
33  
34      /**
35       * Constructor.
36       */
37      public ECIGravitation() {
38          super();
39      }
40  
41      /**
42       * Constructor.
43       *
44       * @param gx acceleration due to gravity through ECI x-axis expressed in meters per squared second (m/s^2).
45       * @param gy acceleration due to gravity through ECI y-axis expressed in meters per squared second (m/s^2).
46       * @param gz acceleration due to gravity through ECI z-axis expressed in meters per squared second (m/s^2).
47       */
48      public ECIGravitation(final double gx, final double gy, final double gz) {
49          super(gx, gy, gz);
50      }
51  
52      /**
53       * Constructor.
54       *
55       * @param gx acceleration due to gravity through ECI x-axis to be set.
56       * @param gy acceleration due to gravity through ECI y-axis to be set.
57       * @param gz acceleration due to gravity through ECI z-axis to be set.
58       */
59      public ECIGravitation(final Acceleration gx, final Acceleration gy, final Acceleration gz) {
60          super(gx, gy, gz);
61      }
62  
63      /**
64       * Constructor.
65       *
66       * @param input instance to copy data from.
67       */
68      public ECIGravitation(final ECIGravitation input) {
69          super(input);
70      }
71  
72      /**
73       * Computes and returns hash code for this instance. Hash codes are almost unique
74       * values that are useful for fast classification and storage of objects in collections.
75       *
76       * @return Hash code.
77       */
78      @Override
79      public int hashCode() {
80          return super.hashCode();
81      }
82  
83      /**
84       * Check if provided object is a ECIGravitation instance having exactly the same contents
85       * as this instance.
86       *
87       * @param obj object to be compared.
88       * @return true if both objects are considered to be equal, false otherwise.
89       */
90      @Override
91      public boolean equals(final Object obj) {
92          if (obj == null) {
93              return false;
94          }
95          if (obj == this) {
96              return true;
97          }
98          if (!(obj instanceof ECIGravitation)) {
99              return false;
100         }
101 
102         //noinspection PatternVariableCanBeUsed
103         final var other = (ECIGravitation) obj;
104         return equals(other);
105     }
106 
107     /**
108      * Makes a copy of this instance.
109      *
110      * @return a copy of this instance.
111      * @throws CloneNotSupportedException if clone fails for some reason.
112      */
113     @Override
114     protected Object clone() throws CloneNotSupportedException {
115         final var result = (ECIGravitation) super.clone();
116         copyTo(result);
117         return result;
118     }
119 }