]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud_ladr.cxx
Tweaks for Mips Irix compilers.
[flightgear.git] / src / Cockpit / hud_ladr.cxx
1
2 #include "hud.hxx"
3 #include "panel.hxx"
4
5 #define DO_PANEL_HACK
6
7 //====================== Top of HudLadder Class =======================
8 HudLadder ::   HudLadder(  string name,
9                            int       x,
10                            int       y,
11                            UINT      width,
12                            UINT      height,
13                            float         factr,
14                            FLTFNPTR  ptch_source,
15                            FLTFNPTR  roll_source,
16                            float     span_units,
17                            float     major_div,
18                            float     minor_div,
19                            UINT      screen_hole,
20                            UINT      lbl_pos,
21                            bool      frl_spot,
22                            bool          target,
23                            bool          vel_vec,
24                            bool          drift,
25                            bool          alpha,
26                            bool      energy,
27                            bool      climb,
28                            bool      glide,
29                            float     glide_slope_val,
30                            bool      worm_energy,
31                            bool      waypoint,
32                            bool      working) :
33     dual_instr_item( x, y, width, height,
34                      ptch_source,
35                      roll_source,
36                      working,
37                      HUDS_RIGHT),
38     width_units                 ( (int)(span_units)   ),
39     div_units                   ( (int)(major_div < 0? -major_div: major_div) ),
40     minor_div                   ( (int)(minor_div)    ),
41     label_pos                   ( lbl_pos      ),
42     scr_hole                    ( screen_hole  ),
43     vmax                                ( span_units/2 ),
44     vmin                                ( -vmax        ),
45     factor                              ( factr           ),
46     hudladder_type              ( name            ),
47     frl                                 ( frl_spot              ),
48     velocity_vector             ( vel_vec               ),
49     drift_marker                ( drift                 ),
50     alpha_bracket               ( alpha                 ),
51     energy_marker               ( energy                ),
52     climb_dive_marker   ( climb         ),
53     target_spot                 ( target                ),
54     glide_slope_marker  ( glide                 ),
55     glide_slope                 ( glide_slope_val),
56     energy_worm                 ( worm_energy),
57     waypoint_marker             ( waypoint)
58
59
60 {
61     if( !width_units ) {
62         width_units = 45;
63     }
64 }
65    
66 HudLadder ::  ~HudLadder()
67 {
68 }
69            
70 HudLadder ::
71 HudLadder( const HudLadder & image ) :
72     dual_instr_item             ( (dual_instr_item &) image),
73     width_units                 ( image.width_units   ),
74     div_units                   ( image.div_units     ),
75     label_pos                   ( image.label_pos     ),
76     scr_hole                    ( image.scr_hole      ),
77     vmax                                ( image.vmax ),
78     vmin                                ( image.vmin ),
79     factor                              ( image.factor        ),
80     hudladder_type              ( image.hudladder_type),
81     frl                                 ( image.frl),
82     velocity_vector             ( image.velocity_vector),
83     drift_marker                ( image.drift_marker),
84     alpha_bracket               ( image.alpha_bracket),
85     energy_marker               ( image.energy_marker),
86     climb_dive_marker   ( image.climb_dive_marker),
87     target_spot                 ( image.target_spot),
88     glide_slope_marker  ( image.glide_slope_marker),
89     glide_slope                 ( image.glide_slope),
90     energy_worm                 ( image.energy_worm),
91     waypoint_marker             ( image.waypoint_marker)
92 {
93 }
94 HudLadder & HudLadder ::  operator = ( const HudLadder & rhs )
95 {
96     if( !(this == &rhs)) {
97         (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
98         width_units                     = rhs.width_units;
99         div_units                       = rhs.div_units;
100         label_pos                       = rhs.label_pos;
101         scr_hole                        = rhs.scr_hole;
102         vmax                            = rhs.vmax;
103         vmin                            = rhs.vmin;
104         factor                          = rhs.factor;
105         hudladder_type          = rhs.hudladder_type;
106         frl                                     = rhs.frl;
107         velocity_vector         = rhs.velocity_vector;
108         drift_marker            = rhs.drift_marker;
109         alpha_bracket           = rhs.alpha_bracket;
110         energy_marker           = rhs.energy_marker;
111         climb_dive_marker       = rhs.climb_dive_marker;
112         target_spot                     = rhs.target_spot;
113         glide_slope_marker      = rhs.glide_slope_marker;
114         glide_slope                     = rhs.glide_slope;
115         energy_worm                     = rhs.energy_worm;
116         waypoint_marker         = rhs.waypoint_marker;
117     }
118     return *this;
119 }
120                            
121 //
122 //  Draws a climb ladder in the center of the HUD
123 //
124
125 void HudLadder :: draw( void )
126 {
127
128     float  x_ini,x_ini2;
129     float  x_end,x_end2;
130     float  y;
131     int count;
132     float cosine, sine,xvvr,yvvr,Vxx,Vyy,Vzz,up_vel,ground_vel,actslope;
133     float Axx,Ayy,Azz,total_vel,pot_slope,t1,t2,psi,alpha,pla;
134     float vel_x,vel_y,drift;
135     char     Textaux[8] ;
136     bool  pitch_ladder;
137     bool  climb_dive_ladder;
138     bool  clip_plane;
139
140     GLdouble eqn_top[4] = {0.0,-1.0,0.0,0.0};
141     GLdouble eqn_left[4] = {-1.0,0.0,0.0,100.0};
142     GLdouble eqn_right[4] = {1.0,0.0,0.0,100.0};
143
144     POINT  centroid    = get_centroid();
145     RECT   box         = get_location();
146
147     float   half_span  = box.right / 2.0;
148     float   roll_value = current_ch2();
149     alpha = get_aoa();
150     pla = get_throttleval();
151
152     int lgear,wown,wowm,ilcanclaw,ihook;
153     ilcanclaw = get_iaux1();
154     lgear = get_iaux2();
155     wown = get_iaux3();
156     wowm = get_iaux4();
157     ihook = get_iaux5();
158     
159     float pitch_value = current_ch1() * RAD_TO_DEG;
160         
161     if(hudladder_type=="Climb/Dive Ladder") {
162         pitch_ladder = false;
163         climb_dive_ladder = true;
164         clip_plane = true;
165     }
166     else
167         if(hudladder_type=="Pitch Ladder") {
168             pitch_ladder = true;
169             climb_dive_ladder = false;
170             clip_plane = false;
171         }
172         
173     //**************************************************************
174     glPushMatrix();
175     // define (0,0) as center of screen
176     glTranslatef( centroid.x, centroid.y, 0);
177
178     // OBJECT STATIC RETICLE
179     // TYPE FRL
180     // ATTRIB - ALWAYS
181     // Draw the FRL spot and line
182     if(frl)     {
183 #define FRL_DIAMOND_SIZE 2.0
184         glBegin(GL_LINE_LOOP);
185         glVertex2f( -FRL_DIAMOND_SIZE, 0.0);
186         glVertex2f(0.0, FRL_DIAMOND_SIZE);
187         glVertex2f( FRL_DIAMOND_SIZE, 0.0);
188         glVertex2f(0.0, -FRL_DIAMOND_SIZE);
189         glEnd();
190         glBegin(GL_LINE_STRIP);
191         glVertex2f(0, FRL_DIAMOND_SIZE);
192         glVertex2f(0, 8.0 );
193         glEnd();
194 #undef FRL_DIAMOND_SIZE
195     }
196     // TYPE WATERLINE_MARK (W shaped _    _ )
197     //                                                \/\/
198
199     //****************************************************************    
200     // TYPE TARGET_SPOT
201     // Draw the target spot.
202     if (target_spot)    {
203 #define CENTER_DIAMOND_SIZE 6.0
204         glBegin(GL_LINE_LOOP);
205         glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
206         glVertex2f(0.0, CENTER_DIAMOND_SIZE);
207         glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
208         glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
209         glEnd();
210 #undef CENTER_DIAMOND_SIZE
211     }
212
213     //****************************************************************    
214     //velocity vector reticle - computations
215     if(velocity_vector) {
216         Vxx = get_Vx();
217         Vyy = get_Vy();
218         Vzz = get_Vz();
219         Axx = get_Ax();
220         Ayy = get_Ay();
221         Azz = get_Az();
222         psi = get_heading();
223
224         if (psi > 180.0) psi = psi - 360;
225
226         total_vel = sqrt(Vxx*Vxx + Vyy*Vyy + Vzz*Vzz);
227         ground_vel = sqrt(Vxx*Vxx + Vyy*Vyy);
228         up_vel = Vzz;
229
230         if (ground_vel < 2.0) {
231             if (fabs(up_vel) < 2.0) {
232                 actslope = 0.0;
233             } else {
234                 actslope = (up_vel/fabs(up_vel))*90.0;
235             }
236         } else {
237             actslope = atan(up_vel/ground_vel)*RAD_TO_DEG;
238         }
239
240         xvvr = (((atan2(Vyy,Vxx)*RAD_TO_DEG)-psi)*(640.0/45.0));
241         drift = ((atan2(Vyy,Vxx)*RAD_TO_DEG)-psi);
242         yvvr = ((actslope - pitch_value)*factor);
243         vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
244         vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*(640/45.0);
245         //  printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
246         //****************************************************************    
247         // OBJECT MOVING RETICLE
248         // TYPE - DRIFT MARKER
249         // ATTRIB - ALWAYS
250         // drift marker
251         if(drift_marker)        {
252             glBegin(GL_LINE_STRIP);
253             glVertex2f((xvvr*25/120)-6, -4);
254             glVertex2f(xvvr*25/120, 8);
255             glVertex2f((xvvr*25/120)+6, -4);
256             glEnd();
257         }
258
259         //****************************************************************    
260         // Clipping coordinates for ladder to be input from xml file
261         // Clip hud ladder
262         if (clip_plane) {
263             glClipPlane(GL_CLIP_PLANE0,eqn_top);
264             glEnable(GL_CLIP_PLANE0);
265             glClipPlane(GL_CLIP_PLANE1,eqn_left);
266             glEnable(GL_CLIP_PLANE1);
267             glClipPlane(GL_CLIP_PLANE2,eqn_right);
268             glEnable(GL_CLIP_PLANE2);
269             //      glScissor(-100,-240,200,240);
270             //      glEnable(GL_SCISSOR_TEST);
271         }
272         //****************************************************************    
273         // OBJECT MOVING RETICLE
274         // TYPE VELOCITY VECTOR
275         // ATTRIB - ALWAYS
276         //  velocity vector
277         glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
278         for(count=0; count<50; count++) {             
279             cosine = 6 * cos(count * 2 * FG_PI/50.0); 
280             sine =   6 * sin(count * 2 * FG_PI/50.0); 
281             glVertex2f(cosine+vel_x, sine+vel_y);
282         }     
283         glEnd(); 
284         //velocity vector reticle orientation lines
285         glBegin(GL_LINE_STRIP);
286         glVertex2f(vel_x-12, vel_y);
287         glVertex2f(vel_x-6, vel_y);
288         glEnd();
289         glBegin(GL_LINE_STRIP);
290         glVertex2f(vel_x+12, vel_y);
291         glVertex2f(vel_x+6, vel_y);
292         glEnd();
293         glBegin(GL_LINE_STRIP);
294         glVertex2f(vel_x, vel_y+12);
295         glVertex2f(vel_x, vel_y+6);
296         glEnd();
297
298         // OBJECT MOVING RETICLE
299         // TYPE LINE
300         // ATTRIB - ON CONDITION
301         if (lgear == 1) {
302             // undercarriage status
303             glBegin(GL_LINE_STRIP);
304             glVertex2f(vel_x+8, vel_y);
305             glVertex2f(vel_x+8, vel_y-4);
306             glEnd();
307             // OBJECT MOVING RETICLE
308             // TYPE LINE
309             // ATTRIB - ON CONDITION
310             glBegin(GL_LINE_STRIP);
311             glVertex2f(vel_x-8, vel_y);
312             glVertex2f(vel_x-8, vel_y-4);
313             glEnd();
314             // OBJECT MOVING RETICLE
315             // TYPE LINE
316             // ATTRIB - ON CONDITION
317             glBegin(GL_LINE_STRIP);
318             glVertex2f(vel_x, vel_y-6);
319             glVertex2f(vel_x, vel_y-10);
320             glEnd();
321         }
322
323         // OBJECT MOVING RETICLE
324         // TYPE V
325         // ATTRIB - ON CONDITION
326         if (ihook == 1) {
327             // arrestor hook status
328             glBegin(GL_LINE_STRIP);
329             glVertex2f(vel_x-4, vel_y-8);
330             glVertex2f(vel_x, vel_y-10);
331             glVertex2f(vel_x+4, vel_y-8);
332             glEnd();
333         }
334     }//if velocity_vector
335
336     //***************************************************************
337     // OBJECT MOVING RETICLE
338     // TYPE - SQUARE_BRACKET
339     // ATTRIB - ON CONDITION
340     // alpha bracket
341     if (alpha_bracket)  {
342         if (ihook == 1) {
343             glBegin(GL_LINE_STRIP);
344             glVertex2f(vel_x-20 , vel_y-(16-alpha)*factor);
345             glVertex2f(vel_x-17, vel_y-(16-alpha)*factor);
346             glVertex2f(vel_x-17, vel_y-(14-alpha)*factor);
347             glVertex2f(vel_x-20, vel_y-(14-alpha)*factor);
348             glEnd();
349             glBegin(GL_LINE_STRIP);
350             glVertex2f(vel_x+20 , vel_y-(16-alpha)*factor);
351             glVertex2f(vel_x+17, vel_y-(16-alpha)*factor);
352             glVertex2f(vel_x+17, vel_y-(14-alpha)*factor);
353             glVertex2f(vel_x+20, vel_y-(14-alpha)*factor);
354             glEnd();
355         }
356     }
357     //printf("xvr=%f,yvr=%f,Vx=%f,Vy=%f,Vz=%f\n",xvvr,yvvr,Vx,Vy,Vz);
358     //printf("Ax=%f,Ay=%f,Az=%f\n",Ax,Ay,Az);
359     //****************************************************************  
360     // OBJECT MOVING RETICLE
361     // TYPE ENERGY_MARKERS
362     // ATTRIB - ALWAYS
363     //energy markers - compute potential slope
364     if(energy_marker)   {
365         if (total_vel < 5.0) {
366             t1 = 0;
367             t2 = 0;
368         } else {
369             t1 = up_vel/total_vel;
370             t2 = asin((Vxx*Axx + Vyy*Ayy + Vzz*Azz)/(9.81*total_vel));
371         }
372         pot_slope = ((t2/3)*RAD_TO_DEG)*factor + vel_y;
373         //    if (pot_slope < (vel_y - 45)) pot_slope = vel_y-45;
374         //    if (pot_slope > (vel_y + 45)) pot_slope = vel_y+45;
375
376         //energy markers
377         glBegin(GL_LINE_STRIP);
378         glVertex2f(vel_x-20, pot_slope-5);
379         glVertex2f(vel_x-15, pot_slope);
380         glVertex2f(vel_x-20, pot_slope+5);
381         glEnd();
382         glBegin(GL_LINE_STRIP);
383         glVertex2f(vel_x+20, pot_slope-5);
384         glVertex2f(vel_x+15, pot_slope);
385         glVertex2f(vel_x+20, pot_slope+5);
386         glEnd();
387         if (pla > (105.0/131.0)) {
388             glBegin(GL_LINE_STRIP);
389             glVertex2f(vel_x-24, pot_slope-5);
390             glVertex2f(vel_x-19, pot_slope);
391             glVertex2f(vel_x-24, pot_slope+5);
392             glEnd();
393             glBegin(GL_LINE_STRIP);
394             glVertex2f(vel_x+24, pot_slope-5);
395             glVertex2f(vel_x+19, pot_slope);
396             glVertex2f(vel_x+24, pot_slope+5);
397             glEnd();
398         }
399     }
400     //********************************************************** 
401     // ramp reticle
402     // OBJECT STATIC RETICLE
403     // TYPE LINE
404     // ATTRIB - ON CONDITION
405     if (energy_worm)    {
406         if (ilcanclaw == 1) {
407             glBegin(GL_LINE_STRIP);
408             glVertex2f(-15, -134);
409             glVertex2f(15, -134);
410             glEnd();
411             // OBJECT MOVING RETICLE
412             // TYPE BOX
413             // ATTRIB - ON CONDITION
414             glBegin(GL_LINE_STRIP);
415             glVertex2f(-6, -134);
416             glVertex2f(-6, t2*RAD_TO_DEG*4.0 - 134);
417             glVertex2f(+6, t2*RAD_TO_DEG*4.0 - 134);
418             glVertex2f(6, -134);
419             glEnd();
420             // OBJECT MOVING RETICLE
421             // TYPE DIAMOND
422             // ATTRIB - ON CONDITION
423             glBegin(GL_LINE_LOOP);
424             glVertex2f(-6, actslope*4.0 - 134);
425             glVertex2f(0, actslope*4.0 -134 +3);
426             glVertex2f(6, actslope*4.0 - 134);
427             glVertex2f(0, actslope*4.0 -134 -3);
428             glEnd();
429         }
430     }
431     //*************************************************************
432     // OBJECT MOVING RETICLE
433     // TYPE DIAMOND
434     // ATTRIB - ALWAYS
435     // Draw the locked velocity vector.
436     if(climb_dive_marker)       {
437         glBegin(GL_LINE_LOOP);
438         glVertex2f( -3.0, 0.0+vel_y);
439         glVertex2f(0.0, 6.0+vel_y);
440         glVertex2f( 3.0, 0.0+vel_y);
441         glVertex2f(0.0, -6.0+vel_y);
442         glEnd();
443     }
444
445     //****************************************************************    
446
447     if(climb_dive_ladder) {// CONFORMAL_HUD
448
449         vmin              = pitch_value - (float)width_units;
450         vmax              = pitch_value + (float)width_units; 
451
452         glTranslatef( vel_x, vel_y, 0);
453
454     }
455     else 
456         if (pitch_ladder) {//Default Hud
457
458             vmin              = pitch_value - (float)width_units * 0.5f;
459             vmax              = pitch_value + (float)width_units * 0.5f;
460
461         }
462
463     glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
464     // FRL marker not rotated - this line shifted below
465
466     if( div_units ) {
467   
468         char     TextLadder[8] ;
469         float    label_length ;
470         float    label_height ;
471         float    left ;
472         float    right ;
473         float    bot ;
474         float    top ;
475         float    text_offset = 4.0f ;
476         float    zero_offset;
477                 
478         if(climb_dive_ladder)
479             zero_offset = 50.0f ;
480         else
481             if(pitch_ladder)
482                 zero_offset = 10.0f ;
483                 
484         fntFont *font      = HUDtext->getFont();
485         float    pointsize = HUDtext->getPointSize();
486         float    italic    = HUDtext->getSlant();
487
488         TextList.setFont( HUDtext );
489         TextList.erase();
490         LineList.erase();
491         StippleLineList.erase();
492
493         int last = FloatToInt(vmax)+1;
494         int i    = FloatToInt(vmin);
495
496         if( !scr_hole ) {
497             x_end =  half_span;
498             for( ; i<last ; i++ ) {
499                 
500                 y =  (((float)(i - pitch_value) * factor) + .5f);
501                 if( !(i % div_units ))    {        //  At integral multiple of div
502                 
503                     sprintf( TextLadder, "%d", i );
504                     font->getBBox ( TextLadder, pointsize, italic,
505                                     &left, &right, &bot, &top ) ;
506                     label_length  = right - left;
507                     label_length += text_offset;
508                     label_height  = (top - bot)/2.0f;
509                 
510                     x_ini = -half_span;
511                     
512                     if( i >= 0 ) {
513                         // Make zero point wider on left
514                         if( i == 0 )
515                             x_ini -= zero_offset;
516                         // Zero or above draw solid lines
517                         Line(x_ini, y, x_end, y);
518                     } else {
519                         // Below zero draw dashed lines.
520                         StippleLine(x_ini, y, x_end, y);
521                     }
522                     
523                     // Calculate the position of the left text and write it.
524                     Text( x_ini-label_length, y-label_height, TextLadder );
525                     Text( x_end+text_offset,  y-label_height, TextLadder );
526                 }
527             }
528         }
529         else // if(scr_hole )
530             {    // Draw ladder with space in the middle of the lines
531                 float hole = (float)((scr_hole)/2.0f);
532
533                 x_end = -half_span + hole;
534                 x_ini2= half_span  - hole;
535                 for( ; i<last ; i++ )      {
536
537                     if(hudladder_type=="Pitch Ladder")
538                         y = (((float)(i - pitch_value) * factor) + .5);
539                     else
540                         if(hudladder_type=="Climb/Dive Ladder")
541                             y = (((float)(i - actslope) * factor) + .5);
542
543                     if( !(i % div_units ))    {        //  At integral multiple of div
544
545                         sprintf( TextLadder, "%d", i );
546                         font->getBBox ( TextLadder, pointsize, italic,
547                                         &left, &right, &bot, &top ) ;
548                         label_length  = right - left;
549                         label_length += text_offset;
550                         label_height  = (top - bot)/2.0f;
551                         //                  printf("l %f r %f b %f t %f\n",left, right, bot, top );
552                 
553                         // Start by calculating the points and drawing the
554                         // left side lines.
555                         x_ini = -half_span;
556                         x_end2= half_span;
557                     
558                         if( i >= 0 ) { 
559                             // Make zero point wider on left
560                             if( i == 0 ) {
561                                 x_ini -= zero_offset;
562                                 x_end2 +=zero_offset;
563                             } else {
564                                 if(climb_dive_ladder){
565                                     // Zero or above draw solid lines
566                                     Line(x_end, y-5.0, x_end, y);
567                                     Line(x_ini2, y-5.0, x_ini2, y);
568                                 }
569                             }
570
571                             Line(x_ini, y, x_end, y);
572                             Line(x_ini2, y, x_end2, y);
573
574                         } else {
575                             // Below zero draw dashed lines.
576                             if(climb_dive_ladder) {
577                                 Line(x_end, y+5.0, x_end, y);
578                                 Line(x_ini2, y+5.0, x_ini2, y);
579                             }
580                             StippleLine(x_ini, y, x_end, y);
581                             StippleLine(x_ini2, y, x_end2, y);
582                         }
583                     
584                         // Now calculate the location of the left side label using
585                         Text( x_ini-label_length, y-label_height, TextLadder );
586                         Text (x_end2+text_offset, y-label_height, TextLadder );
587
588                     }
589                 }
590
591                 // OBJECT LADDER MARK
592                 // TYPE LINE
593                 // ATTRIB - ON CONDITION
594                 // draw appraoch glide slope marker
595                 if (glide_slope_marker) {
596                     if (ihook) {
597                         Line(-half_span+15, (glide_slope-actslope)*factor, -half_span + hole, (glide_slope-actslope)*factor);
598                         Line(half_span-15, (glide_slope-actslope)*factor, half_span - hole, (glide_slope-actslope)*factor);
599                     }
600                 }// if glide_slope_marker
601             }
602         TextList.draw();
603
604         glLineWidth(0.2);
605         
606         LineList.draw();
607         
608         glEnable(GL_LINE_STIPPLE);
609         glLineStipple( 1, 0x00FF );
610         StippleLineList.draw( );
611         glDisable(GL_LINE_STIPPLE);
612     }
613     glDisable(GL_CLIP_PLANE0);
614     glDisable(GL_CLIP_PLANE1);
615     glDisable(GL_CLIP_PLANE2);
616     //      glDisable(GL_SCISSOR_TEST);
617     glPopMatrix();
618     //*************************************************************
619     //*************************************************************
620     if(waypoint_marker) {
621         //waypoint marker computation
622         float fromwp_lat,towp_lat,fromwp_lon,towp_lon,dist,delx,dely,hyp,theta,brg;
623
624         fromwp_lon = get_longitude()*DEG_TO_RAD;
625         fromwp_lat = get_latitude()*DEG_TO_RAD;
626         towp_lon = get_aux5()*DEG_TO_RAD;
627         towp_lat = get_aux6()*DEG_TO_RAD;
628
629         dist = acos(sin(fromwp_lat)*sin(towp_lat)+cos(fromwp_lat)*cos(towp_lat)*cos(fabs(fromwp_lon-towp_lon)));
630         delx= towp_lat - fromwp_lat;
631         dely = towp_lon - fromwp_lon;
632         hyp = sqrt(pow(delx,2)+pow(dely,2));
633         if (hyp != 0) {
634             theta = asin(dely/hyp);
635         } else {
636             theta = 0.0;
637         }
638         brg = theta*RAD_TO_DEG;
639         if (brg > 360.0) brg = 0.0;
640         if (delx < 0) brg = 180 - brg;
641
642         //        {Brg  = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
643         //        Brg = Brg * RAD_TO_DEG; }
644         dist = dist*RAD_TO_DEG * 60.0*1852.0; //rad->deg->nm->m
645         // end waypoint marker computation
646         //*********************************************************
647         // OBJECT MOVING RETICLE
648         // TYPE ARROW
649         // waypoint marker
650         if (fabs(brg-psi) > 10.0) {
651             glPushMatrix();
652             glTranslatef( centroid.x, centroid.y, 0);
653             glTranslatef( vel_x, vel_y, 0);
654             glRotatef(brg - psi,0.0,0.0,-1.0);
655             glBegin(GL_LINE_LOOP);
656             glVertex2f(-2.5,20.0);
657             glVertex2f(-2.5,30.0);
658             glVertex2f(-5.0,30.0);
659             glVertex2f(0.0,35.0);
660             glVertex2f(5.0,30.0);
661             glVertex2f(2.5,30.0);
662             glVertex2f(2.5,20.0);
663             glEnd();
664             glPopMatrix();
665         }
666         // waypoint marker on heading scale
667         if (fabs(brg-psi) < 12.0) {
668             glBegin(GL_LINE_LOOP);
669             glVertex2f(((brg-psi)*60/25)+320,240.0);
670             glVertex2f(((brg-psi)*60/25)+326,240.0-4);
671             glVertex2f(((brg-psi)*60/25)+323,240.0-4);
672             glVertex2f(((brg-psi)*60/25)+323,240.0-8);
673             glVertex2f(((brg-psi)*60/25)+317,240.0-8);
674             glVertex2f(((brg-psi)*60/25)+317,240.0-4);
675             glVertex2f(((brg-psi)*60/25)+314,240.0-4);
676             glEnd();
677         }
678         //*************************************************************
679     }// if waypoint_marker
680 }//draw