2 * Copyright (C) 2008 Liam Girdwood
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __PROJECTION_H
21 #define __PROJECTION_H
23 #include <libnova/ln_types.h>
24 #include <glib-2.0/glib.h>
29 #define PROJ_MAX_RA 360.0
30 #define PROJ_MIN_RA 0.0
32 #define PROJ_MAX_DEC 90
33 #define PROJ_MIN_DEC -90
35 #define PROJ_MIN_FOV 0.5
36 #define PROJ_MAX_FOV 270.0
38 #define GRID_DEC_TILES 18
39 #define GRID_RA_TILES 24
40 #define GRID_DEC_TILE_SIZE ((PROJ_MAX_DEC - PROJ_MIN_DEC) / GRID_DEC_TILES)
41 #define GRID_RA_TILE_SIZE (PROJ_MAX_RA / GRID_RA_TILES)
43 enum projection_flip
{
50 enum projection_coords
{
58 /* Equatorial coords - RA, DEC */
59 void (*sky_to_proj_equ
)(struct projection
*projection
,
60 struct render_coord
*c
);
61 void (*proj_to_sky_equ
)(struct projection
*projection
,
62 struct render_coord
*c
);
63 /* horizontal coords - Alt, Az */
64 void (*sky_to_proj_hrz
)(struct projection
*projection
,
65 struct render_coord
*c
);
66 void (*proj_to_sky_hrz
)(struct projection
*projection
,
67 struct render_coord
*c
);
73 gdouble centre_ra
; /*!< FOV centre RA */
74 gdouble centre_dec
; /*!< FOV centre DEC */
75 gdouble centre_az
; /*!< FOV centre RA */
76 gdouble centre_alt
; /*!< FOV centre DEC */
77 gdouble centre_ra_rad
; /*!< FOV centre RA */
78 gdouble centre_dec_rad
; /*!< FOV centre DEC */
79 gdouble centre_dec_rad_cos
; /*!< FOV centre DEC */
80 gdouble centre_dec_rad_sin
; /*!< FOV centre DEC */
81 gdouble fov
; /*!< vertical FOV size in degrees */
84 gint sky_width
; /*!< Drawing area x size */
85 gint sky_height
; /*!< Drawing area y size */
86 gdouble sky_scale
; /*!< Rendering scale */
87 gdouble sky_mid_width
; /*!< width / 2 */
88 gdouble sky_mid_height
; /*!< height / 2 */
90 /* virtual sky clipping box */
91 gdouble clip_mag_faint
; /*!< Minimum mag */
92 gdouble clip_mag_bright
; /*!< Maximum mag */
94 enum projection_flip flip
;
95 enum projection_coords coords
;
96 enum projection_coords grid_coords
;
98 /* sky pixels per degree scale */
99 gdouble pixels_per_degree
; /*!< pixels per degree */
100 gdouble pixels_per_radian
; /*!< pixels per radian */
104 struct transform
* trans
;
107 gdouble observer_lat_rad
;
108 gdouble observer_lng_rad
;
109 gdouble observer_lat_sin
;
110 gdouble observer_lat_cos
;
114 int grid_tile
[GRID_RA_TILES
][GRID_DEC_TILES
]; /*!< Visible grid subtiles */
117 extern struct transform transform_flip_none
;
118 extern struct transform transform_flip_lr
;
119 extern struct transform transform_flip_tb
;
120 extern struct transform transform_flip_lr_tb
;
122 gint
projection_set_flip(struct projection
*proj
, enum projection_flip flip
);
123 void projection_fov_bounds(struct projection
*proj
,
124 struct observer_info
*observer
);
125 void projection_check_bounds (struct projection
* proj
);
126 void projection_set_observer(struct projection
*proj
,
127 struct observer_info
*observer
);
128 void projection_move_rel_pixels(struct projection
*projection
,
129 gfloat ra_offset
, gfloat dec_offset
);
131 static inline int projection_is_visible0(struct projection
* projection
,
132 struct render_object
*r
)
134 if (r
->coord
[0].x
< 0 || r
->coord
[0].x
> projection
->sky_width
)
136 if (r
->coord
[0].y
< 0 || r
->coord
[0].y
> projection
->sky_height
)
141 static inline int projection_is_visible1(struct projection
* projection
,
142 struct render_object
*r
)
144 if (r
->coord
[1].x
< 0 || r
->coord
[1].x
> projection
->sky_width
)
146 if (r
->coord
[1].y
< 0 || r
->coord
[1].y
> projection
->sky_height
)