• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • ekos
  • guide
gmath.h
Go to the documentation of this file.
1 /* Ekos guide tool
2  Copyright (C) 2012 Andrew Stepanenko
3 
4  Modified by Jasem Mutlaq <mutlaqja@ikarustech.com> for KStars.
5 
6  This application is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10  */
11 
12 #ifndef GMATH_H_
13 #define GMATH_H_
14 
15 #include <stdint.h>
16 #include <sys/types.h>
17 #include "vect.h"
18 #include "matr.h"
19 #include "common.h"
20 
21 class FITSView;
22 
23 typedef struct
24 {
25  int size;
26  double square;
27 }guide_square_t;
28 
29 #define SMART_THRESHOLD 0
30 #define CENTROID_THRESHOLD 1
31 #define AUTO_THRESHOLD 2
32 #define NO_THRESHOLD 3
33 
34 typedef struct
35 {
36  int idx;
37  const char name[32];
38 }square_alg_t;
39 
40 // smart threshold algorithm param
41 // width of outer frame for backgroung calculation
42 #define SMART_FRAME_WIDTH 4
43 // cut-factor above avarage threshold
44 #define SMART_CUT_FACTOR 0.1
45 
46 
47 #define GUIDE_RA 0
48 #define GUIDE_DEC 1
49 #define CHANNEL_CNT 2
50 #define DEFAULT_SQR 1
51 
52 #define MAX_ACCUM_CNT 50
53 extern const guide_square_t guide_squares[];
54 extern const square_alg_t guide_square_alg[];
55 
56 
57 
58 typedef struct
59 {
60  enum type_t
61  {
62  OVR_SQUARE = 1,
63  OVR_RETICLE = 2
64  };
65  int visible;
66  int square_size;
67  point_t square_pos;
68  point_t reticle_axis_ra[2];
69  point_t reticle_axis_dec[2];
70  point_t reticle_pos;
71 }ovr_params_t;
72 
73 
74 // input params
75 class cproc_in_params
76 {
77 public:
78  cproc_in_params();
79  void reset( void );
80 
81  int threshold_alg_idx;
82  double guiding_rate;
83  bool enabled[CHANNEL_CNT];
84  bool average;
85  uint32_t accum_frame_cnt[CHANNEL_CNT];
86  double proportional_gain[CHANNEL_CNT];
87  double integral_gain[CHANNEL_CNT];
88  double derivative_gain[CHANNEL_CNT];
89  int max_pulse_length[CHANNEL_CNT];
90  int min_pulse_length[CHANNEL_CNT];
91 };
92 
93 
94 //output params
95 class cproc_out_params
96 {
97 public:
98  cproc_out_params();
99  void reset( void );
100 
101  double delta[2];
102  GuideDirection pulse_dir[2];
103  int pulse_length[2];
104  double sigma[2];
105 };
106 
107 
108 typedef struct
109 {
110  double focal_ratio;
111  double fov_wd, fov_ht;
112  double focal, aperture;
113 }info_params_t;
114 
115 
116 class cgmath
117 {
118 public:
119  cgmath();
120  virtual ~cgmath();
121 
122  // functions
123  bool set_video_params( int vid_wd, int vid_ht );
124  float *get_data_buffer( int *width, int *height, int *length, int *size );
125  bool set_guider_params( double ccd_pix_wd, double ccd_pix_ht, double guider_aperture, double guider_focal );
126  void get_guider_params( double *ccd_pix_wd, double *ccd_pix_ht, double *guider_aperture, double *guider_focal );
127  bool set_reticle_params( double x, double y, double ang );
128  bool get_reticle_params( double *x, double *y, double *ang ) const;
129  int get_square_index( void ) const;
130  int get_square_algorithm_index( void ) const;
131  void set_square_algorithm( int alg_idx );
132  cproc_in_params *get_in_params( void );
133  void set_in_params( const cproc_in_params *v );
134  const cproc_out_params *get_out_params( void ) const;
135  info_params_t get_info_params( void ) const;
136  uint32_t get_ticks( void ) const;
137  void get_star_drift( double *dx, double *dy ) const;
138  void get_star_screen_pos( double *dx, double *dy ) const;
139  bool reset( void );
140  void set_buffer(float *buffer);
141  void set_image(FITSView *image);
142  FITSView *get_image() { return pimage; }
143 
144  ovr_params_t *prepare_overlays( void );
145  void move_square( double newx, double newy );
146  void resize_square( int size_idx );
147 
148  // proc
149  void start( void );
150  void stop( void );
151  void suspend( bool mode );
152  bool is_suspended( void ) const;
153  bool is_lost_star(void) const;
154  void set_lost_star(bool is_lost);
155  void do_processing( void );
156  static double precalc_proportional_gain( double g_rate );
157  bool calc_and_set_reticle( double start_x, double start_y, double end_x, double end_y );
158  bool calc_and_set_reticle2( double start_ra_x, double start_ra_y, double end_ra_x, double end_ra_y, double start_dec_x, double start_dec_y, double end_dec_x, double end_dec_y);
159  double calc_phi( double start_x, double start_y, double end_x, double end_y ) const;
160 
161 private:
162  // sys...
163  uint32_t ticks; // global channel ticker
164  float *pdata; // pointer to data buffer
165  FITSView *pimage; // pointer to image
166  int video_width, video_height; // video frame dimensions
167  double ccd_pixel_width, ccd_pixel_height, aperture, focal;
168  Matrix ROT_Z;
169  bool preview_mode, suspended, lost_star;
170 
171  // square variables
172  int square_size; // size of analysing square
173  double square_square; // square of guiding rect
174  Vector square_pos; // integer values in double vars.
175  int square_idx; // index in size list
176  int square_alg_idx; // index of threshold algorithm
177 
178  // sky coord. system vars.
179  Vector star_pos; // position of star in reticle coord. system
180  Vector scr_star_pos; // sctreen star position
181  Vector reticle_pos;
182  Vector reticle_orts[2];
183  double reticle_angle;
184 
185  // processing
186  uint32_t channel_ticks[2];
187  uint32_t accum_ticks[2];
188  double *drift[2];
189  double drift_integral[2];
190 
191  // overlays...
192  ovr_params_t overlays;
193  cproc_in_params in_params;
194  cproc_out_params out_params;
195 
196  // stat math...
197  bool do_statistics;
198  double sum, sqr_sum;
199  double delta_prev, sigma_prev, sigma;
200 
201  // proc
202  void do_ticks( void );
203  Vector point2arcsec( const Vector &p ) const;
204  Vector find_star_local_pos( void ) const;
205  void process_axes( void );
206  void calc_square_err( void );
207 
208 };
209 
210 #endif /*GMATH_H_*/
CHANNEL_CNT
#define CHANNEL_CNT
Definition: gmath.h:49
cgmath::~cgmath
virtual ~cgmath()
Definition: gmath.cpp:98
cproc_in_params::average
bool average
Definition: gmath.h:84
cproc_in_params::derivative_gain
double derivative_gain[CHANNEL_CNT]
Definition: gmath.h:88
cproc_in_params::integral_gain
double integral_gain[CHANNEL_CNT]
Definition: gmath.h:87
ovr_params_t::square_size
int square_size
Definition: gmath.h:66
cgmath::get_out_params
const cproc_out_params * get_out_params(void) const
Definition: gmath.cpp:277
cgmath::get_star_drift
void get_star_drift(double *dx, double *dy) const
Definition: gmath.cpp:307
Vector
Definition: vect.h:18
cgmath::get_ticks
uint32_t get_ticks(void) const
Definition: gmath.cpp:301
square_alg_t::idx
int idx
Definition: gmath.h:36
cgmath::set_guider_params
bool set_guider_params(double ccd_pix_wd, double ccd_pix_ht, double guider_aperture, double guider_focal)
Definition: gmath.cpp:150
guide_square_t::size
int size
Definition: gmath.h:25
ovr_params_t::square_pos
point_t square_pos
Definition: gmath.h:67
guide_square_alg
const square_alg_t guide_square_alg[]
Definition: gmath.cpp:37
info_params_t
Definition: gmath.h:108
point_t
Definition: common.h:36
info_params_t::focal
double focal
Definition: gmath.h:112
cproc_in_params::cproc_in_params
cproc_in_params()
Definition: gmath.cpp:1035
GuideDirection
GuideDirection
Definition: indicommon.h:23
FITSView
Definition: fitsview.h:81
cgmath::get_in_params
cproc_in_params * get_in_params(void)
Definition: gmath.cpp:248
cgmath::get_square_algorithm_index
int get_square_algorithm_index(void) const
Definition: gmath.cpp:241
cproc_out_params::reset
void reset(void)
Definition: gmath.cpp:1066
cproc_in_params::min_pulse_length
int min_pulse_length[CHANNEL_CNT]
Definition: gmath.h:90
vect.h
cproc_in_params::max_pulse_length
int max_pulse_length[CHANNEL_CNT]
Definition: gmath.h:89
cgmath::suspend
void suspend(bool mode)
Definition: gmath.cpp:569
cproc_in_params::accum_frame_cnt
uint32_t accum_frame_cnt[CHANNEL_CNT]
Definition: gmath.h:85
cproc_in_params::guiding_rate
double guiding_rate
Definition: gmath.h:82
ovr_params_t::reticle_pos
point_t reticle_pos
Definition: gmath.h:70
cgmath::reset
bool reset(void)
Definition: gmath.cpp:321
cgmath::is_lost_star
bool is_lost_star(void) const
Definition: gmath.cpp:580
guide_squares
const guide_square_t guide_squares[]
Definition: gmath.cpp:29
cproc_out_params::pulse_dir
GuideDirection pulse_dir[2]
Definition: gmath.h:102
cproc_out_params
Definition: gmath.h:95
cgmath::do_processing
void do_processing(void)
Definition: gmath.cpp:889
ovr_params_t::type_t
type_t
Definition: gmath.h:60
cproc_in_params::reset
void reset(void)
Definition: gmath.cpp:1041
cproc_out_params::cproc_out_params
cproc_out_params()
Definition: gmath.cpp:1060
cgmath::set_lost_star
void set_lost_star(bool is_lost)
Definition: gmath.cpp:585
cgmath::is_suspended
bool is_suspended(void) const
Definition: gmath.cpp:575
cproc_out_params::delta
double delta[2]
Definition: gmath.h:101
cgmath::get_star_screen_pos
void get_star_screen_pos(double *dx, double *dy) const
Definition: gmath.cpp:314
cgmath::get_info_params
info_params_t get_info_params(void) const
Definition: gmath.cpp:283
cgmath::resize_square
void resize_square(int size_idx)
Definition: gmath.cpp:362
cgmath::stop
void stop(void)
Definition: gmath.cpp:563
cgmath::move_square
void move_square(double newx, double newy)
Definition: gmath.cpp:339
matr.h
guide_square_t
Definition: gmath.h:23
info_params_t::focal_ratio
double focal_ratio
Definition: gmath.h:110
cgmath::get_data_buffer
float * get_data_buffer(int *width, int *height, int *length, int *size)
Definition: gmath.cpp:135
cgmath
Definition: gmath.h:116
cproc_in_params
Definition: gmath.h:75
cgmath::set_buffer
void set_buffer(float *buffer)
Definition: gmath.cpp:120
Matrix
Definition: matr.h:18
cproc_in_params::threshold_alg_idx
int threshold_alg_idx
Definition: gmath.h:81
cgmath::set_video_params
bool set_video_params(int vid_wd, int vid_ht)
Definition: gmath.cpp:107
ovr_params_t
Definition: gmath.h:58
cgmath::get_reticle_params
bool get_reticle_params(double *x, double *y, double *ang) const
Definition: gmath.cpp:224
guide_square_t::square
double square
Definition: gmath.h:26
cgmath::start
void start(void)
Definition: gmath.cpp:544
cgmath::precalc_proportional_gain
static double precalc_proportional_gain(double g_rate)
Definition: gmath.cpp:417
cproc_out_params::pulse_length
int pulse_length[2]
Definition: gmath.h:103
square_alg_t
Definition: gmath.h:34
cgmath::calc_and_set_reticle2
bool calc_and_set_reticle2(double start_ra_x, double start_ra_y, double end_ra_x, double end_ra_y, double start_dec_x, double start_dec_y, double end_dec_x, double end_dec_y)
Definition: gmath.cpp:442
cgmath::calc_phi
double calc_phi(double start_x, double start_y, double end_x, double end_y) const
Definition: gmath.cpp:497
common.h
cgmath::set_reticle_params
bool set_reticle_params(double x, double y, double ang)
Definition: gmath.cpp:176
cproc_out_params::sigma
double sigma[2]
Definition: gmath.h:104
cgmath::get_square_index
int get_square_index(void) const
Definition: gmath.cpp:235
cgmath::set_in_params
void set_in_params(const cproc_in_params *v)
Definition: gmath.cpp:254
cgmath::get_guider_params
void get_guider_params(double *ccd_pix_wd, double *ccd_pix_ht, double *guider_aperture, double *guider_focal)
Definition: gmath.cpp:167
ovr_params_t::visible
int visible
Definition: gmath.h:65
cproc_in_params::enabled
bool enabled[CHANNEL_CNT]
Definition: gmath.h:83
cgmath::prepare_overlays
ovr_params_t * prepare_overlays(void)
Definition: gmath.cpp:390
cgmath::get_image
FITSView * get_image()
Definition: gmath.h:142
cgmath::calc_and_set_reticle
bool calc_and_set_reticle(double start_x, double start_y, double end_x, double end_y)
Definition: gmath.cpp:426
cgmath::set_image
void set_image(FITSView *image)
Definition: gmath.cpp:125
info_params_t::fov_wd
double fov_wd
Definition: gmath.h:111
cgmath::set_square_algorithm
void set_square_algorithm(int alg_idx)
Definition: gmath.cpp:379
cproc_in_params::proportional_gain
double proportional_gain[CHANNEL_CNT]
Definition: gmath.h:86
cgmath::cgmath
cgmath()
Definition: gmath.cpp:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal