wcs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ wcs_wrap.c: wcs.i
2
+ swig -ruby wcs.i
@@ -0,0 +1,12 @@
1
+ require "mkmf"
2
+
3
+ # configure options:
4
+ # --with-metis-dir=path
5
+ # --with-metis-include=path
6
+ # --with-metis-lib=path
7
+
8
+ dir_config("wcs")
9
+ exit unless have_header("wcs/wcs.h")
10
+ exit unless have_library("wcs")
11
+ $objs = ["wcs_wrap.o"]
12
+ create_makefile("wcs")
@@ -0,0 +1,578 @@
1
+ %module wcs
2
+ %{
3
+ #include "wcs/wcs.h"
4
+ typedef int BOOLEAN;
5
+ %}
6
+ %include "typemaps.i"
7
+ %include "wcs_h.i"
8
+
9
+ %typemap(in) double *cd {
10
+ if (NIL_P($input)) {
11
+ $1 = (double *)0;
12
+ } else {
13
+ /* Get the length of the List */
14
+ int size = RARRAY_LEN($input);
15
+ int i;
16
+ /* Get the first element in memory */
17
+ VALUE *ptr = RARRAY_PTR($input);
18
+ $1 = (double *)malloc((size+1)*sizeof(double));
19
+ for (i=0; i < size; i++, ptr++) {
20
+ /* Convert Ruby Object String to char* */
21
+ $1[i] = NUM2DBL(*ptr);
22
+ }
23
+ }
24
+ }
25
+ %typemap(freearg) double *cd {
26
+ free($1);
27
+ }
28
+
29
+ %extend WorldCoor {
30
+
31
+ WorldCoor( /* set up a WCS structure from arguments */
32
+ double cra, /* Center right ascension in degrees */
33
+ double cdec, /* Center declination in degrees */
34
+ double secpix, /* Number of arcseconds per pixel */
35
+ double xrpix, /* Reference pixel X coordinate */
36
+ double yrpix, /* Reference pixel X coordinate */
37
+ int nxpix, /* Number of pixels along x-axis */
38
+ int nypix, /* Number of pixels along y-axis */
39
+ double rotate, /* Rotation angle (clockwise positive) in degrees */
40
+ int equinox, /* Equinox of coordinates, 1950 and 2000 supported */
41
+ double epoch, /* Epoch of coordinates, used for FK4/FK5 conversion
42
+ * no effect if 0 */
43
+ char *proj) /* Projection */
44
+ {
45
+ struct WorldCoor *v;
46
+ v = wcsxinit( cra, cdec, secpix, xrpix, yrpix, nxpix, nypix,
47
+ rotate, equinox, epoch, proj );
48
+ if (v==NULL) {
49
+ rb_raise(rb_eRuntimeError,"fail to initialize WorldCoor");
50
+ };
51
+ return v;
52
+ }
53
+
54
+ WorldCoor(
55
+ int naxis1, /* Number of pixels along x-axis */
56
+ int naxis2, /* Number of pixels along y-axis */
57
+ char *ctype1, /* FITS WCS projection for axis 1 */
58
+ char *ctype2, /* FITS WCS projection for axis 2 */
59
+ double crpix1, /* Reference pixel coordinates */
60
+ double crpix2, /* Reference pixel coordinates */
61
+ double crval1, /* Coordinate at reference pixel in degrees */
62
+ double crval2, /* Coordinate at reference pixel in degrees */
63
+ double *cd, /* Rotation matrix, used if not NULL */
64
+ double cdelt1, /* scale in degrees/pixel, if cd is NULL */
65
+ double cdelt2, /* scale in degrees/pixel, if cd is NULL */
66
+ double crota, /* Rotation angle in degrees, if cd is NULL */
67
+ int equinox, /* Equinox of coordinates, 1950 and 2000 supported */
68
+ double epoch) /* Epoch of coordinates, for FK4/FK5 conversion */
69
+ {
70
+ struct WorldCoor *v;
71
+ v = wcskinit( naxis1, naxis2, ctype1, ctype2, crpix1, crpix2,
72
+ crval1, crval2, cd, cdelt1, cdelt2, crota, equinox, epoch );
73
+ if (v==NULL) {
74
+ rb_raise(rb_eRuntimeError,"fail to initialize WorldCoor");
75
+ };
76
+ return v;
77
+ }
78
+
79
+ /* WCS data structure initialization subroutines in wcsinit.c */
80
+ WorldCoor( /* set up WCS structure from a FITS image header */
81
+ const char* hstring)
82
+ {
83
+ struct WorldCoor *v;
84
+ v = wcsinit( hstring );
85
+ if (v==NULL) {
86
+ rb_raise(rb_eRuntimeError,"fail to initialize WorldCoor with string");
87
+ };
88
+ return v;
89
+ }
90
+
91
+ WorldCoor( /* set up WCS structure from a FITS image header */
92
+ const char* hstring, /* FITS header */
93
+ const char* wcsname) /* WCS name */
94
+ {
95
+ struct WorldCoor *v;
96
+ v = wcsinitn( hstring, wcsname );
97
+ if (v==NULL) {
98
+ rb_raise(rb_eRuntimeError,"fail to initialize WorldCoor with string");
99
+ };
100
+ return v;
101
+ }
102
+
103
+ ~WorldCoor() {
104
+ wcsfree($self);
105
+ }
106
+
107
+ int wcstype( /* Set projection type from header CTYPEs */
108
+ char *ctype1, /* FITS WCS projection for axis 1 */
109
+ char *ctype2) /* FITS WCS projection for axis 2 */
110
+ {
111
+ return wcstype($self, ctype1, ctype2);
112
+ }
113
+
114
+ %typemap(out) BOOLEAN {
115
+ if ($1)
116
+ $result = Qtrue;
117
+ else
118
+ $result = Qfalse;
119
+ }
120
+
121
+ BOOLEAN iswcs() /* Returns 1 if wcs structure set, else 0 */
122
+ {
123
+ return iswcs($self);
124
+ }
125
+
126
+ BOOLEAN nowcs() /* Returns 0 if wcs structure set, else 1 */
127
+ {
128
+ return nowcs($self);
129
+ }
130
+
131
+
132
+ VALUE pix2wcst( /* Convert pixel coordinates to World Coordinate string */
133
+ double xpix, /* Image horizontal coordinate in pixels */
134
+ double ypix) /* Image vertical coordinate in pixels */
135
+ //char *wcstring, /* World coordinate string (returned) */
136
+ //int lstr) /* Length of world coordinate string (returned) */
137
+ {
138
+ volatile VALUE str = Qnil;
139
+ char wcstring[51];
140
+ int r;
141
+ wcstring[50] = '\0';
142
+ r = pix2wcst($self, xpix, ypix, wcstring, 50);
143
+ str = rb_str_new2(wcstring);
144
+ if (r==0) {
145
+ rb_raise(rb_eRuntimeError,"fail to convert pixel coordinates to World Coordinate string");
146
+ }
147
+ return str;
148
+ }
149
+
150
+ %apply double *OUTPUT {
151
+ double *xpix, /* Image horizontal coordinate in pixels (returned) */
152
+ double *ypix, /* Image vertical coordinate in pixels (returned) */
153
+ double *xpos, /* Longitude/Right Ascension in degrees (returned) */
154
+ double *ypos /* Latitude/Declination in degrees (returned) */
155
+ }
156
+ %apply int *OUTPUT {
157
+ int *offscl
158
+ }
159
+
160
+ void pix2wcs ( /* Convert pixel coordinates to World Coordinates */
161
+ double xpix, /* Image horizontal coordinate in pixels */
162
+ double ypix, /* Image vertical coordinate in pixels */
163
+ double *xpos, /* Longitude/Right Ascension in degrees (returned) */
164
+ double *ypos) /* Latitude/Declination in degrees (returned) */
165
+ {
166
+ pix2wcs($self, xpix, ypix, xpos, ypos);
167
+ }
168
+
169
+ void wcsc2pix ( /* Convert World Coordinates to pixel coordinates */
170
+ double xpos, /* Longitude/Right Ascension in degrees */
171
+ double ypos, /* Latitude/Declination in degrees */
172
+ char *coorsys, /* Coordinate system (B1950, J2000, etc) */
173
+ double *xpix, /* Image horizontal coordinate in pixels (returned) */
174
+ double *ypix, /* Image vertical coordinate in pixels (returned) */
175
+ int *offscl)
176
+ {
177
+ wcsc2pix($self, xpos, ypos, coorsys, xpix, ypix, offscl);
178
+ }
179
+
180
+ void wcs2pix ( /* Convert World Coordinates to pixel coordinates */
181
+ double xpos, /* Longitude/Right Ascension in degrees */
182
+ double ypos, /* Latitude/Declination in degrees */
183
+ double *xpix, /* Image horizontal coordinate in pixels (returned) */
184
+ double *ypix, /* Image vertical coordinate in pixels (returned) */
185
+ int *offscl)
186
+ {
187
+ wcs2pix($self, xpos, ypos, xpix, ypix, offscl);
188
+ }
189
+
190
+
191
+ void wcsshift( /* Change center of WCS */
192
+ double cra, /* New center right ascension in degrees */
193
+ double cdec, /* New center declination in degrees */
194
+ char *coorsys) /* FK4 or FK5 coordinates (1950 or 2000) */
195
+ {
196
+ wcsshift($self, cra, cdec, coorsys);
197
+ }
198
+
199
+ %apply double *OUTPUT {
200
+ double *cra, /* Right ascension of image center (deg) (returned) */
201
+ double *cdec, /* Declination of image center (deg) (returned) */
202
+ double *width, /* Width in degrees (returned) */
203
+ double *height, /* Height in degrees (returned) */
204
+ double *dra, /* Half-width in right ascension (deg) (returned) */
205
+ double *ddec /* Half-width in declination (deg) (returned) */
206
+ }
207
+
208
+ void wcsfull( /* Return RA and Dec of image center, size in degrees */
209
+ double *cra, /* Right ascension of image center (deg) (returned) */
210
+ double *cdec, /* Declination of image center (deg) (returned) */
211
+ double *width, /* Width in degrees (returned) */
212
+ double *height) /* Height in degrees (returned) */
213
+ {
214
+ wcsfull($self, cra, cdec, width, height);
215
+ }
216
+
217
+ void wcscent() /* Print the image center and size in WCS units */
218
+ {
219
+ wcscent($self);
220
+ }
221
+
222
+ void wcssize( /* Return image center and size in RA and Dec */
223
+ double *cra, /* Right ascension of image center (deg) (returned) */
224
+ double *cdec, /* Declination of image center (deg) (returned) */
225
+ double *dra, /* Half-width in right ascension (deg) (returned) */
226
+ double *ddec) /* Half-width in declination (deg) (returned) */
227
+ {
228
+ wcssize($self, cra, cdec, dra, ddec);
229
+ }
230
+
231
+ %apply double *OUTPUT {
232
+ double *ora1, /* Min. right ascension of image (deg) (returned) */
233
+ double *ora2, /* Max. right ascension of image (deg) (returned) */
234
+ double *odec1, /* Min. declination of image (deg) (returned) */
235
+ double *odec2 /* Max. declination of image (deg) (returned) */
236
+ }
237
+
238
+ void wcsrange( /* Return min and max RA and Dec of image in degrees */
239
+ double *ora1, /* Min. right ascension of image (deg) (returned) */
240
+ double *ora2, /* Max. right ascension of image (deg) (returned) */
241
+ double *odec1, /* Min. declination of image (deg) (returned) */
242
+ double *odec2) /* Max. declination of image (deg) (returned) */
243
+ {
244
+ wcsrange($self,ora1,ora2,odec1,odec2);
245
+ }
246
+
247
+ %typemap(in) double *cd {
248
+ if (NIL_P($input)) {
249
+ $1 = (double *)0;
250
+ } else {
251
+ /* Get the length of the List */
252
+ int size = RARRAY_LEN($input);
253
+ int i;
254
+ /* Get the first element in memory */
255
+ VALUE *ptr = RARRAY_PTR($input);
256
+ $1 = (double *)malloc((size+1)*sizeof(double));
257
+ for (i=0; i < size; i++, ptr++) {
258
+ /* Convert Ruby Object String to char* */
259
+ $1[i] = NUM2DBL(*ptr);
260
+ }
261
+ }
262
+ }
263
+ %typemap(freearg) double *cd {
264
+ free($1);
265
+ }
266
+
267
+ void wcscdset( /* Set scaling and rotation from CD matrix */
268
+ double *cd) /* CD matrix, ignored if NULL */
269
+ {
270
+ wcscdset($self,cd);
271
+ }
272
+
273
+ void wcsdeltset( /* set scaling, rotation from CDELTi, CROTA2 */
274
+ double cdelt1, /* degrees/pixel in first axis (or both axes) */
275
+ double cdelt2, /* degrees/pixel in second axis if nonzero */
276
+ double crota) /* Rotation counterclockwise in degrees */
277
+ {
278
+ wcsdeltset($self,cdelt1,cdelt2,crota);
279
+ }
280
+
281
+ void wcspcset( /* set scaling, rotation from CDELTs and PC matrix */
282
+ double cdelt1, /* degrees/pixel in first axis (or both axes) */
283
+ double cdelt2, /* degrees/pixel in second axis if nonzero */
284
+ double *pc) /* Rotation matrix, ignored if NULL */
285
+ {
286
+ wcspcset($self,cdelt1,cdelt2,pc);
287
+ }
288
+
289
+
290
+ char *getradecsys() /* Return name of image coordinate system */
291
+ {
292
+ return getradecsys($self);
293
+ }
294
+
295
+ void wcsoutinit( /* Set output coordinate system for pix2wcs */
296
+ char *coorsys) /* Coordinate system (B1950, J2000, etc) */
297
+ {
298
+ wcsoutinit($self,coorsys);
299
+ }
300
+
301
+ char *getwcsout() /* Return current output coordinate system */
302
+ {
303
+ return getwcsout($self);
304
+ }
305
+
306
+ void wcsininit( /* Set input coordinate system for wcs2pix */
307
+ char *coorsys) /* Coordinate system (B1950, J2000, etc) */
308
+ {
309
+ wcsininit($self,coorsys);
310
+ }
311
+
312
+ char *getwcsin() /* Return current input coordinate system */
313
+ {
314
+ return getwcsin($self);
315
+ }
316
+
317
+ int setwcsdeg( /* Set WCS coordinate output format */
318
+ int degout) /* 1= degrees, 0= hh:mm:ss dd:mm:ss */
319
+ {
320
+ return setwcsdeg($self,degout);
321
+ }
322
+
323
+ int wcsndec( /* Set or get number of output decimal places */
324
+ int ndec) /* Number of decimal places in output string
325
+ if < 0, return current ndec unchanged */
326
+ {
327
+ return wcsndec($self,ndec);
328
+ }
329
+
330
+ int wcsreset( /* Change WCS using arguments */
331
+ double crpix1, /* Horizontal reference pixel */
332
+ double crpix2, /* Vertical reference pixel */
333
+ double crval1, /* Reference pixel horizontal coordinate in degrees */
334
+ double crval2, /* Reference pixel vertical coordinate in degrees */
335
+ double cdelt1, /* Horizontal scale in degrees/pixel, ignored if cd is not NULL */
336
+ double cdelt2, /* Vertical scale in degrees/pixel, ignored if cd is not NULL */
337
+ double crota, /* Rotation angle in degrees, ignored if cd is not NULL */
338
+ double *cd) /* Rotation matrix, used if not NULL */
339
+ {
340
+ return wcsreset($self,crpix1,crpix2,crval1,crval2,cdelt1,cdelt2,crota,cd);
341
+ }
342
+
343
+ void wcseqset( /* Change equinox of reference pixel coordinates in WCS */
344
+ double equinox) /* Desired equinox as fractional year */
345
+ {
346
+ wcseqset($self,equinox);
347
+ }
348
+
349
+ void setwcslin( /* Set pix2wcst() mode for LINEAR coordinates */
350
+ int mode) /* 0: x y linear, 1: x units x units
351
+ 2: x y linear units */
352
+ {
353
+ setwcslin($self,mode);
354
+ }
355
+
356
+ int wcszout () /* Return coordinate in third dimension */
357
+ {
358
+ return wcszout($self);
359
+ }
360
+
361
+ }; // end of WorldCoor
362
+
363
+
364
+ double wcsdist( /* Compute angular distance between 2 sky positions */
365
+ double ra1, /* First longitude/right ascension in degrees */
366
+ double dec1, /* First latitude/declination in degrees */
367
+ double ra2, /* Second longitude/right ascension in degrees */
368
+ double dec2) /* Second latitude/declination in degrees */
369
+ {
370
+ return wcsdist($self, ra1, dec1, ra2, dec2);
371
+ }
372
+
373
+ double wcsdiff( /* Compute angular distance between 2 sky positions */
374
+ double ra1, /* First longitude/right ascension in degrees */
375
+ double dec1, /* First latitude/declination in degrees */
376
+ double ra2, /* Second longitude/right ascension in degrees */
377
+ double dec2) /* Second latitude/declination in degrees */
378
+ {
379
+ return wcsdiff($self, ra1, dec1, ra2, dec2);
380
+ }
381
+
382
+ void setwcserr( /* Set WCS error message for later printing */
383
+ char *errmsg); /* Error mesage < 80 char */
384
+
385
+ void wcserr(void); /* Print WCS error message to stderr */
386
+
387
+ void setdefwcs( /* Set flag to use AIPS WCS instead of WCSLIB */
388
+ int oldwcs); /* 1 for AIPS WCS subroutines, else WCSLIB */
389
+
390
+ int getdefwcs(void); /* Return flag for AIPS WCS set by setdefwcs */
391
+
392
+ int wcszin( /* Set third dimension for cube projections */
393
+ int izpix); /* Set coordinate in third dimension (face) */
394
+
395
+ void setwcsfile( /* Set filename for WCS error message */
396
+ char *filename); /* FITS or IRAF file name */
397
+
398
+
399
+ //%typemap(in) char **header {
400
+ // int size;
401
+ // char *str;
402
+ // char *buf;
403
+ // size = RSTRING_LEN($input);
404
+ // str = StringValuePtr($input);
405
+ // buf = (char*)malloc(size+1);
406
+ // strncpy(buf, str, size);
407
+ // $1 = &(buf);
408
+ // puts("pass 1");
409
+ // }
410
+ //
411
+ //%typemap(freearg) char **header {
412
+ // free(*$1);
413
+ // }
414
+ // int cpwcs ( /* Copy WCS keywords with no suffix to ones with suffix */
415
+ // char **header, /* Pointer to start of FITS header */
416
+ // char *cwcs); /* Keyword suffix character for output WCS */
417
+
418
+ void savewcscoor( /* Save output coordinate system */
419
+ char *wcscoor); /* coordinate system (J2000, B1950, galactic) */
420
+
421
+ char *getwcscoor(void); /* Return output coordinate system */
422
+
423
+
424
+ /* Coordinate conversion subroutines in wcscon.c */
425
+
426
+ %apply double *INOUT {
427
+ double *dtheta, /* Longitude or right ascension in degrees
428
+ Input in sys1, returned in sys2 */
429
+ double *dphi, /* Latitude or declination in degrees
430
+ Input in sys1, returned in sys2 */
431
+ double *ptheta, /* Longitude or right ascension proper motion in deg/year
432
+ Input in sys1, returned in sys2 */
433
+ double *pphi, /* Latitude or declination proper motion in deg/year */
434
+ double *px, /* Parallax in arcseconds */
435
+ double *rv, /* Radial velocity in km/sec */
436
+ double *io_ra, /* Right ascension in degrees (B1950 in, J2000 out) */
437
+ double *io_dec /* Declination in degrees (B1950 in, J2000 out) */
438
+ }
439
+
440
+ void wcsconv( /* Convert between coordinate systems and equinoxes */
441
+ int sys1, /* Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC */
442
+ int sys2, /* Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC */
443
+ double eq1, /* Input equinox (default of sys1 if 0.0) */
444
+ double eq2, /* Output equinox (default of sys2 if 0.0) */
445
+ double ep1, /* Input Besselian epoch in years */
446
+ double ep2, /* Output Besselian epoch in years */
447
+ double *dtheta, /* Longitude or right ascension in degrees
448
+ Input in sys1, returned in sys2 */
449
+ double *dphi, /* Latitude or declination in degrees
450
+ Input in sys1, returned in sys2 */
451
+ double *ptheta, /* Longitude or right ascension proper motion in deg/year
452
+ Input in sys1, returned in sys2 */
453
+ double *pphi, /* Latitude or declination proper motion in deg/year */
454
+ double *px, /* Parallax in arcseconds */
455
+ double *rv); /* Radial velocity in km/sec */
456
+
457
+ void wcsconp( /* Convert between coordinate systems and equinoxes */
458
+ int sys1, /* Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC */
459
+ int sys2, /* Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC */
460
+ double eq1, /* Input equinox (default of sys1 if 0.0) */
461
+ double eq2, /* Output equinox (default of sys2 if 0.0) */
462
+ double ep1, /* Input Besselian epoch in years */
463
+ double ep2, /* Output Besselian epoch in years */
464
+ double *dtheta, /* Longitude or right ascension in degrees
465
+ Input in sys1, returned in sys2 */
466
+ double *dphi, /* Latitude or declination in degrees
467
+ Input in sys1, returned in sys2 */
468
+ double *ptheta, /* Longitude or right ascension proper motion in degrees/year
469
+ Input in sys1, returned in sys2 */
470
+ double *pphi); /* Latitude or declination proper motion in degrees/year
471
+ Input in sys1, returned in sys2 */
472
+
473
+ void wcscon( /* Convert between coordinate systems and equinoxes */
474
+ int sys1, /* Input coordinate system (J2000, B1950, ECLIPTIC, GALACTIC */
475
+ int sys2, /* Output coordinate system (J2000, B1950, ECLIPTIC, G ALACTIC */
476
+ double eq1, /* Input equinox (default of sys1 if 0.0) */
477
+ double eq2, /* Output equinox (default of sys2 if 0.0) */
478
+ double *dtheta, /* Longitude or right ascension in degrees
479
+ Input in sys1, returned in sys2 */
480
+ double *dphi, /* Latitude or declination in degrees
481
+ Input in sys1, returned in sys2 */
482
+ double epoch); /* Besselian epoch in years */
483
+
484
+ void fk425e ( /* Convert B1950(FK4) to J2000(FK5) coordinates */
485
+ double *io_ra, /* Right ascension in degrees (B1950 in, J2000 out) */
486
+ double *io_dec, /* Declination in degrees (B1950 in, J2000 out) */
487
+ double epoch); /* Besselian epoch in years */
488
+
489
+ void fk524e ( /* Convert J2000(FK5) to B1950(FK4) coordinates */
490
+ double *io_ra, /* Right ascension in degrees (J2000 in, B1950 out) */
491
+ double *io_dec, /* Declination in degrees (J2000 in, B1950 out) */
492
+ double epoch); /* Besselian epoch in years */
493
+
494
+ int wcscsys( /* Return code for coordinate system in string */
495
+ char *coorsys); /* Coordinate system (B1950, J2000, etc) */
496
+
497
+ double wcsceq ( /* Set equinox from string (return 0.0 if not obvious) */
498
+ char *wcstring_in); /* Coordinate system (B1950, J2000, etc) */
499
+
500
+
501
+ %apply char *OUTPUT {
502
+ char *cstr
503
+ }
504
+ %typemap(in,numinputs=0) char *cstr {
505
+ $1 = malloc(64);
506
+ }
507
+ %typemap(argout) char *cstr {
508
+ $result = rb_str_new2($1);
509
+ }
510
+ %typemap(freearg) char *cstr {
511
+ free($1);
512
+ }
513
+
514
+ void wcscstr ( /* Set coordinate system type string from system and equinox */
515
+ char *cstr, /* Coordinate system string (returned) */
516
+ int syswcs, /* Coordinate system code */
517
+ double equinox, /* Equinox of coordinate system */
518
+ double epoch); /* Epoch of coordinate system */
519
+
520
+ %apply double *OUTPUT {
521
+ double opos[3]
522
+ }
523
+ %typemap(in,numinputs=0) double opos[3] {
524
+ $1 = malloc(sizeof(double)*3);
525
+ }
526
+ %typemap(argout) double opos[3] {
527
+ $result = rb_ary_new();
528
+ rb_ary_push($result, rb_float_new($1[0]));
529
+ rb_ary_push($result, rb_float_new($1[1]));
530
+ rb_ary_push($result, rb_float_new($1[2]));
531
+ }
532
+ %typemap(freearg) double opos[3] {
533
+ free($1);
534
+ }
535
+
536
+ void d2v3 ( /* Convert RA and Dec in degrees and distance to vector */
537
+ double rra, /* Right ascension in degrees */
538
+ double rdec, /* Declination in degrees */
539
+ double r, /* Distance to object in same units as pos */
540
+ double opos[3]); /* x,y,z geocentric equatorial position of object (returned) */
541
+
542
+ void s2v3 ( /* Convert RA and Dec in radians and distance to vector */
543
+ double rra, /* Right ascension in radians */
544
+ double rdec, /* Declination in radians */
545
+ double r, /* Distance to object in same units as pos */
546
+ double opos[3]); /* x,y,z geocentric equatorial position of object (returned) */
547
+
548
+ %apply double *OUTPUT {
549
+ double *rra, /* Right ascension in degrees (returned) */
550
+ double *rdec, /* Declination in degrees (returned) */
551
+ double *r /* Distance to object in same units as pos (returned) */
552
+ }
553
+
554
+ %apply double *INPUT {
555
+ double pos[3]
556
+ }
557
+
558
+ %typemap(in) double pos[3] {
559
+ $1 = malloc(sizeof(double)*3);
560
+ $1[0] = NUM2DBL(RARRAY_PTR($input)[0]);
561
+ $1[1] = NUM2DBL(RARRAY_PTR($input)[2]);
562
+ $1[2] = NUM2DBL(RARRAY_PTR($input)[2]);
563
+ }
564
+ %typemap(freearg) double pos[3] {
565
+ free($1);
566
+ }
567
+
568
+ void v2d3 ( /* Convert vector to RA and Dec in degrees and distance */
569
+ double pos[3], /* x,y,z geocentric equatorial position of object */
570
+ double *rra, /* Right ascension in degrees (returned) */
571
+ double *rdec, /* Declination in degrees (returned) */
572
+ double *r); /* Distance to object in same units as pos (returned) */
573
+
574
+ void v2s3 ( /* Convert vector to RA and Dec in radians and distance */
575
+ double pos[3], /* x,y,z geocentric equatorial position of object */
576
+ double *rra, /* Right ascension in radians (returned) */
577
+ double *rdec, /* Declination in radians (returned) */
578
+ double *r); /* Distance to object in same units as pos (returned) */