1 /* 2 3 -Procedure spkcpt_c ( SPK, constant position target state ) 4 5 -Abstract 6 7 Return the state, relative to a specified observer, of a target 8 having constant position in a specified reference frame. The 9 target's position is provided by the calling program rather than by 10 loaded SPK files. 11 12 -Disclaimer 13 14 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 15 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 16 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 17 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 18 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 19 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 20 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 21 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 22 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 23 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 24 25 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 26 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 27 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 28 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 29 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 30 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 31 32 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 33 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 34 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 35 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 36 37 -Required_Reading 38 39 FRAMES 40 PCK 41 SPK 42 TIME 43 44 -Keywords 45 46 EPHEMERIS 47 48 */ 49 50 #include "SpiceUsr.h" 51 #include "SpiceZfc.h" 52 #include "SpiceZmc.h" 53 #undef spkcpt_c 54 spkcpt_c(ConstSpiceDouble trgpos[3],ConstSpiceChar * trgctr,ConstSpiceChar * trgref,SpiceDouble et,ConstSpiceChar * outref,ConstSpiceChar * refloc,ConstSpiceChar * abcorr,ConstSpiceChar * obsrvr,SpiceDouble state[6],SpiceDouble * lt)55 void spkcpt_c ( ConstSpiceDouble trgpos [3], 56 ConstSpiceChar * trgctr, 57 ConstSpiceChar * trgref, 58 SpiceDouble et, 59 ConstSpiceChar * outref, 60 ConstSpiceChar * refloc, 61 ConstSpiceChar * abcorr, 62 ConstSpiceChar * obsrvr, 63 SpiceDouble state [6], 64 SpiceDouble * lt ) 65 /* 66 67 -Brief_I/O 68 69 Variable I/O Description 70 -------- --- -------------------------------------------------- 71 trgpos I Target position relative to center of motion. 72 trgctr I Center of motion of target. 73 trgref I Frame of target position. 74 et I Observation epoch. 75 outref I Reference frame of output state. 76 refloc I Output reference frame evaluation locus. 77 abcorr I Aberration correction. 78 obsrvr I Name of observing ephemeris object. 79 state O State of target with respect to observer. 80 lt O One way light time between target and 81 observer. 82 83 -Detailed_Input 84 85 trgpos is the fixed (constant) position of a target relative to 86 its "center of motion" `trgctr', expressed in the 87 reference frame `trgref'. 88 89 Units are always km. 90 91 92 trgctr is the name of the center of motion of `trgpos'. The 93 ephemeris of `trgctr' is provided by loaded SPK files. 94 95 Optionally, you may supply the integer ID code for the 96 object as an integer string. For example both "MOON" and 97 "301" are legitimate strings that indicate the moon is 98 the center of motion. 99 100 Case and leading and trailing blanks are not significant 101 in the string `trgctr'. 102 103 104 trgref is the name of the reference frame relative to which the 105 input position `trgpos' is expressed. The target has 106 constant position relative to its center of motion in 107 this reference frame. 108 109 Case and leading and trailing blanks are not significant 110 in the string `trgref'. 111 112 113 et is the ephemeris time at which the state of the target 114 relative to the observer is to be computed. `et' is 115 expressed as seconds past J2000 TDB. `et' refers to time 116 at the observer's location. 117 118 `et' is independent of the target epoch `trgepc'. 119 120 121 outref is the name of the reference frame with respect to which 122 the output state is expressed. 123 124 When `outref' is time-dependent (non-inertial), its 125 orientation relative to the J2000 frame is evaluated in 126 the manner commanded by the input argument `refloc' (see 127 description below). 128 129 Case and leading and trailing blanks are not significant 130 in the string `outref'. 131 132 133 refloc is a string indicating the output reference frame 134 evaluation locus: this is the location associated 135 with the epoch at which this routine is to evaluate 136 the orientation, relative to the J2000 frame, of the 137 output frame `outref'. The values and meanings of 138 `refloc' are: 139 140 "OBSERVER" Evaluate `outref' at the observer's 141 epoch `et'. 142 143 Normally the locus "OBSERVER" should 144 be selected when `outref' is centered 145 at the observer. 146 147 148 "TARGET" Evaluate `outref' at the target epoch; 149 letting `lt' be the one-way light time 150 between the target and observer, the 151 target epoch is 152 153 et-lt if reception aberration 154 corrections are used 155 156 et+lt if transmission aberration 157 corrections are used 158 159 et if no aberration corrections 160 are used 161 162 Normally the locus "TARGET" should 163 be selected when `outref' is `trgref', 164 the frame in which the target position 165 is specified. 166 167 168 "CENTER" Evaluate the frame `outref' at the epoch 169 associated its center. This epoch, 170 which we'll call `etctr', is determined 171 as follows: 172 173 Let `ltctr' be the one-way light time 174 between the observer and the center 175 of `outref'. Then `etctr' is 176 177 et-ltctr if reception 178 aberration corrections 179 are used 180 181 et+ltctr if transmission 182 aberration corrections 183 are used 184 185 et if no aberration 186 corrections are used 187 188 189 The locus "CENTER" should be selected 190 when the user intends to obtain 191 results compatible with those produced 192 by spkezr_c. 193 194 When `outref' is inertial, all choices of `refloc' 195 yield the same results. 196 197 Case and leading and trailing blanks are not 198 significant in the string `refloc'. 199 200 201 abcorr indicates the aberration corrections to be applied to 202 the observer-target state to account for one-way light 203 time and stellar aberration. 204 205 `abcorr' may be any of the following: 206 207 "NONE" Apply no correction. Return the 208 geometric state of the target 209 relative to the observer. 210 211 The following values of `abcorr' apply to the 212 "reception" case in which photons depart from the 213 target's location at the light-time corrected epoch 214 et-lt and *arrive* at the observer's location at `et': 215 216 "LT" Correct for one-way light time (also 217 called "planetary aberration") using a 218 Newtonian formulation. This correction 219 yields the state of the target at the 220 moment it emitted photons arriving at 221 the observer at `et'. 222 223 The light time correction uses an 224 iterative solution of the light time 225 equation. The solution invoked by the 226 "LT" option uses one iteration. 227 228 "LT+S" Correct for one-way light time and 229 stellar aberration using a Newtonian 230 formulation. This option modifies the 231 state obtained with the "LT" option to 232 account for the observer's velocity 233 relative to the solar system 234 barycenter. The result is the apparent 235 state of the target---the position and 236 velocity of the target as seen by the 237 observer. 238 239 "CN" Converged Newtonian light time 240 correction. In solving the light time 241 equation, the "CN" correction iterates 242 until the solution converges. 243 244 "CN+S" Converged Newtonian light time 245 and stellar aberration corrections. 246 247 248 The following values of `abcorr' apply to the 249 "transmission" case in which photons *depart* from 250 the observer's location at `et' and arrive at the 251 target's location at the light-time corrected epoch 252 et+lt: 253 254 "XLT" "Transmission" case: correct for 255 one-way light time using a Newtonian 256 formulation. This correction yields the 257 state of the target at the moment it 258 receives photons emitted from the 259 observer's location at `et'. 260 261 "XLT+S" "Transmission" case: correct for 262 one-way light time and stellar 263 aberration using a Newtonian 264 formulation This option modifies the 265 state obtained with the "XLT" option to 266 account for the observer's velocity 267 relative to the solar system 268 barycenter. The position component of 269 the computed target state indicates the 270 direction that photons emitted from the 271 observer's location must be "aimed" to 272 hit the target. 273 274 "XCN" "Transmission" case: converged 275 Newtonian light time correction. 276 277 "XCN+S" "Transmission" case: converged 278 Newtonian light time and stellar 279 aberration corrections. 280 281 Neither special nor general relativistic effects are 282 accounted for in the aberration corrections applied 283 by this routine. 284 285 Case and leading and trailing blanks are not 286 significant in the string `abcorr'. 287 288 289 obsrvr is the name of an observing body. Optionally, you 290 may supply the ID code of the object as an integer 291 string. For example, both "EARTH" and "399" are 292 legitimate strings to supply to indicate the 293 observer is Earth. 294 295 Case and leading and trailing blanks are not 296 significant in the string `obsrvr'. 297 298 299 -Detailed_Output 300 301 state is a Cartesian state vector representing the position 302 and velocity of the target relative to the specified 303 observer. `state' is corrected for the specified 304 aberrations and is expressed with respect to the 305 reference frame specified by `outref'. The first three 306 components of `state' represent the x-, y- and 307 z-components of the target's position; the last three 308 components form the corresponding velocity vector. 309 310 The position component of `state' points from the 311 observer's location at `et' to the aberration-corrected 312 location of the target. Note that the sense of the 313 position vector is independent of the direction of 314 radiation travel implied by the aberration 315 correction. 316 317 The velocity component of `state' is the derivative 318 with respect to time of the position component of 319 `state'. 320 321 Units are always km and km/sec. 322 323 When `state' is expressed in a time-dependent 324 (non-inertial) output frame, the orientation of that 325 frame relative to the J2000 frame is evaluated in the 326 manner indicated by the input argument `refloc' (see 327 description above). 328 329 330 lt is the one-way light time between the observer and 331 target in seconds. If the target state is corrected 332 for aberrations, then `lt' is the one-way light time 333 between the observer and the light time corrected 334 target location. 335 336 337 -Parameters 338 339 None. 340 341 -Exceptions 342 343 1) If either the name of the center of motion or the observer 344 cannot be translated to its NAIF ID code, the error will 345 be diagnosed by a routine in the call tree of this routine. 346 347 2) If the reference frame `outref' is unrecognized, the error will 348 be diagnosed by a routine in the call tree of this routine. 349 350 3) If the reference frame `trgref' is unrecognized, the error will 351 be diagnosed by a routine in the call tree of this routine. 352 353 4) If the frame evaluation locus `refloc' is not recognized, the 354 error will be diagnosed by a routine in the call tree of this 355 routine. 356 357 5) If the loaded kernels provide insufficient data to compute 358 the requested state vector, the deficiency will be diagnosed 359 by a routine in the call tree of this routine. 360 361 6) If an error occurs while reading an SPK or other kernel file, 362 the error will be diagnosed by a routine in the call tree of 363 this routine. 364 365 7) If the aberration correction `abcorr' is not recognized, 366 the error will be diagnosed by a routine in the call tree of 367 this routine. 368 369 8) If any input string pointer is null, or if the output state 370 pointer is null, the error SPICE(NULLPOINTER) will be signaled. 371 372 9) If any input string has length zero, the error SPICE(EMPTYSTRING) 373 will be signaled. 374 375 376 -Files 377 378 Appropriate kernels must be loaded by the calling program before 379 this routine is called. 380 381 The following data are required: 382 383 - SPK data: ephemeris data for target center and observer 384 must be loaded. If aberration corrections are used, the 385 states of target center and observer relative to the solar 386 system barycenter must be calculable from the available 387 ephemeris data. Typically ephemeris data are made available 388 by loading one or more SPK files using furnsh_c. 389 390 The following data may be required: 391 392 - PCK data: if the target frame is a PCK frame, rotation data 393 for the target frame must be loaded. These may be provided 394 in a text or binary PCK file. 395 396 - Frame data: if a frame definition not built into SPICE is 397 required, for example to convert the observer-target state to 398 the output frame, that definition must be available in the 399 kernel pool. Typically frame definitions are supplied by 400 loading a frame kernel using furnsh_c. 401 402 - Additional kernels: if any frame used in this routine's 403 state computation is a CK frame, then at least one CK and 404 corresponding SCLK kernel is required. If dynamic frames 405 are used, additional SPK, PCK, CK, or SCLK kernels may be 406 required. 407 408 In all cases, kernel data are normally loaded once per program 409 run, NOT every time this routine is called. 410 411 -Particulars 412 413 This routine computes observer-target states for targets whose 414 trajectories are not provided by SPK files. 415 416 Targets supported by this routine must have constant position 417 with respect to a specified center of motion, expressed in a 418 caller-specified reference frame. The state of the center of 419 motion relative to the observer must be computable using 420 loaded SPK data. 421 422 For applications in which the target has non-zero, constant velocity 423 relative to its center of motion, the CSPICE routine 424 425 spkcvt_c { SPK, constant velocity target } 426 427 can be used. 428 429 This routine is suitable for computing states of landmarks on the 430 surface of an extended object, as seen by a specified observer, 431 in cases where no SPK data are available for those landmarks. 432 433 This routine's treatment of the output reference frame differs 434 from that of the principal SPK API routines 435 436 spkezr_c 437 spkez_c 438 spkpos_c 439 spkezp_c 440 441 which require both observer and target ephemerides to be provided 442 by loaded SPK files: 443 444 The SPK API routines listed above evaluate the orientation of 445 the output reference frame (with respect to the J2000 frame) 446 at an epoch corrected for one-way light time between the 447 observer and the center of the output frame. When the center 448 of the output frame is not the target (for example, when the 449 target is on the surface of Mars and the output frame is 450 centered at Mars' center), the epoch of evaluation may not 451 closely match the light-time corrected epoch associated with 452 the target itself. 453 454 This routine allows the caller to dictate how the orientation 455 of the output reference frame is to be evaluated. The caller 456 passes to this routine an input string called the output 457 frame's evaluation "locus." This string specifies the location 458 associated with the output frame's evaluation epoch. The three 459 possible values of the locus are 460 461 "TARGET" 462 "OBSERVER" 463 "CENTER" 464 465 The choice of locus has an effect when aberration corrections 466 are used and the output frame is non-inertial. 467 468 When the locus is "TARGET" and light time corrections are used, 469 the orientation of the output frame is evaluated at the epoch 470 obtained by correcting the observation epoch `et' for one-way 471 observer-target light time `lt'. The evaluation epoch will be 472 either et-lt or et+lt for reception or transmission corrections 473 respectively. 474 475 For remote sensing applications where the target is a surface 476 point on an extended object, and the orientation of that 477 object should be evaluated at the emission time, the locus 478 "TARGET" should be used. 479 480 When the output frame's orientation should be evaluated at 481 the observation epoch `et', which is the case when the 482 output frame is centered at the observer, the locus 483 "OBSERVER" should be used. 484 485 The locus option "CENTER" is provided for compatibility 486 with existing SPK state computation APIs such as spkezr_c. 487 488 Note that the output frame evaluation locus does not affect 489 the computation of light time between the target and 490 observer. 491 492 493 The SPK routines that compute observer-target states for 494 combinations of objects having ephemerides provided by SPK files and 495 objects having constant position or constant velocity are 496 497 spkcpo_c {SPK, Constant position observer} 498 spkcpt_c {SPK, Constant position target} 499 spkcvo_c {SPK, Constant velocity observer} 500 spkcvt_c {SPK, Constant velocity target} 501 502 -Examples 503 504 The numerical results shown for these examples may differ across 505 platforms. The results depend on the SPICE kernels used as 506 input, the compiler and supporting libraries, and the machine 507 specific arithmetic implementation. 508 509 1) Demonstrate use of this routine; in particular demonstrate 510 applications of the output frame evaluation locus. 511 512 The following program is not necessarily realistic: for 513 brevity, it combines several unrelated computations. 514 515 Task Description 516 ================ 517 518 Find the state of a given surface point on earth, corrected 519 for light time and stellar aberration, relative to the Mars 520 Global Surveyor spacecraft, expressed in the earth fixed 521 reference frame ITRF93. The selected point is the position 522 of the DSN station DSS-14. 523 524 Contrast the states computed by setting the output frame 525 evaluation locus to "TARGET" and to "CENTER". Show that the 526 latter choice produces results very close to those that 527 can be obtained using spkezr_c. 528 529 Also compute the state of a selected Mars surface point as 530 seen from MGS. The point we'll use is the narrow angle MOC 531 boresight surface intercept corresponding to the chosen 532 observation time. Express the state in a spacecraft-centered 533 reference frame. Use the output frame evaluation locus 534 "OBSERVER" for this computation. 535 536 The observation epoch is 2003 OCT 13 06:00:00 UTC. 537 538 539 Kernels 540 ======= 541 542 Use the meta-kernel shown below to load the required SPICE 543 kernels. 544 545 KPL/MK 546 547 File name: spkcpt.tm 548 549 This is the meta-kernel file for the header code example for 550 the subroutine spkcpt_c. The kernel files referenced by this 551 meta-kernel can be found on the NAIF website. 552 553 In order for an application to use this meta-kernel, the 554 kernels referenced here must be present in the user's 555 current working directory. 556 557 The names and contents of the kernels referenced 558 by this meta-kernel are as follows: 559 560 File name Contents 561 --------- -------- 562 de421.bsp Planetary ephemeris 563 pck00010.tpc Planet orientation and 564 radii 565 naif0010.tls Leapseconds 566 earth_720101_070426.bpc Earth historical 567 binary PCK 568 earthstns_itrf93_050714.bsp DSN station SPK 569 mgs_moc_v20.ti MGS MOC instrument 570 parameters 571 mgs_sclkscet_00061.tsc MGS SCLK coefficients 572 mgs_sc_ext12.bc MGS s/c bus attitude 573 mgs_ext12_ipng_mgs95j.bsp MGS ephemeris 574 575 \begindata 576 577 KERNELS_TO_LOAD = ( 'de421.bsp', 578 'pck00010.tpc', 579 'naif0010.tls', 580 'earth_720101_070426.bpc', 581 'earthstns_itrf93_050714.bsp', 582 'mgs_moc_v20.ti', 583 'mgs_sclkscet_00061.tsc', 584 'mgs_sc_ext12.bc', 585 'mgs_ext12_ipng_mgs95j.bsp' ) 586 587 \begintext 588 589 End of meta-kernel. 590 591 592 Example code begins here. 593 594 595 /. 596 Program spkcpt_ex1 597 598 599 This program demonstrates the use of spkcpt_c. 600 Computations are performed using all three possible 601 values of the output frame evaluation locus `refloc': 602 603 "TARGET" 604 "OBSERVER" 605 "CENTER" 606 607 Several unrelated computations are performed in this 608 program. In particular, computations involving a surface 609 point on Mars are included simply to demonstrate use of 610 the "OBSERVER" option. 611 ./ 612 613 #include <stdio.h> 614 #include <string.h> 615 #include <stdlib.h> 616 #include "SpiceUsr.h" 617 618 int main() 619 { 620 /. 621 Local constants 622 ./ 623 624 #define CAMERA "MGS_MOC_NA" 625 #define MAXBND 100 626 #define META "spkcpt.tm" 627 #define FRNMLN 33 628 #define SHAPLN 33 629 #define TIMFMT "YYYY MON DD HR:MN:SC.###### UTC" 630 #define TIMLEN 41 631 632 /. 633 Local variables 634 ./ 635 SpiceBoolean found; 636 637 SpiceChar * abcorr; 638 SpiceChar camref [ FRNMLN ]; 639 SpiceChar emitim [ TIMLEN ]; 640 SpiceChar * refloc; 641 SpiceChar * obsrvr; 642 SpiceChar * obstim; 643 SpiceChar * outref; 644 SpiceChar shape [ SHAPLN ]; 645 SpiceChar * target; 646 SpiceChar * trgctr; 647 SpiceChar * trgref; 648 649 SpiceDouble bounds [ MAXBND ] [ 3 ]; 650 SpiceDouble bsight [ 3 ]; 651 SpiceDouble et; 652 SpiceDouble lt0; 653 SpiceDouble lt1; 654 SpiceDouble lt2; 655 SpiceDouble lt3; 656 SpiceDouble spoint [ 3 ]; 657 SpiceDouble srfvec [ 3 ]; 658 SpiceDouble state0 [ 6 ]; 659 SpiceDouble state1 [ 6 ]; 660 SpiceDouble state2 [ 6 ]; 661 SpiceDouble state3 [ 6 ]; 662 SpiceDouble trgepc ; 663 SpiceDouble trgpos [ 3 ]; 664 665 SpiceInt camid; 666 SpiceInt n; 667 668 /. 669 Load SPICE kernels. 670 ./ 671 furnsh_c ( META ); 672 673 /. 674 Convert the observation time to seconds past J2000 TDB. 675 ./ 676 obstim = "2003 OCT 13 06:00:00.000000 UTC"; 677 678 str2et_c ( obstim, &et ); 679 680 /. 681 Set the observer, target center, and target frame. 682 ./ 683 obsrvr = "MGS"; 684 trgctr = "EARTH"; 685 trgref = "ITRF93"; 686 687 /. 688 Set the state of DSS-14 relative to the earth's 689 center at the J2000 epoch, expressed in the 690 ITRF93 reference frame. Values come from the 691 earth station SPK specified in the meta-kernel. 692 693 The actual station velocity is non-zero due 694 to tectonic plate motion; we ignore the motion 695 in this example. See the routine spkcvt_c for an 696 example in which the plate motion is accounted for. 697 ./ 698 trgpos[0] = -2353.6213656676991; 699 trgpos[1] = -4641.3414911499403; 700 trgpos[2] = 3677.0523293197439; 701 702 /. 703 Find the apparent state of the station relative 704 to the spacecraft in the ITRF93 reference frame. 705 Evaluate the earth's orientation, that is the 706 orientation of the ITRF93 frame relative to the 707 J2000 frame, at the epoch obtained by correcting 708 the observation time for one-way light time. This 709 correction is obtained by setting `refloc' to "TARGET". 710 ./ 711 outref = "ITRF93"; 712 abcorr = "CN+S"; 713 714 refloc = "TARGET"; 715 716 /. 717 Compute the observer-target state. 718 ./ 719 spkcpt_c ( trgpos, trgctr, trgref, 720 et, outref, refloc, abcorr, 721 obsrvr, state0, <0 ); 722 723 /. 724 Display the computed state and light time. 725 ./ 726 timout_c ( et-lt0, TIMFMT, TIMLEN, emitim ); 727 728 printf ( "\n" 729 " Frame evaluation locus: %s\n" 730 "\n" 731 " Observer: %s\n" 732 " Observation time: %s\n" 733 " Target center: %s\n" 734 " Target frame: %s\n" 735 " Emission time: %s\n" 736 " Output reference frame: %s\n" 737 " Aberration correction: %s\n" 738 "\n" 739 " Observer-target position (km):\n" 740 " %20.8f %20.8f %20.8f\n" 741 " Observer-target velocity (km/s):\n" 742 " %20.8f %20.8f %20.8f\n" 743 " Light time (s): %20.8f\n", 744 745 refloc, obsrvr, obstim, trgctr, 746 trgref, emitim, outref, abcorr, 747 state0[0], state0[1], state0[2], 748 state0[3], state0[4], state0[5], lt0 ); 749 750 /. 751 Repeat the computation, this time evaluating the 752 earth's orientation at the epoch obtained by 753 subtracting from the observation time the one way 754 light time from the earth's center. 755 756 This is equivalent to looking up the observer-target 757 state using spkezr_c. 758 ./ 759 refloc = "CENTER"; 760 761 spkcpt_c ( trgpos, trgctr, trgref, 762 et, outref, refloc, abcorr, 763 obsrvr, state1, <1 ); 764 765 /. 766 Display the computed state and light time. 767 ./ 768 timout_c ( et-lt1, TIMFMT, TIMLEN, emitim ); 769 770 printf ( "\n\n" 771 " Frame evaluation locus: %s\n" 772 "\n" 773 " Observer: %s\n" 774 " Observation time: %s\n" 775 " Target center: %s\n" 776 " Target frame: %s\n" 777 " Emission time: %s\n" 778 " Output reference frame: %s\n" 779 " Aberration correction: %s\n" 780 "\n" 781 " Observer-target position (km):\n" 782 " %20.8f %20.8f %20.8f\n" 783 " Observer-target velocity (km/s):\n" 784 " %20.8f %20.8f %20.8f\n" 785 " Light time (s): %20.8f\n", 786 787 refloc, obsrvr, obstim, trgctr, 788 trgref, emitim, outref, abcorr, 789 state1[0], state1[1], state1[2], 790 state1[3], state1[4], state1[5], lt0 ); 791 792 printf ( "\n" 793 " Distance between above positions (km): " 794 " %20.8f\n" 795 " Velocity difference magnitude (km/s):" 796 " %20.8f\n", 797 vdist_c( state0, state1 ), 798 vdist_c( state0+3, state1+3 ) ); 799 800 /. 801 Check: compare the state computed directly above 802 to one produced by spkezr_c: 803 ./ 804 target = "DSS-14"; 805 806 spkezr_c ( target, et, outref, abcorr, 807 obsrvr, state2, <2 ); 808 809 printf ( "\n\n" 810 " State computed using spkezr_c:\n" 811 "\n" 812 " Observer: %s\n" 813 " Observation time: %s\n" 814 " Target: %s\n" 815 " Output reference frame: %s\n" 816 " Aberration correction: %s\n" 817 "\n" 818 " Observer-target position (km):\n" 819 " %20.8f %20.8f %20.8f\n" 820 " Observer-target velocity (km/s):\n" 821 " %20.8f %20.8f %20.8f\n" 822 " Light time (s): %20.8f\n", 823 824 obsrvr, obstim, target, 825 outref, abcorr, 826 state2[0], state2[1], state2[2], 827 state2[3], state2[4], state2[5], lt2 ); 828 829 printf ( "\n" 830 " Distance between last two " 831 "positions (km): %20.8f\n" 832 " Velocity difference magnitude " 833 " (km/s): %20.8f\n", 834 vdist_c( state1, state2 ), 835 vdist_c( state1+3, state2+3 ) ); 836 837 /. 838 Finally, compute an observer-target state in 839 a frame centered at the observer. 840 The reference frame will be that of the 841 MGS MOC NA camera. 842 843 In this case we'll use as the target the surface 844 intercept on Mars of the camera boresight. This 845 allows us to easily verify the correctness of 846 the results returned by spkcpt_c. 847 848 Get camera frame and FOV parameters. We'll need 849 the camera ID code first. 850 ./ 851 bodn2c_c ( CAMERA, &camid, &found ); 852 853 if ( !found ) 854 { 855 printf ( "Camera name could not be mapped " 856 "to an ID code.\n" ); 857 exit( 1 ); 858 } 859 860 /. 861 getfov_c will return the name of the camera-fixed frame 862 in the string `camref', the camera boresight vector in 863 the array `bsight', and the FOV corner vectors in the 864 array `bounds'. All we're going to use are the camera 865 frame name and camera boresight. 866 ./ 867 getfov_c ( camid, MAXBND, SHAPLN, FRNMLN, 868 shape, camref, bsight, &n, bounds ); 869 870 /. 871 Find the camera boresight surface intercept. 872 ./ 873 874 trgctr = "MARS"; 875 trgref = "IAU_MARS"; 876 877 sincpt_c ( "Ellipsoid", trgctr, et, trgref, 878 abcorr, obsrvr, camref, bsight, 879 spoint, &trgepc, srfvec, &found ); 880 881 outref = camref; 882 883 refloc = "OBSERVER"; 884 885 spkcpt_c ( spoint, trgctr, trgref, 886 et, outref, refloc, abcorr, 887 obsrvr, state3, <3 ); 888 889 /. 890 Convert the emission time and the target state 891 evaluation epoch to strings for output. 892 ./ 893 timout_c ( et-lt3, TIMFMT, TIMLEN, emitim ); 894 895 printf ( "\n\n" 896 " Frame evaluation locus: %s\n" 897 "\n" 898 " Observer: %s\n" 899 " Observation time: %s\n" 900 " Target center: %s\n" 901 " Target frame: %s\n" 902 " Emission time: %s\n" 903 " Output reference frame: %s\n" 904 " Aberration correction: %s\n" 905 "\n" 906 " Observer-target position (km):\n" 907 " %20.8f %20.8f %20.8f\n" 908 " Observer-target velocity (km/s):\n" 909 " %20.8f %20.8f %20.8f\n" 910 " Light time (s): %20.8f\n" 911 " Target range from sincpt_c (km): " 912 " %20.8f\n", 913 914 refloc, obsrvr, obstim, trgctr, 915 trgref, emitim, outref, abcorr, 916 state3[0], state3[1], state3[2], 917 state3[3], state3[4], state3[5], lt3, 918 vnorm_c( srfvec ) ); 919 920 return ( 0 ); 921 } 922 923 924 When this program was executed on a PC/Linux/gcc 925 platform, the output was: 926 927 928 Frame evaluation locus: TARGET 929 930 Observer: MGS 931 Observation time: 2003 OCT 13 06:00:00.000000 UTC 932 Target center: EARTH 933 Target frame: ITRF93 934 Emission time: 2003 OCT 13 05:55:44.232914 UTC 935 Output reference frame: ITRF93 936 Aberration correction: CN+S 937 938 Observer-target position (km): 939 52746468.84243592 52367725.79653772 18836142.68957234 940 Observer-target velocity (km/s): 941 3823.39593314 -3840.60002121 2.21337692 942 Light time (s): 255.76708533 943 944 945 Frame evaluation locus: CENTER 946 947 Observer: MGS 948 Observation time: 2003 OCT 13 06:00:00.000000 UTC 949 Target center: EARTH 950 Target frame: ITRF93 951 Emission time: 2003 OCT 13 05:55:44.232914 UTC 952 Output reference frame: ITRF93 953 Aberration correction: CN+S 954 955 Observer-target position (km): 956 52746419.34648802 52367775.65036674 18836142.68969753 957 Observer-target velocity (km/s): 958 3823.40103499 -3840.59789000 2.21337692 959 Light time (s): 255.76708533 960 961 Distance between above positions (km): 70.25135676 962 Velocity difference magnitude (km/s): 0.00552910 963 964 965 State computed using spkezr_c: 966 967 Observer: MGS 968 Observation time: 2003 OCT 13 06:00:00.000000 UTC 969 Target: DSS-14 970 Output reference frame: ITRF93 971 Aberration correction: CN+S 972 973 Observer-target position (km): 974 52746419.34641990 52367775.65039122 18836142.68968301 975 Observer-target velocity (km/s): 976 3823.40103499 -3840.59789000 2.21337692 977 Light time (s): 255.76708533 978 979 Distance between last two positions (km): 0.00007383 980 Velocity difference magnitude (km/s): 0.00000000 981 982 983 Frame evaluation locus: OBSERVER 984 985 Observer: MGS 986 Observation time: 2003 OCT 13 06:00:00.000000 UTC 987 Target center: MARS 988 Target frame: IAU_MARS 989 Emission time: 2003 OCT 13 05:59:59.998702 UTC 990 Output reference frame: MGS_MOC_NA 991 Aberration correction: CN+S 992 993 Observer-target position (km): 994 0.00000001 -0.00000001 388.97573572 995 Observer-target velocity (km/s): 996 2.91968665 0.15140014 0.92363513 997 Light time (s): 0.00129748 998 Target range from sincpt_c (km): 388.97573572 999 1000 1001 -Restrictions 1002 1003 1) This routine may not be suitable for work with stars or other 1004 objects having large distances from the observer, due to loss 1005 of precision in position vectors. 1006 1007 -Literature_References 1008 1009 None. 1010 1011 -Author_and_Institution 1012 1013 N.J. Bachman (JPL) 1014 S.C. Krening (JPL) 1015 B.V. Semenov (JPL) 1016 1017 -Version 1018 1019 -CSPICE Version 1.0.1, 09-SEP-2015 (NJB) 1020 1021 The Exceptions section of the header was updated 1022 to mention exceptions involving null pointers and 1023 empty input strings. 1024 1025 -CSPICE Version 1.0.0, 27-MAR-2012 (NJB) (SCK) (BVS) 1026 1027 -Index_Entries 1028 1029 state of constant_velocity_target 1030 state of surface_point on extended_object 1031 state of landmark on extended_object 1032 1033 -& 1034 */ 1035 1036 { /* Begin spkcpt_c */ 1037 1038 1039 /* 1040 Participate in error tracing. 1041 */ 1042 chkin_c ( "spkcpt_c" ); 1043 1044 /* 1045 Check the input state pointer. 1046 */ 1047 CHKPTR ( CHK_STANDARD, "spkcpt_c", trgpos ); 1048 1049 /* 1050 Check the input strings. 1051 */ 1052 CHKFSTR ( CHK_STANDARD, "spkcpt_c", trgctr ); 1053 CHKFSTR ( CHK_STANDARD, "spkcpt_c", trgref ); 1054 CHKFSTR ( CHK_STANDARD, "spkcpt_c", outref ); 1055 CHKFSTR ( CHK_STANDARD, "spkcpt_c", refloc ); 1056 CHKFSTR ( CHK_STANDARD, "spkcpt_c", abcorr ); 1057 CHKFSTR ( CHK_STANDARD, "spkcpt_c", obsrvr ); 1058 1059 /* 1060 Check the output pointers. 1061 */ 1062 CHKPTR ( CHK_STANDARD, "spkcpt_c", state ); 1063 CHKPTR ( CHK_STANDARD, "spkcpt_c", lt ); 1064 1065 /* 1066 Let the f2c'd routine do the work. 1067 */ 1068 spkcpt_ ( ( doublereal * ) trgpos, 1069 ( char * ) trgctr, 1070 ( char * ) trgref, 1071 ( doublereal * ) &et, 1072 ( char * ) outref, 1073 ( char * ) refloc, 1074 ( char * ) abcorr, 1075 ( char * ) obsrvr, 1076 ( doublereal * ) state, 1077 ( doublereal * ) lt, 1078 ( ftnlen ) strlen(trgctr), 1079 ( ftnlen ) strlen(trgref), 1080 ( ftnlen ) strlen(outref), 1081 ( ftnlen ) strlen(refloc), 1082 ( ftnlen ) strlen(abcorr), 1083 ( ftnlen ) strlen(obsrvr) ); 1084 1085 chkout_c ( "spkcpt_c" ); 1086 1087 } /* End spkcpt_c */ 1088