-
Notifications
You must be signed in to change notification settings - Fork 2
/
cxform-auto.c
2074 lines (1922 loc) · 65.3 KB
/
cxform-auto.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
static char const Ident[] = "@(#) $XX: cxform-auto.c c:1.30 pl:1.40 $";
/*
** This file is automatically generated. *** DO NOT EDIT BY HAND! ***
**
** Generated by the script `gen_cxform_auto.pl', version 1.40,
** from input `cxform-manual.c' version 1.30.
**
** This code is simply a set of wrapper functions for the basic
** coordinate transformations (J2000 to GEI, GEI to GSE, and so on).
** Although there are only a small set of "real" transforms, we want
** to be able to go from one to another without having to think (after
** all, that's what computers are for).
**
** This module performs the mappings for going from any coordinate
** system to any other. It also provides the front end "cxform()",
** so the source/destination frames can be passed as strings, instead
** of having to hardcode "gse_to_gsm()" or whatever.
*/
#include <stdio.h>
#include <string.h>
#include "cxform.h"
/*
** First, though, we want a way to convert from a char string ("GSE")
** to a numeric representation. Here we define an enum listing all
** the known coordinate systems, plus UNKNOWN. We then define a
** complicated-looking function that looks at the input string, char
** by char, and returns the numeric representation of the desired
** coordinate system. Note that upper/lower case combos are fine.
*/
enum systems { UNKNOWN, J2000, GEI, GEO, MAG, GSE, GSM, SM, RTN, GSEQ, HEE, HAE, HEEQ };
enum systems system_number( const char *system )
{
if (system == NULL)
return UNKNOWN;
switch (system[0]) {
case 'g': /* GEI, GEO, GSE, GSM, GSEQ */
case 'G':
switch (system[1]) {
case 'e': /* GEI, GEO */
case 'E':
switch (system[2]) {
case 'i': /* GEI */
case 'I':
switch (system[3]) {
case '\0':
return GEI;
default:
return UNKNOWN;
}
case 'o': /* GEO */
case 'O':
switch (system[3]) {
case '\0':
return GEO;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 's': /* GSE, GSM, GSEQ */
case 'S':
switch (system[2]) {
case 'e': /* GSE, GSEQ */
case 'E':
switch (system[3]) {
case '\0':
return GSE;
case 'q': /* GSEQ */
case 'Q':
switch (system[4]) {
case '\0':
return GSEQ;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 'm': /* GSM */
case 'M':
switch (system[3]) {
case '\0':
return GSM;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 'h': /* HEE, HAE, HEEQ */
case 'H':
switch (system[1]) {
case 'a': /* HAE */
case 'A':
switch (system[2]) {
case 'e': /* HAE */
case 'E':
switch (system[3]) {
case '\0':
return HAE;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 'e': /* HEE, HEEQ */
case 'E':
switch (system[2]) {
case 'e': /* HEE, HEEQ */
case 'E':
switch (system[3]) {
case '\0':
return HEE;
case 'q': /* HEEQ */
case 'Q':
switch (system[4]) {
case '\0':
return HEEQ;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 'j': /* J2000 */
case 'J':
switch (system[1]) {
case '2': /* J2000 */
switch (system[2]) {
case '0': /* J2000 */
switch (system[3]) {
case '0': /* J2000 */
switch (system[4]) {
case '0': /* J2000 */
switch (system[5]) {
case '\0':
return J2000;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 'm': /* MAG */
case 'M':
switch (system[1]) {
case 'a': /* MAG */
case 'A':
switch (system[2]) {
case 'g': /* MAG */
case 'G':
switch (system[3]) {
case '\0':
return MAG;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 'r': /* RTN */
case 'R':
switch (system[1]) {
case 't': /* RTN */
case 'T':
switch (system[2]) {
case 'n': /* RTN */
case 'N':
switch (system[3]) {
case '\0':
return RTN;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
case 's': /* SM */
case 'S':
switch (system[1]) {
case 'm': /* SM */
case 'M':
switch (system[2]) {
case '\0':
return SM;
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
default:
return UNKNOWN;
}
}
/*
** The following boring list of prototypes is for the benefit of cxform().
**
** The first cluster, below, lists the functions defined in cxform-manual.c
*/
extern int j2000_twixt_gei (double t, Vec in, Vec out, Direction d);
extern int gei_twixt_geo (double t, Vec in, Vec out, Direction d);
extern int gei_twixt_gse (double t, Vec in, Vec out, Direction d);
extern int geo_twixt_mag (double t, Vec in, Vec out, Direction d);
extern int gse_twixt_gsm (double t, Vec in, Vec out, Direction d);
extern int gse_twixt_rtn (double t, Vec in, Vec out, Direction d);
extern int gse_twixt_gseq (double t, Vec in, Vec out, Direction d);
extern int gse_twixt_hee (double t, Vec in, Vec out, Direction d);
extern int gsm_twixt_sm (double t, Vec in, Vec out, Direction d);
extern int hae_twixt_hee (double t, Vec in, Vec out, Direction d);
extern int hae_twixt_heeq (double t, Vec in, Vec out, Direction d);
/*
** This second (long) cluster defines the wrappers we generate automatically.
*/
static int j2000_to_gei (double t, Vec in, Vec out);
static int j2000_to_geo (double t, Vec in, Vec out);
static int j2000_to_mag (double t, Vec in, Vec out);
static int j2000_to_gse (double t, Vec in, Vec out);
static int j2000_to_gsm (double t, Vec in, Vec out);
static int j2000_to_sm (double t, Vec in, Vec out);
static int j2000_to_rtn (double t, Vec in, Vec out);
static int j2000_to_gseq (double t, Vec in, Vec out);
static int j2000_to_hee (double t, Vec in, Vec out);
static int j2000_to_hae (double t, Vec in, Vec out);
static int j2000_to_heeq (double t, Vec in, Vec out);
static int gei_to_j2000 (double t, Vec in, Vec out);
static int gei_to_geo (double t, Vec in, Vec out);
static int gei_to_mag (double t, Vec in, Vec out);
static int gei_to_gse (double t, Vec in, Vec out);
static int gei_to_gsm (double t, Vec in, Vec out);
static int gei_to_sm (double t, Vec in, Vec out);
static int gei_to_rtn (double t, Vec in, Vec out);
static int gei_to_gseq (double t, Vec in, Vec out);
static int gei_to_hee (double t, Vec in, Vec out);
static int gei_to_hae (double t, Vec in, Vec out);
static int gei_to_heeq (double t, Vec in, Vec out);
static int geo_to_j2000 (double t, Vec in, Vec out);
static int geo_to_gei (double t, Vec in, Vec out);
static int geo_to_mag (double t, Vec in, Vec out);
static int geo_to_gse (double t, Vec in, Vec out);
static int geo_to_gsm (double t, Vec in, Vec out);
static int geo_to_sm (double t, Vec in, Vec out);
static int geo_to_rtn (double t, Vec in, Vec out);
static int geo_to_gseq (double t, Vec in, Vec out);
static int geo_to_hee (double t, Vec in, Vec out);
static int geo_to_hae (double t, Vec in, Vec out);
static int geo_to_heeq (double t, Vec in, Vec out);
static int mag_to_j2000 (double t, Vec in, Vec out);
static int mag_to_gei (double t, Vec in, Vec out);
static int mag_to_geo (double t, Vec in, Vec out);
static int mag_to_gse (double t, Vec in, Vec out);
static int mag_to_gsm (double t, Vec in, Vec out);
static int mag_to_sm (double t, Vec in, Vec out);
static int mag_to_rtn (double t, Vec in, Vec out);
static int mag_to_gseq (double t, Vec in, Vec out);
static int mag_to_hee (double t, Vec in, Vec out);
static int mag_to_hae (double t, Vec in, Vec out);
static int mag_to_heeq (double t, Vec in, Vec out);
static int gse_to_j2000 (double t, Vec in, Vec out);
static int gse_to_gei (double t, Vec in, Vec out);
static int gse_to_geo (double t, Vec in, Vec out);
static int gse_to_mag (double t, Vec in, Vec out);
static int gse_to_gsm (double t, Vec in, Vec out);
static int gse_to_sm (double t, Vec in, Vec out);
static int gse_to_rtn (double t, Vec in, Vec out);
static int gse_to_gseq (double t, Vec in, Vec out);
static int gse_to_hee (double t, Vec in, Vec out);
static int gse_to_hae (double t, Vec in, Vec out);
static int gse_to_heeq (double t, Vec in, Vec out);
static int gsm_to_j2000 (double t, Vec in, Vec out);
static int gsm_to_gei (double t, Vec in, Vec out);
static int gsm_to_geo (double t, Vec in, Vec out);
static int gsm_to_mag (double t, Vec in, Vec out);
static int gsm_to_gse (double t, Vec in, Vec out);
static int gsm_to_sm (double t, Vec in, Vec out);
static int gsm_to_rtn (double t, Vec in, Vec out);
static int gsm_to_gseq (double t, Vec in, Vec out);
static int gsm_to_hee (double t, Vec in, Vec out);
static int gsm_to_hae (double t, Vec in, Vec out);
static int gsm_to_heeq (double t, Vec in, Vec out);
static int sm_to_j2000 (double t, Vec in, Vec out);
static int sm_to_gei (double t, Vec in, Vec out);
static int sm_to_geo (double t, Vec in, Vec out);
static int sm_to_mag (double t, Vec in, Vec out);
static int sm_to_gse (double t, Vec in, Vec out);
static int sm_to_gsm (double t, Vec in, Vec out);
static int sm_to_rtn (double t, Vec in, Vec out);
static int sm_to_gseq (double t, Vec in, Vec out);
static int sm_to_hee (double t, Vec in, Vec out);
static int sm_to_hae (double t, Vec in, Vec out);
static int sm_to_heeq (double t, Vec in, Vec out);
static int rtn_to_j2000 (double t, Vec in, Vec out);
static int rtn_to_gei (double t, Vec in, Vec out);
static int rtn_to_geo (double t, Vec in, Vec out);
static int rtn_to_mag (double t, Vec in, Vec out);
static int rtn_to_gse (double t, Vec in, Vec out);
static int rtn_to_gsm (double t, Vec in, Vec out);
static int rtn_to_sm (double t, Vec in, Vec out);
static int rtn_to_gseq (double t, Vec in, Vec out);
static int rtn_to_hee (double t, Vec in, Vec out);
static int rtn_to_hae (double t, Vec in, Vec out);
static int rtn_to_heeq (double t, Vec in, Vec out);
static int gseq_to_j2000 (double t, Vec in, Vec out);
static int gseq_to_gei (double t, Vec in, Vec out);
static int gseq_to_geo (double t, Vec in, Vec out);
static int gseq_to_mag (double t, Vec in, Vec out);
static int gseq_to_gse (double t, Vec in, Vec out);
static int gseq_to_gsm (double t, Vec in, Vec out);
static int gseq_to_sm (double t, Vec in, Vec out);
static int gseq_to_rtn (double t, Vec in, Vec out);
static int gseq_to_hee (double t, Vec in, Vec out);
static int gseq_to_hae (double t, Vec in, Vec out);
static int gseq_to_heeq (double t, Vec in, Vec out);
static int hee_to_j2000 (double t, Vec in, Vec out);
static int hee_to_gei (double t, Vec in, Vec out);
static int hee_to_geo (double t, Vec in, Vec out);
static int hee_to_mag (double t, Vec in, Vec out);
static int hee_to_gse (double t, Vec in, Vec out);
static int hee_to_gsm (double t, Vec in, Vec out);
static int hee_to_sm (double t, Vec in, Vec out);
static int hee_to_rtn (double t, Vec in, Vec out);
static int hee_to_gseq (double t, Vec in, Vec out);
static int hee_to_hae (double t, Vec in, Vec out);
static int hee_to_heeq (double t, Vec in, Vec out);
static int hae_to_j2000 (double t, Vec in, Vec out);
static int hae_to_gei (double t, Vec in, Vec out);
static int hae_to_geo (double t, Vec in, Vec out);
static int hae_to_mag (double t, Vec in, Vec out);
static int hae_to_gse (double t, Vec in, Vec out);
static int hae_to_gsm (double t, Vec in, Vec out);
static int hae_to_sm (double t, Vec in, Vec out);
static int hae_to_rtn (double t, Vec in, Vec out);
static int hae_to_gseq (double t, Vec in, Vec out);
static int hae_to_hee (double t, Vec in, Vec out);
static int hae_to_heeq (double t, Vec in, Vec out);
static int heeq_to_j2000 (double t, Vec in, Vec out);
static int heeq_to_gei (double t, Vec in, Vec out);
static int heeq_to_geo (double t, Vec in, Vec out);
static int heeq_to_mag (double t, Vec in, Vec out);
static int heeq_to_gse (double t, Vec in, Vec out);
static int heeq_to_gsm (double t, Vec in, Vec out);
static int heeq_to_sm (double t, Vec in, Vec out);
static int heeq_to_rtn (double t, Vec in, Vec out);
static int heeq_to_gseq (double t, Vec in, Vec out);
static int heeq_to_hee (double t, Vec in, Vec out);
static int heeq_to_hae (double t, Vec in, Vec out);
static char cxform_err_buf[1024];
char *cxform_err(void)
{
return cxform_err_buf;
}
/*
** Here's the main code. Simple, actually. All we do is:
**
** 1) determine the source ("from") and destination ("to") frames,
** and make sure they are valid ones.
**
** 2) call the appropriate <from>_to_<to>() function.
**
** The <from>_to_<to> functions are declared further down below (except
** for the "real" transformation functions, which are in cxform-manual.c).
*/
int cxform(const char *from, const char *to, const double t, Vec v_in, Vec v_out)
{
enum systems from_n, to_n;
cxform_err_buf[0] = '\0';
if (from == NULL) {
strcpy(cxform_err_buf, "No source frame given.");
return 1;
}
if (to == NULL) {
strcpy(cxform_err_buf, "No destination frame given.");
return 1;
}
if ((from_n = system_number(from)) == UNKNOWN) {
sprintf(cxform_err_buf, "Source frame '%s' is unknown;", from);
strcat(cxform_err_buf, " must be one of: J2000 GEI GEO MAG GSE GSM SM RTN GSEQ HEE HAE HEEQ");
return 1;
}
if ((to_n = system_number(to)) == UNKNOWN) {
sprintf(cxform_err_buf, "Destination frame '%s' is unknown;", to);
strcat(cxform_err_buf, " must be one of: J2000 GEI GEO MAG GSE GSM SM RTN GSEQ HEE HAE HEEQ");
return 1;
}
/*
** Check to see if the source and destination are the same. If so,
** return the input vector as output.
*/
if (from_n == to_n) {
int i;
for (i=0; i<3; i++)
v_out[i] = v_in[i];
return 0;
}
/* For the "default" cases in the switches below */
strcpy(cxform_err_buf, "Internal error -- this is impossible");
/*
** Find the source, then find the dest, then call the appropriate xform.
*/
switch (from_n) {
case J2000:
switch (to_n) {
case GEI:
return j2000_to_gei(t,v_in,v_out);
case GEO:
return j2000_to_geo(t,v_in,v_out);
case MAG:
return j2000_to_mag(t,v_in,v_out);
case GSE:
return j2000_to_gse(t,v_in,v_out);
case GSM:
return j2000_to_gsm(t,v_in,v_out);
case SM:
return j2000_to_sm(t,v_in,v_out);
case RTN:
return j2000_to_rtn(t,v_in,v_out);
case GSEQ:
return j2000_to_gseq(t,v_in,v_out);
case HEE:
return j2000_to_hee(t,v_in,v_out);
case HAE:
return j2000_to_hae(t,v_in,v_out);
case HEEQ:
return j2000_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case GEI:
switch (to_n) {
case J2000:
return gei_to_j2000(t,v_in,v_out);
case GEO:
return gei_to_geo(t,v_in,v_out);
case MAG:
return gei_to_mag(t,v_in,v_out);
case GSE:
return gei_to_gse(t,v_in,v_out);
case GSM:
return gei_to_gsm(t,v_in,v_out);
case SM:
return gei_to_sm(t,v_in,v_out);
case RTN:
return gei_to_rtn(t,v_in,v_out);
case GSEQ:
return gei_to_gseq(t,v_in,v_out);
case HEE:
return gei_to_hee(t,v_in,v_out);
case HAE:
return gei_to_hae(t,v_in,v_out);
case HEEQ:
return gei_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case GEO:
switch (to_n) {
case J2000:
return geo_to_j2000(t,v_in,v_out);
case GEI:
return geo_to_gei(t,v_in,v_out);
case MAG:
return geo_to_mag(t,v_in,v_out);
case GSE:
return geo_to_gse(t,v_in,v_out);
case GSM:
return geo_to_gsm(t,v_in,v_out);
case SM:
return geo_to_sm(t,v_in,v_out);
case RTN:
return geo_to_rtn(t,v_in,v_out);
case GSEQ:
return geo_to_gseq(t,v_in,v_out);
case HEE:
return geo_to_hee(t,v_in,v_out);
case HAE:
return geo_to_hae(t,v_in,v_out);
case HEEQ:
return geo_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case MAG:
switch (to_n) {
case J2000:
return mag_to_j2000(t,v_in,v_out);
case GEI:
return mag_to_gei(t,v_in,v_out);
case GEO:
return mag_to_geo(t,v_in,v_out);
case GSE:
return mag_to_gse(t,v_in,v_out);
case GSM:
return mag_to_gsm(t,v_in,v_out);
case SM:
return mag_to_sm(t,v_in,v_out);
case RTN:
return mag_to_rtn(t,v_in,v_out);
case GSEQ:
return mag_to_gseq(t,v_in,v_out);
case HEE:
return mag_to_hee(t,v_in,v_out);
case HAE:
return mag_to_hae(t,v_in,v_out);
case HEEQ:
return mag_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case GSE:
switch (to_n) {
case J2000:
return gse_to_j2000(t,v_in,v_out);
case GEI:
return gse_to_gei(t,v_in,v_out);
case GEO:
return gse_to_geo(t,v_in,v_out);
case MAG:
return gse_to_mag(t,v_in,v_out);
case GSM:
return gse_to_gsm(t,v_in,v_out);
case SM:
return gse_to_sm(t,v_in,v_out);
case RTN:
return gse_to_rtn(t,v_in,v_out);
case GSEQ:
return gse_to_gseq(t,v_in,v_out);
case HEE:
return gse_to_hee(t,v_in,v_out);
case HAE:
return gse_to_hae(t,v_in,v_out);
case HEEQ:
return gse_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case GSM:
switch (to_n) {
case J2000:
return gsm_to_j2000(t,v_in,v_out);
case GEI:
return gsm_to_gei(t,v_in,v_out);
case GEO:
return gsm_to_geo(t,v_in,v_out);
case MAG:
return gsm_to_mag(t,v_in,v_out);
case GSE:
return gsm_to_gse(t,v_in,v_out);
case SM:
return gsm_to_sm(t,v_in,v_out);
case RTN:
return gsm_to_rtn(t,v_in,v_out);
case GSEQ:
return gsm_to_gseq(t,v_in,v_out);
case HEE:
return gsm_to_hee(t,v_in,v_out);
case HAE:
return gsm_to_hae(t,v_in,v_out);
case HEEQ:
return gsm_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case SM:
switch (to_n) {
case J2000:
return sm_to_j2000(t,v_in,v_out);
case GEI:
return sm_to_gei(t,v_in,v_out);
case GEO:
return sm_to_geo(t,v_in,v_out);
case MAG:
return sm_to_mag(t,v_in,v_out);
case GSE:
return sm_to_gse(t,v_in,v_out);
case GSM:
return sm_to_gsm(t,v_in,v_out);
case RTN:
return sm_to_rtn(t,v_in,v_out);
case GSEQ:
return sm_to_gseq(t,v_in,v_out);
case HEE:
return sm_to_hee(t,v_in,v_out);
case HAE:
return sm_to_hae(t,v_in,v_out);
case HEEQ:
return sm_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case RTN:
switch (to_n) {
case J2000:
return rtn_to_j2000(t,v_in,v_out);
case GEI:
return rtn_to_gei(t,v_in,v_out);
case GEO:
return rtn_to_geo(t,v_in,v_out);
case MAG:
return rtn_to_mag(t,v_in,v_out);
case GSE:
return rtn_to_gse(t,v_in,v_out);
case GSM:
return rtn_to_gsm(t,v_in,v_out);
case SM:
return rtn_to_sm(t,v_in,v_out);
case GSEQ:
return rtn_to_gseq(t,v_in,v_out);
case HEE:
return rtn_to_hee(t,v_in,v_out);
case HAE:
return rtn_to_hae(t,v_in,v_out);
case HEEQ:
return rtn_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case GSEQ:
switch (to_n) {
case J2000:
return gseq_to_j2000(t,v_in,v_out);
case GEI:
return gseq_to_gei(t,v_in,v_out);
case GEO:
return gseq_to_geo(t,v_in,v_out);
case MAG:
return gseq_to_mag(t,v_in,v_out);
case GSE:
return gseq_to_gse(t,v_in,v_out);
case GSM:
return gseq_to_gsm(t,v_in,v_out);
case SM:
return gseq_to_sm(t,v_in,v_out);
case RTN:
return gseq_to_rtn(t,v_in,v_out);
case HEE:
return gseq_to_hee(t,v_in,v_out);
case HAE:
return gseq_to_hae(t,v_in,v_out);
case HEEQ:
return gseq_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case HEE:
switch (to_n) {
case J2000:
return hee_to_j2000(t,v_in,v_out);
case GEI:
return hee_to_gei(t,v_in,v_out);
case GEO:
return hee_to_geo(t,v_in,v_out);
case MAG:
return hee_to_mag(t,v_in,v_out);
case GSE:
return hee_to_gse(t,v_in,v_out);
case GSM:
return hee_to_gsm(t,v_in,v_out);
case SM:
return hee_to_sm(t,v_in,v_out);
case RTN:
return hee_to_rtn(t,v_in,v_out);
case GSEQ:
return hee_to_gseq(t,v_in,v_out);
case HAE:
return hee_to_hae(t,v_in,v_out);
case HEEQ:
return hee_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case HAE:
switch (to_n) {
case J2000:
return hae_to_j2000(t,v_in,v_out);
case GEI:
return hae_to_gei(t,v_in,v_out);
case GEO:
return hae_to_geo(t,v_in,v_out);
case MAG:
return hae_to_mag(t,v_in,v_out);
case GSE:
return hae_to_gse(t,v_in,v_out);
case GSM:
return hae_to_gsm(t,v_in,v_out);
case SM:
return hae_to_sm(t,v_in,v_out);
case RTN:
return hae_to_rtn(t,v_in,v_out);
case GSEQ:
return hae_to_gseq(t,v_in,v_out);
case HEE:
return hae_to_hee(t,v_in,v_out);
case HEEQ:
return hae_to_heeq(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
case HEEQ:
switch (to_n) {
case J2000:
return heeq_to_j2000(t,v_in,v_out);
case GEI:
return heeq_to_gei(t,v_in,v_out);
case GEO:
return heeq_to_geo(t,v_in,v_out);
case MAG:
return heeq_to_mag(t,v_in,v_out);
case GSE:
return heeq_to_gse(t,v_in,v_out);
case GSM:
return heeq_to_gsm(t,v_in,v_out);
case SM:
return heeq_to_sm(t,v_in,v_out);
case RTN:
return heeq_to_rtn(t,v_in,v_out);
case GSEQ:
return heeq_to_gseq(t,v_in,v_out);
case HEE:
return heeq_to_hee(t,v_in,v_out);
case HAE:
return heeq_to_hae(t,v_in,v_out);
default: /* Cannot happen */
return 1;
}
default: /*Cannot happen */
return 1;
}
/* We should never get here */
strcat(cxform_err_buf, "INTERNAL ERROR: switch statements fell through!");
return 2;
}
/*
** Stub routines... all we do is call one of The Six, in various orders
*/
/*
** J2000 to GEI
*/
int j2000_to_gei(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD); /* J2000 to GEI */
}
/*
** J2000 to GEO
*/
int j2000_to_geo(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_geo (t, v_out, v_out, FORWARD); /* GEI to GEO */
}
/*
** J2000 to MAG
*/
int j2000_to_mag(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_geo (t, v_out, v_out, FORWARD) /* GEI to GEO */
|| geo_twixt_mag (t, v_out, v_out, FORWARD); /* GEO to MAG */
}
/*
** J2000 to GSE
*/
int j2000_to_gse(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD); /* GEI to GSE */
}
/*
** J2000 to GSM
*/
int j2000_to_gsm(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_gsm (t, v_out, v_out, FORWARD); /* GSE to GSM */
}
/*
** J2000 to SM
*/
int j2000_to_sm(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_gsm (t, v_out, v_out, FORWARD) /* GSE to GSM */
|| gsm_twixt_sm (t, v_out, v_out, FORWARD); /* GSM to SM */
}
/*
** J2000 to RTN
*/
int j2000_to_rtn(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_rtn (t, v_out, v_out, FORWARD); /* GSE to RTN */
}
/*
** J2000 to GSEQ
*/
int j2000_to_gseq(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_gseq (t, v_out, v_out, FORWARD); /* GSE to GSEQ */
}
/*
** J2000 to HEE
*/
int j2000_to_hee(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_hee (t, v_out, v_out, FORWARD); /* GSE to HEE */
}
/*
** J2000 to HAE
*/
int j2000_to_hae(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_hee (t, v_out, v_out, FORWARD) /* GSE to HEE */
|| hae_twixt_hee (t, v_out, v_out, BACK); /* HEE to HAE */
}
/*
** J2000 to HEEQ
*/
int j2000_to_heeq(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, FORWARD) /* J2000 to GEI */
|| gei_twixt_gse (t, v_out, v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_hee (t, v_out, v_out, FORWARD) /* GSE to HEE */
|| hae_twixt_hee (t, v_out, v_out, BACK) /* HEE to HAE */
|| hae_twixt_heeq (t, v_out, v_out, FORWARD); /* HAE to HEEQ */
}
/*
** GEI to J2000
*/
int gei_to_j2000(double t, Vec v_in, Vec v_out)
{
return j2000_twixt_gei (t, v_in , v_out, BACK); /* GEI to J2000 */
}
/*
** GEI to GEO
*/
int gei_to_geo(double t, Vec v_in, Vec v_out)
{
return gei_twixt_geo (t, v_in , v_out, FORWARD); /* GEI to GEO */
}
/*
** GEI to MAG
*/
int gei_to_mag(double t, Vec v_in, Vec v_out)
{
return gei_twixt_geo (t, v_in , v_out, FORWARD) /* GEI to GEO */
|| geo_twixt_mag (t, v_out, v_out, FORWARD); /* GEO to MAG */
}
/*
** GEI to GSE
*/
int gei_to_gse(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD); /* GEI to GSE */
}
/*
** GEI to GSM
*/
int gei_to_gsm(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_gsm (t, v_out, v_out, FORWARD); /* GSE to GSM */
}
/*
** GEI to SM
*/
int gei_to_sm(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_gsm (t, v_out, v_out, FORWARD) /* GSE to GSM */
|| gsm_twixt_sm (t, v_out, v_out, FORWARD); /* GSM to SM */
}
/*
** GEI to RTN
*/
int gei_to_rtn(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_rtn (t, v_out, v_out, FORWARD); /* GSE to RTN */
}
/*
** GEI to GSEQ
*/
int gei_to_gseq(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_gseq (t, v_out, v_out, FORWARD); /* GSE to GSEQ */
}
/*
** GEI to HEE
*/
int gei_to_hee(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_hee (t, v_out, v_out, FORWARD); /* GSE to HEE */
}
/*
** GEI to HAE
*/
int gei_to_hae(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_hee (t, v_out, v_out, FORWARD) /* GSE to HEE */
|| hae_twixt_hee (t, v_out, v_out, BACK); /* HEE to HAE */
}
/*
** GEI to HEEQ
*/
int gei_to_heeq(double t, Vec v_in, Vec v_out)
{
return gei_twixt_gse (t, v_in , v_out, FORWARD) /* GEI to GSE */
|| gse_twixt_hee (t, v_out, v_out, FORWARD) /* GSE to HEE */
|| hae_twixt_hee (t, v_out, v_out, BACK) /* HEE to HAE */
|| hae_twixt_heeq (t, v_out, v_out, FORWARD); /* HAE to HEEQ */
}
/*
** GEO to J2000
*/
int geo_to_j2000(double t, Vec v_in, Vec v_out)
{
return gei_twixt_geo (t, v_in , v_out, BACK) /* GEO to GEI */
|| j2000_twixt_gei (t, v_out, v_out, BACK); /* GEI to J2000 */
}