sky: grid - fixed grid at low FOV.
[nova.git] / src / sky / projection.h
blobf26644ba0d44e3bb8f143bf6dc60b8b23c03410f
1 /*
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>
26 #include "render.h"
27 #include "settings.h"
29 #define GRID_DEC_TILES 19
30 #define GRID_RA_TILES 24
32 enum projection_flip {
33 PF_NONE,
34 PF_TB,
35 PF_LR,
36 PF_LR_TB,
39 enum projection_coords {
40 PC_RA_DEC,
41 PC_ALT_AZ,
44 struct projection;
46 struct transform {
47 /* Equatorial coords - RA, DEC */
48 void (*sky_to_proj_equ)(struct projection *projection,
49 struct render_coord *c);
50 void (*proj_to_sky_equ)(struct projection *projection,
51 struct render_coord *c);
52 /* horizontal coords - Alt, Az */
53 void (*sky_to_proj_hrz)(struct projection *projection,
54 struct render_coord *c);
55 void (*proj_to_sky_hrz)(struct projection *projection,
56 struct render_coord *c);
59 struct projection {
61 /* field of view */
62 gdouble centre_ra; /*!< FOV centre RA */
63 gdouble centre_dec; /*!< FOV centre DEC */
64 gdouble centre_1ra; /*!< FOV centre RA */
65 gdouble centre_1dec; /*!< FOV centre DEC */
66 gdouble centre_ra_rad; /*!< FOV centre RA */
67 gdouble centre_dec_rad; /*!< FOV centre DEC */
68 gdouble centre_dec_rad_cos; /*!< FOV centre DEC */
69 gdouble centre_dec_rad_sin; /*!< FOV centre DEC */
70 gdouble fov; /*!< vertical FOV size in degrees */
72 /* sky size */
73 gint sky_width; /*!< Drawing area x size */
74 gint sky_height; /*!< Drawing area y size */
75 gdouble sky_scale; /*!< Rendering scale */
76 gdouble sky_mid_width; /*!< width / 2 */
77 gdouble sky_mid_height; /*!< height / 2 */
79 /* virtual sky clipping box */
80 gdouble clip_mag_faint; /*!< Minimum mag */
81 gdouble clip_mag_bright; /*!< Maximum mag */
83 enum projection_flip flip;
84 enum projection_coords coords;
85 enum projection_coords grid_coords;
87 /* sky pixels per degree scale */
88 gdouble pixels_per_degree; /*!< pixels per degree */
89 gdouble pixels_per_radian; /*!< pixels per radian */
91 /* transforms */
92 gdouble sidereal;
93 struct transform* trans;
95 /* observer */
96 gdouble observer_lat_rad;
97 gdouble observer_lng_rad;
98 gdouble observer_lat_sin;
99 gdouble observer_lat_cos;
100 gdouble hour_angle;
102 /* grid */
103 int grid_tile[GRID_RA_TILES][GRID_DEC_TILES]; /*!< Visible grid subtiles */
106 extern struct transform transform_flip_none;
107 extern struct transform transform_flip_lr;
108 extern struct transform transform_flip_tb;
109 extern struct transform transform_flip_lr_tb;
111 gint projection_set_flip(struct projection *proj, enum projection_flip flip);
112 void projection_fov_bounds(struct projection *proj,
113 struct observer_info *observer);
114 void projection_check_bounds (struct projection* proj);
115 void projection_set_observer(struct projection *proj,
116 struct observer_info *observer);
117 void projection_move_rel_pixels(struct projection *projection,
118 gfloat ra_offset, gfloat dec_offset);
120 static inline int projection_is_visible0(struct projection* projection,
121 struct render_object *r)
123 if (r->coord[0].x < 0 || r->coord[0].x > projection->sky_width)
124 return 0;
125 if (r->coord[0].y < 0 || r->coord[0].y > projection->sky_height)
126 return 0;
127 return 1;
130 static inline int projection_is_visible1(struct projection* projection,
131 struct render_object *r)
133 if (r->coord[1].x < 0 || r->coord[1].x > projection->sky_width)
134 return 0;
135 if (r->coord[1].y < 0 || r->coord[1].y > projection->sky_height)
136 return 0;
137 return 1;
140 #endif