10 #include <Aircraft/aircraft.hxx>
11 #include <Debug/fg_debug.h>
12 #include <Include/fg_constants.h>
13 #include <Math/fg_random.h>
14 #include <Math/mat3.h>
15 #include <Math/polar3d.hxx>
16 #include <Scenery/scenery.hxx>
17 #include <Time/fg_timer.hxx>
21 //============ Top of fgTBI_instr class member definitions ==============
34 dual_instr_item( x, y, width, height,
39 BankLimit (maxBankAngle),
40 SlewLimit (maxSlipAngle),
45 fgTBI_instr :: ~fgTBI_instr() {}
47 fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
48 dual_instr_item( (const dual_instr_item &) image),
49 BankLimit( image.BankLimit),
50 SlewLimit( image.SlewLimit),
51 scr_hole ( image.scr_hole )
55 fgTBI_instr & fgTBI_instr ::
56 operator = (const fgTBI_instr & rhs )
58 if( !(this == &rhs)) {
59 dual_instr_item::operator = (rhs);
60 BankLimit = rhs.BankLimit;
61 SlewLimit = rhs.SlewLimit;
62 scr_hole = rhs.scr_hole;
68 // Draws a Turn Bank Indicator on the screen
71 void fgTBI_instr :: draw( void )
75 int x_t_inc1, y_t_inc1;
77 int d_bottom_x, d_bottom_y;
78 int d_right_x, d_right_y;
80 int d_left_x, d_left_y;
86 RECT My_box = get_location();
87 POINT centroid = get_centroid();
88 int tee_height = My_box.bottom;
90 // struct fgFLIGHT *f = ¤t_aircraft.flight;
91 double sin_bank, cos_bank;
92 double bank_angle, sideslip_angle;
93 double ss_const; // sideslip angle pixels per rad
95 bank_angle = current_ch2(); // Roll limit +/- 30 degrees
96 if( bank_angle < -FG_PI_2/3 ) {
97 bank_angle = -FG_PI_2/3;
100 if( bank_angle > FG_PI_2/3 ) {
101 bank_angle = FG_PI_2/3;
103 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
104 if( sideslip_angle < -FG_PI/9 ) {
105 sideslip_angle = -FG_PI/9;
108 if( sideslip_angle > FG_PI/9 ) {
109 sideslip_angle = FG_PI/9;
112 // sin_bank = sin( FG_2PI-FG_Phi );
113 // cos_bank = cos( FG_2PI-FG_Phi );
114 sin_bank = sin(FG_2PI-bank_angle);
115 cos_bank = cos(FG_2PI-bank_angle);
117 x_inc1 = (int)(get_span() * cos_bank);
118 y_inc1 = (int)(get_span() * sin_bank);
119 x_inc2 = (int)(scr_hole * cos_bank);
120 y_inc2 = (int)(scr_hole * sin_bank);
122 x_t_inc1 = (int)(tee_height * sin_bank);
123 y_t_inc1 = (int)(tee_height * cos_bank);
126 d_bottom_y = (int)(-scr_hole);
127 d_right_x = (int)(scr_hole);
130 d_top_y = (int)(scr_hole);
131 d_left_x = (int)(-scr_hole);
134 ss_const = (get_span()*2)/(FG_2PI/9); // width represents 40 degrees
136 d_bottom_x += (int)(sideslip_angle*ss_const);
137 d_right_x += (int)(sideslip_angle*ss_const);
138 d_left_x += (int)(sideslip_angle*ss_const);
139 d_top_x += (int)(sideslip_angle*ss_const);
141 inc_b_x = (int)(d_bottom_x*cos_bank-d_bottom_y*sin_bank);
142 inc_b_y = (int)(d_bottom_x*sin_bank+d_bottom_y*cos_bank);
143 inc_r_x = (int)(d_right_x*cos_bank-d_right_y*sin_bank);
144 inc_r_y = (int)(d_right_x*sin_bank+d_right_y*cos_bank);
145 inc_t_x = (int)(d_top_x*cos_bank-d_top_y*sin_bank);
146 inc_t_y = (int)(d_top_x*sin_bank+d_top_y*cos_bank);
147 inc_l_x = (int)(d_left_x*cos_bank-d_left_y*sin_bank);
148 inc_l_y = (int)(d_left_x*sin_bank+d_left_y*cos_bank);
152 drawOneLine( centroid.x - x_inc1, centroid.y - y_inc1, \
153 centroid.x + x_inc1, centroid.y + y_inc1 );
157 drawOneLine( centroid.x - x_inc1, centroid.y - y_inc1, \
158 centroid.x - x_inc2, centroid.y - y_inc2 );
159 drawOneLine( centroid.x + x_inc2, centroid.y + y_inc2, \
160 centroid.x + x_inc1, centroid.y + y_inc1 );
164 drawOneLine( centroid.x + x_inc2, \
165 centroid.y + y_inc2, \
166 centroid.x + x_inc2 + x_t_inc1, \
167 centroid.y + y_inc2 - y_t_inc1 );
168 drawOneLine( centroid.x - x_inc2, \
169 centroid.y - y_inc2, \
170 centroid.x - x_inc2 + x_t_inc1, \
171 centroid.y - y_inc2 - y_t_inc1 );
173 // draw sideslip diamond (it is not yet positioned correctly )
174 drawOneLine( centroid.x + inc_b_x, \
175 centroid.y + inc_b_y, \
176 centroid.x + inc_r_x, \
177 centroid.y + inc_r_y );
178 drawOneLine( centroid.x + inc_r_x, \
179 centroid.y + inc_r_y, \
180 centroid.x + inc_t_x, \
181 centroid.y + inc_t_y );
182 drawOneLine( centroid.x + inc_t_x, \
183 centroid.y + inc_t_y, \
184 centroid.x + inc_l_x, \
185 centroid.y + inc_l_y );
186 drawOneLine( centroid.x + inc_l_x, \
187 centroid.y + inc_l_y, \
188 centroid.x + inc_b_x, \
189 centroid.y + inc_b_y );