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.frames;
17
18 import com.irurueta.geometry.Point3D;
19 import com.irurueta.navigation.gnss.ECEFPositionAndVelocity;
20 import com.irurueta.units.Distance;
21 import com.irurueta.units.Speed;
22
23 /**
24 * Contains position, velocity and coordinates transformation matrix expressed in ECEF frame.
25 * Position and velocity of this frame is expressed along ECEF axes as described here:
26 * {@link FrameType#EARTH_CENTERED_EARTH_FIXED_FRAME}.
27 */
28 public class ECEFFrame extends ECIorECEFFrame<ECEFFrame> implements Cloneable {
29
30 /**
31 * Constructor.
32 * Initializes position and velocity coordinates to zero and the coordinate transformation matrix to the
33 * identity.
34 */
35 public ECEFFrame() {
36 super(ECEFFrame.class);
37 c = new CoordinateTransformation(FrameType.BODY_FRAME, FrameType.EARTH_CENTERED_EARTH_FIXED_FRAME);
38 }
39
40 /**
41 * Constructor.
42 *
43 * @param c Body to ECEF coordinate transformation matrix to be set.
44 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
45 */
46 public ECEFFrame(final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
47 super(c);
48 }
49
50 /**
51 * Constructor.
52 *
53 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
54 * ECEF-frame axes.
55 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
56 * ECEF-frame axes.
57 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
58 * ECEF-frame axes.
59 */
60 public ECEFFrame(final double x, final double y, final double z) {
61 this();
62 setCoordinates(x, y, z);
63 }
64
65 /**
66 * Constructor.
67 *
68 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
69 */
70 public ECEFFrame(final Point3D position) {
71 this();
72 setPosition(position);
73 }
74
75 /**
76 * Constructor.
77 *
78 * @param positionX cartesian x coordinate of body position to be set resolved along ECEF-frame axes.
79 * @param positionY cartesian y coordinate of body position to be set resolved along ECEF-frame axes.
80 * @param positionZ cartesian z coordinate of body position to be set resolved along ECEF-frame axes.
81 */
82 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ) {
83 this();
84 setPositionCoordinates(positionX, positionY, positionZ);
85 }
86
87 /**
88 * Constructor.
89 *
90 * @param position cartesian position.
91 */
92 public ECEFFrame(final ECEFPosition position) {
93 this();
94 setPosition(position);
95 }
96
97 /**
98 * Constructor.
99 *
100 * @param x cartesian x coordinate of body position expressed in meters (m) and resolved along ECEF-frame axes.
101 * @param y cartesian y coordinate of body position expressed in meters (m) and resolved along ECEF-frame axes.
102 * @param z cartesian z coordinate of body position expressed in meters (m) and resolved along ECEF-frame axes.
103 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
104 * ECEF-frame axes.
105 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
106 * ECEF-frame axes.
107 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
108 * ECEF-frame axes.
109 */
110 public ECEFFrame(final double x, final double y, final double z,
111 final double vx, final double vy, final double vz) {
112 this(x, y, z);
113 setVelocityCoordinates(vx, vy, vz);
114 }
115
116 /**
117 * Constructor.
118 *
119 * @param position cartesian position.
120 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
121 * ECEF-frame axes.
122 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
123 * ECEF-frame axes.
124 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
125 * ECEF-frame axes.
126 */
127 public ECEFFrame(final ECEFPosition position, final double vx, final double vy, final double vz) {
128 this(position);
129 setVelocityCoordinates(vx, vy, vz);
130 }
131
132 /**
133 * Constructor.
134 *
135 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
136 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
137 * ECEF-frame axes.
138 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
139 * ECEF-frame axes.
140 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
141 * ECEF-frame axes.
142 */
143 public ECEFFrame(final Point3D position, final double vx, final double vy, final double vz) {
144 this(position);
145 setVelocityCoordinates(vx, vy, vz);
146 }
147
148 /**
149 * Constructor.
150 *
151 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
152 * @param speedX x coordinate of velocity to be set resolved along ECEF-frame axes.
153 * @param speedY y coordinate of velocity to be set resolved along ECEF-frame axes.
154 * @param speedZ z coordinate of velocity to be set resolved along ECEF-frame axes.
155 */
156 public ECEFFrame(final Point3D position, final Speed speedX, final Speed speedY, final Speed speedZ) {
157 this(position);
158 setSpeedCoordinates(speedX, speedY, speedZ);
159 }
160
161 /**
162 * Constructor.
163 *
164 * @param position cartesian position.
165 * @param speedX x coordinate of velocity to be set resolved along ECEF-frame axes.
166 * @param speedY y coordinate of velocity to be set resolved along ECEF-frame axes.
167 * @param speedZ z coordinate of velocity to be set resolved along ECEF-frame axes.
168 */
169 public ECEFFrame(final ECEFPosition position, final Speed speedX, final Speed speedY, final Speed speedZ) {
170 this(position);
171 setSpeedCoordinates(speedX, speedY, speedZ);
172 }
173
174 /**
175 * Constructor.
176 *
177 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
178 * @param velocity velocity to be set resolved along ECEF-frame axes.
179 */
180 public ECEFFrame(final Point3D position, final ECEFVelocity velocity) {
181 this(position);
182 setVelocity(velocity);
183 }
184
185 /**
186 * Constructor.
187 *
188 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
189 * along ECEF-frame axes.
190 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
191 * along ECEF-frame axes.
192 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
193 * along ECEF-frame axes.
194 * @param speedX x coordinate of velocity to be set resolved along ECEF-frame axes.
195 * @param speedY y coordinate of velocity to be set resolved along ECEF-frame axes.
196 * @param speedZ z coordinate of velocity to be set resolved along ECEF-frame axes.
197 */
198 public ECEFFrame(final double x, final double y, final double z,
199 final Speed speedX, final Speed speedY, final Speed speedZ) {
200 this(x, y, z);
201 setSpeedCoordinates(speedX, speedY, speedZ);
202 }
203
204 /**
205 * Constructor.
206 *
207 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
208 * along ECEF-frame axes.
209 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
210 * along ECEF-frame axes.
211 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
212 * along ECEF-frame axes.
213 * @param velocity velocity to be set resolved along ECEF-frame axes.
214 */
215 public ECEFFrame(final double x, final double y, final double z, final ECEFVelocity velocity) {
216 this(x, y, z);
217 setVelocity(velocity);
218 }
219
220 /**
221 * Constructor.
222 *
223 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
224 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
225 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
226 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
227 * ECEF-frame axes.
228 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
229 * ECEF-frame axes.
230 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
231 * ECEF-frame axes.
232 */
233 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
234 final double vx, final double vy, final double vz) {
235 this(positionX, positionY, positionZ);
236 setVelocityCoordinates(vx, vy, vz);
237 }
238
239 /**
240 * Constructor.
241 *
242 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
243 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
244 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
245 * @param speedX x coordinate of velocity to be set, resolved along ECEF-frame axes.
246 * @param speedY y coordinate of velocity to be set, resolved along ECEF-frame axes.
247 * @param speedZ z coordinate of velocity to be set, resolved along ECEF-frame axes.
248 */
249 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
250 final Speed speedX, final Speed speedY, final Speed speedZ) {
251 this(positionX, positionY, positionZ);
252 setSpeedCoordinates(speedX, speedY, speedZ);
253 }
254
255 /**
256 * Constructor.
257 *
258 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
259 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
260 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
261 * @param velocity velocity to be set resolved along ECEF-frame axes.
262 */
263 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
264 final ECEFVelocity velocity) {
265 this(positionX, positionY, positionZ);
266 setVelocity(velocity);
267 }
268
269 /**
270 * Constructor.
271 *
272 * @param position cartesian position.
273 * @param velocity velocity to be set resolved along ECEF-frame axes.
274 */
275 public ECEFFrame(final ECEFPosition position, final ECEFVelocity velocity) {
276 this(position);
277 setVelocity(velocity);
278 }
279
280 /**
281 * Constructor.
282 *
283 * @param positionAndVelocity position and velocity to be set resolved
284 * along ECEF-frame axes.
285 */
286 public ECEFFrame(final ECEFPositionAndVelocity positionAndVelocity) {
287 this();
288 setPositionAndVelocity(positionAndVelocity);
289 }
290
291 /**
292 * Constructor.
293 *
294 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
295 * ECEF-frame axes.
296 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
297 * ECEF-frame axes.
298 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
299 * ECEF-frame axes.
300 * @param c Body to ECEF coordinate transformation matrix to be set.
301 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
302 */
303 public ECEFFrame(final double x, final double y, final double z, final CoordinateTransformation c)
304 throws InvalidSourceAndDestinationFrameTypeException {
305 this(x, y, z);
306 setCoordinateTransformation(c);
307 }
308
309 /**
310 * Constructor.
311 *
312 * @param position cartesian position.
313 * @param c Body to ECEF coordinate transformation matrix to be set.
314 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
315 */
316 public ECEFFrame(final ECEFPosition position, final CoordinateTransformation c)
317 throws InvalidSourceAndDestinationFrameTypeException {
318 this(position);
319 setCoordinateTransformation(c);
320 }
321
322 /**
323 * Constructor.
324 *
325 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
326 * @param c Body to ECEF coordinate transformation matrix to be set.
327 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
328 */
329 public ECEFFrame(final Point3D position, final CoordinateTransformation c)
330 throws InvalidSourceAndDestinationFrameTypeException {
331
332 this(position);
333 setCoordinateTransformation(c);
334 }
335
336 /**
337 * Constructor.
338 *
339 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
340 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
341 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
342 * @param c Body to ECEF coordinate transformation matrix to be set.
343 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
344 */
345 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
346 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
347
348 this(positionX, positionY, positionZ);
349 setCoordinateTransformation(c);
350 }
351
352 /**
353 * Constructor.
354 *
355 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
356 * ECEF-frame axes.
357 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
358 * ECEF-frame axes.
359 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame, resolved along
360 * ECEF-frame axes.
361 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
362 * ECEF-frame axes.
363 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
364 * ECEF-frame axes.
365 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
366 * ECEF-frame axes.
367 * @param c Body to ECEF coordinate transformation matrix to be set.
368 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
369 */
370 public ECEFFrame(final double x, final double y, final double z, final double vx, final double vy, final double vz,
371 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
372 this(x, y, z, vx, vy, vz);
373 setCoordinateTransformation(c);
374 }
375
376 /**
377 * Constructor.
378 *
379 * @param position cartesian position.
380 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
381 * ECEF-frame axes.
382 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
383 * ECEF-frame axes.
384 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
385 * ECEF-frame axes.
386 * @param c Body to ECEF coordinate transformation matrix to be set.
387 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
388 */
389 public ECEFFrame(final ECEFPosition position, final double vx, final double vy, final double vz,
390 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
391 this(position, vx, vy, vz);
392 setCoordinateTransformation(c);
393 }
394
395 /**
396 * Constructor.
397 *
398 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame,
399 * resolved along ECEF-frame axes.
400 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame,
401 * resolved along ECEF-frame axes.
402 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame,
403 * resolved along ECEF-frame axes.
404 * @param velocity velocity to be set resolved along ECEF-frame axes.
405 * @param c Body to ECEF coordinate transformation matrix to be set.
406 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
407 */
408 public ECEFFrame(final double x, final double y, final double z, final ECEFVelocity velocity,
409 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
410 this(x, y, z, velocity);
411 setCoordinateTransformation(c);
412 }
413
414 /**
415 * Constructor.
416 *
417 * @param position cartesian position.
418 * @param velocity velocity to be set resolved along ECEF-frame axes.
419 * @param c Body to ECEF coordinate transformation matrix to be set.
420 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
421 */
422 public ECEFFrame(final ECEFPosition position, final ECEFVelocity velocity, final CoordinateTransformation c)
423 throws InvalidSourceAndDestinationFrameTypeException {
424 this(position, velocity);
425 setCoordinateTransformation(c);
426 }
427
428 /**
429 * Constructor.
430 *
431 * @param positionAndVelocity position and velocity to be set resolved along
432 * ECEF-frame axes.
433 * @param c Body to ECEF coordinate transformation matrix to be
434 * set.
435 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
436 */
437 public ECEFFrame(final ECEFPositionAndVelocity positionAndVelocity, final CoordinateTransformation c)
438 throws InvalidSourceAndDestinationFrameTypeException {
439 this(positionAndVelocity);
440 setCoordinateTransformation(c);
441 }
442
443 /**
444 * Constructor.
445 *
446 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
447 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
448 * ECEF-frame axes.
449 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
450 * ECEF-frame axes.
451 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
452 * ECEF-frame axes.
453 * @param c Body to ECEF coordinate transformation matrix to be set.
454 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
455 */
456 public ECEFFrame(final Point3D position, final double vx, final double vy, final double vz,
457 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
458 this(position, vx, vy, vz);
459 setCoordinateTransformation(c);
460 }
461
462 /**
463 * Constructor.
464 *
465 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
466 * @param velocity velocity to be set resolved along ECEF-frame axes.
467 * @param c Body to ECEF coordinate transformation matrix to be set.
468 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
469 */
470 public ECEFFrame(final Point3D position, final ECEFVelocity velocity, final CoordinateTransformation c)
471 throws InvalidSourceAndDestinationFrameTypeException {
472 this(position, velocity);
473 setCoordinateTransformation(c);
474 }
475
476 /**
477 * Constructor.
478 *
479 * @param position body position expressed in meters (m) and resolved along ECEF-frame axes.
480 * @param speedX x coordinate of velocity to be set, resolved along ECEF-frame axes.
481 * @param speedY y coordinate of velocity to be set, resolved along ECEF-frame axes.
482 * @param speedZ z coordinate of velocity to be set, resolved along ECEF-frame axes.
483 * @param c Body to ECEF coordinate transformation matrix to be set.
484 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
485 */
486 public ECEFFrame(final Point3D position, final Speed speedX, final Speed speedY, final Speed speedZ,
487 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
488 this(position, speedX, speedY, speedZ);
489 setCoordinateTransformation(c);
490 }
491
492 /**
493 * Constructor.
494 *
495 * @param position cartesian position.
496 * @param speedX x coordinate of velocity to be set, resolved along ECEF-frame axes.
497 * @param speedY y coordinate of velocity to be set, resolved along ECEF-frame axes.
498 * @param speedZ z coordinate of velocity to be set, resolved along ECEF-frame axes.
499 * @param c Body to ECEF coordinate transformation matrix to be set.
500 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
501 */
502 public ECEFFrame(final ECEFPosition position, final Speed speedX, final Speed speedY, final Speed speedZ,
503 final CoordinateTransformation c) throws InvalidSourceAndDestinationFrameTypeException {
504 this(position, speedX, speedY, speedZ);
505 setCoordinateTransformation(c);
506 }
507
508 /**
509 * Constructor.
510 *
511 * @param x cartesian x coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
512 * along ECEF-frame axes.
513 * @param y cartesian y coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
514 * along ECEF-frame axes.
515 * @param z cartesian z coordinate of body position expressed in meters (m) with respect ECEF frame, resolved
516 * along ECEF-frame axes.
517 * @param speedX x coordinate of velocity to be set, resolved along ECEF-frame axes.
518 * @param speedY y coordinate of velocity to be set, resolved along ECEF-frame axes.
519 * @param speedZ z coordinate of velocity to be set, resolved along ECEF-frame axes.
520 * @param c Body to ECEF coordinate transformation matrix to be set.
521 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
522 */
523 public ECEFFrame(final double x, final double y, final double z,
524 final Speed speedX, final Speed speedY, final Speed speedZ, final CoordinateTransformation c)
525 throws InvalidSourceAndDestinationFrameTypeException {
526 this(x, y, z, speedX, speedY, speedZ);
527 setCoordinateTransformation(c);
528 }
529
530 /**
531 * Constructor.
532 *
533 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
534 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
535 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
536 * @param vx x coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
537 * ECEF-frame axes.
538 * @param vy y coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
539 * ECEF-frame axes.
540 * @param vz z coordinate of velocity of body frame expressed in meters per second (m/s) and resolved along
541 * ECEF-frame axes.
542 * @param c Body to ECEF coordinate transformation matrix to be set.
543 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
544 */
545 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
546 final double vx, final double vy, final double vz, final CoordinateTransformation c)
547 throws InvalidSourceAndDestinationFrameTypeException {
548 this(positionX, positionY, positionZ, vx, vy, vz);
549 setCoordinateTransformation(c);
550 }
551
552 /**
553 * Constructor.
554 *
555 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
556 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
557 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
558 * @param velocity velocity to be set resolved along ECEF-frame axes.
559 * @param c Body to ECEF coordinate transformation matrix to be set.
560 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
561 */
562 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
563 final ECEFVelocity velocity, final CoordinateTransformation c)
564 throws InvalidSourceAndDestinationFrameTypeException {
565 this(positionX, positionY, positionZ, velocity);
566 setCoordinateTransformation(c);
567 }
568
569 /**
570 * Constructor.
571 *
572 * @param positionX cartesian x coordinate of body position to be set, resolved along ECEF-frame axes.
573 * @param positionY cartesian y coordinate of body position to be set, resolved along ECEF-frame axes.
574 * @param positionZ cartesian z coordinate of body position to be set, resolved along ECEF-frame axes.
575 * @param speedX x coordinate of velocity to be set, resolved along ECEF-frame axes.
576 * @param speedY y coordinate of velocity to be set, resolved along ECEF-frame axes.
577 * @param speedZ z coordinate of velocity to be set, resolved along ECEF-frame axes.
578 * @param c Body to ECEF coordinate transformation matrix to be set.
579 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
580 */
581 public ECEFFrame(final Distance positionX, final Distance positionY, final Distance positionZ,
582 final Speed speedX, final Speed speedY, final Speed speedZ, final CoordinateTransformation c)
583 throws InvalidSourceAndDestinationFrameTypeException {
584 this(positionX, positionY, positionZ, speedX, speedY, speedZ);
585 setCoordinateTransformation(c);
586 }
587
588 /**
589 * Constructor.
590 *
591 * @param input ECEF frame to copy data from.
592 */
593 public ECEFFrame(final ECEFFrame input) {
594 this();
595 copyFrom(input);
596 }
597
598 /**
599 * Gets cartesian position.
600 *
601 * @param result instance where cartesian position will be stored.
602 */
603 public void getECEFPosition(final ECEFPosition result) {
604 result.setCoordinates(x, y, z);
605 }
606
607 /**
608 * Gets cartesian position.
609 *
610 * @return cartesian position.
611 */
612 public ECEFPosition getECEFPosition() {
613 return new ECEFPosition(x, y, z);
614 }
615
616 /**
617 * Sets cartesian position.
618 *
619 * @param position cartesian position to be set.
620 */
621 public void setPosition(final ECEFPosition position) {
622 x = position.getX();
623 y = position.getY();
624 z = position.getZ();
625 }
626
627 /**
628 * Gets cartesian velocity.
629 *
630 * @param result instance where cartesian velocity will be stored.
631 */
632 public void getECEFVelocity(final ECEFVelocity result) {
633 result.setCoordinates(vx, vy, vz);
634 }
635
636 /**
637 * Gets cartesian velocity.
638 *
639 * @return cartesian velocity.
640 */
641 public ECEFVelocity getECEFVelocity() {
642 return new ECEFVelocity(vx, vy, vz);
643 }
644
645 /**
646 * Sets cartesian velocity.
647 *
648 * @param velocity cartesian velocity to be set.
649 */
650 public void setVelocity(final ECEFVelocity velocity) {
651 vx = velocity.getVx();
652 vy = velocity.getVy();
653 vz = velocity.getVz();
654 }
655
656 /**
657 * Gets cartesian position and velocity.
658 *
659 * @param result instance where cartesian position and velocity will be stored.
660 */
661 public void getPositionAndVelocity(final ECEFPositionAndVelocity result) {
662 result.setPositionCoordinates(x, y, z);
663 result.setVelocityCoordinates(vx, vy, vz);
664 }
665
666 /**
667 * Gets cartesian position and velocity.
668 *
669 * @return cartesian position and velocity.
670 */
671 public ECEFPositionAndVelocity getPositionAndVelocity() {
672 return new ECEFPositionAndVelocity(x, y, z, vx, vy, vz);
673 }
674
675 /**
676 * Sets cartesian position and velocity.
677 *
678 * @param positionAndVelocity cartesian position and velocity.
679 */
680 public void setPositionAndVelocity(final ECEFPositionAndVelocity positionAndVelocity) {
681 x = positionAndVelocity.getX();
682 y = positionAndVelocity.getY();
683 z = positionAndVelocity.getZ();
684
685 vx = positionAndVelocity.getVx();
686 vy = positionAndVelocity.getVy();
687 vz = positionAndVelocity.getVz();
688 }
689
690 /**
691 * Gets coordinate transformation matrix.
692 *
693 * @return coordinate transformation matrix.
694 */
695 @Override
696 public CoordinateTransformation getCoordinateTransformation() {
697 final var result = new CoordinateTransformation(FrameType.BODY_FRAME,
698 FrameType.EARTH_CENTERED_EARTH_FIXED_FRAME);
699 getCoordinateTransformation(result);
700 return result;
701 }
702
703 /**
704 * Gets coordinate transformation matrix.
705 *
706 * @param result instance where coordinate transformation matrix will be copied to.
707 */
708 @Override
709 public void getCoordinateTransformation(final CoordinateTransformation result) {
710 c.copyTo(result);
711 }
712
713 /**
714 * Sets coordinate transformation matrix.
715 * Provided value must be a body to ECEF transformation matrix.
716 *
717 * @param c coordinate transformation matrix to be set.
718 * @throws InvalidSourceAndDestinationFrameTypeException if source or destination frame types are invalid.
719 */
720 @Override
721 public void setCoordinateTransformation(final CoordinateTransformation c)
722 throws InvalidSourceAndDestinationFrameTypeException {
723 if (!isValidCoordinateTransformation(c)) {
724 throw new InvalidSourceAndDestinationFrameTypeException();
725 }
726
727 this.c = c;
728 }
729
730 /**
731 * Checks whether provided coordinate transformation is valid or not.
732 * Only body to ECEF transformation matrices are considered to be valid.
733 *
734 * @param c coordinate transformation matrix to be checked.
735 * @return true if provided value is valid, false otherwise.
736 */
737 public static boolean isValidCoordinateTransformation(final CoordinateTransformation c) {
738 return c.getSourceType() == FrameType.BODY_FRAME
739 && c.getDestinationType() == FrameType.EARTH_CENTERED_EARTH_FIXED_FRAME;
740 }
741
742 /**
743 * Makes a copy of this instance.
744 *
745 * @return a copy of this instance.
746 * @throws CloneNotSupportedException if clone fails for some reason.
747 */
748 @Override
749 protected Object clone() throws CloneNotSupportedException {
750 final var result = (ECEFFrame) super.clone();
751 copyTo(result);
752 clazz = ECEFFrame.class;
753 return result;
754 }
755 }