1 // HUD_ladder.cxx -- HUD Ladder Instrument
3 // Written by Michele America, started September 1997.
5 // Copyright (C) 1997 Michele F. America [micheleamerica#geocities:com]
6 // Copyright (C) 2006 Melchior FRANZ [mfranz#aon:at]
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <Main/viewer.hxx>
31 float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
32 float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
33 float get__aoa() { return fgGetFloat("/sim/frame-rate"); } // FIXME
34 float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
35 float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
36 float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
37 float get__Ax() { return fgGetFloat("/acclerations/pilot/x-accel-fps_sec"); }
38 float get__Ay() { return fgGetFloat("/acclerations/pilot/y-accel-fps_sec"); }
39 float get__Az() { return fgGetFloat("/acclerations/pilot/z-accel-fps_sec"); }
43 HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
45 _pitch(n->getNode("pitch-input", false)),
46 _roll(n->getNode("roll-input", false)),
47 _width_units(int(n->getFloatValue("display-span"))),
48 div_units(int(fabs(n->getFloatValue("divisions")))),
49 label_pos(n->getIntValue("lbl-pos")),
50 _scr_hole(n->getIntValue("screen-hole")),
51 _compression(n->getFloatValue("compression-factor")),
52 _frl(n->getBoolValue("enable-fuselage-ref-line", false)),
53 _target_spot(n->getBoolValue("enable-target-spot", false)),
54 _velocity_vector(n->getBoolValue("enable-velocity-vector", false)),
55 _drift_marker(n->getBoolValue("enable-drift-marker", false)),
56 _alpha_bracket(n->getBoolValue("enable-alpha-bracket", false)),
57 _energy_marker(n->getBoolValue("enable-energy-marker", false)),
58 _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker", false)),
59 _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker",false)),
60 _glide_slope(n->getFloatValue("glide-slope", -4.0)),
61 _energy_worm(n->getBoolValue("enable-energy-marker", false)),
62 _waypoint_marker(n->getBoolValue("enable-waypoint-marker", false)),
63 _zenith(n->getIntValue("zenith")),
64 _nadir(n->getIntValue("nadir")),
65 _hat(n->getIntValue("hat"))
67 const char *t = n->getStringValue("type");
68 _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
73 _vmax = _width_units / 2;
78 void HUD::Ladder::draw(void)
80 if (!_pitch.isValid() || !_roll.isValid())
87 float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
88 float up_vel, ground_vel, actslope = 0.0;
89 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
90 float t2 = 0.0, psi = 0.0, alpha, pla;
91 float vel_x = 0.0, vel_y = 0.0, drift;
92 bool pitch_ladder = false;
93 bool climb_dive_ladder = false;
94 bool clip_plane = false;
96 GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
97 GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
98 GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
100 Point centroid = get_centroid();
102 float half_span = _w / 2.0;
103 float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS; // FIXME rad/deg conversion
105 pla = get__throttleval();
107 #ifdef ENABLE_SP_FMDS
108 int lgear, wown, wowm, ilcanclaw, ihook;
109 ilcanclaw = get__iaux2();
110 lgear = get__iaux3();
113 ihook = get__iaux6();
115 float pitch_value = _pitch.getFloatValue();
117 if (_type == CLIMB_DIVE) {
118 pitch_ladder = false;
119 climb_dive_ladder = true;
122 } else { // _type == PITCH
124 climb_dive_ladder = false;
128 //**************************************************************
130 // define (0, 0) as center of screen
131 glTranslatef(centroid.x, centroid.y, 0);
133 // OBJECT STATIC RETICLE
134 // TYPE FRL (FUSELAGE REFERENCE LINE)
136 // Draw the FRL spot and line
138 #define FRL_DIAMOND_SIZE 2.0
139 glBegin(GL_LINE_LOOP);
140 glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
141 glVertex2f(0.0, FRL_DIAMOND_SIZE);
142 glVertex2f(FRL_DIAMOND_SIZE, 0.0);
143 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
146 glBegin(GL_LINE_STRIP);
147 glVertex2f(0, FRL_DIAMOND_SIZE);
150 #undef FRL_DIAMOND_SIZE
152 // TYPE WATERLINE_MARK (W shaped _ _ )
155 //****************************************************************
157 // Draw the target spot.
159 #define CENTER_DIAMOND_SIZE 6.0
160 glBegin(GL_LINE_LOOP);
161 glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
162 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
163 glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
164 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
166 #undef CENTER_DIAMOND_SIZE
169 //****************************************************************
170 //velocity vector reticle - computations
171 if (_velocity_vector) {
178 psi = get__heading();
183 total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
184 ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
187 if (ground_vel < 2.0) {
188 if (fabs(up_vel) < 2.0)
191 actslope = (up_vel / fabs(up_vel)) * 90.0;
194 actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
197 xvvr = (((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi)
198 * (_compression / globals->get_current_view()->get_aspect_ratio()));
199 drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
200 yvvr = ((actslope - pitch_value) * _compression);
201 vel_y = ((actslope - pitch_value) * cos(roll_value) + drift * sin(roll_value)) * _compression;
202 vel_x = (-(actslope - pitch_value) * sin(roll_value) + drift * cos(roll_value))
203 * (_compression / globals->get_current_view()->get_aspect_ratio());
204 // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
206 //****************************************************************
207 // OBJECT MOVING RETICLE
208 // TYPE - DRIFT MARKER
212 glBegin(GL_LINE_STRIP);
213 glVertex2f((xvvr * 25 / 120) - 6, -4);
214 glVertex2f(xvvr * 25 / 120, 8);
215 glVertex2f((xvvr * 25 / 120) + 6, -4);
219 //****************************************************************
220 // Clipping coordinates for ladder to be input from xml file
223 glClipPlane(GL_CLIP_PLANE0, eqn_top);
224 glEnable(GL_CLIP_PLANE0);
225 glClipPlane(GL_CLIP_PLANE1, eqn_left);
226 glEnable(GL_CLIP_PLANE1);
227 glClipPlane(GL_CLIP_PLANE2, eqn_right);
228 glEnable(GL_CLIP_PLANE2);
229 // glScissor(-100,-240, 200, 240);
230 // glEnable(GL_SCISSOR_TEST);
233 //****************************************************************
234 // OBJECT MOVING RETICLE
235 // TYPE VELOCITY VECTOR
238 glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
239 for (count = 0; count < 50; count++) {
240 cosine = 6 * cos(count * SGD_2PI / 50.0);
241 sine = 6 * sin(count * SGD_2PI / 50.0);
242 glVertex2f(cosine + vel_x, sine + vel_y);
246 //velocity vector reticle orientation lines
247 glBegin(GL_LINE_STRIP);
248 glVertex2f(vel_x - 12, vel_y);
249 glVertex2f(vel_x - 6, vel_y);
251 glBegin(GL_LINE_STRIP);
252 glVertex2f(vel_x + 12, vel_y);
253 glVertex2f(vel_x + 6, vel_y);
255 glBegin(GL_LINE_STRIP);
256 glVertex2f(vel_x, vel_y + 12);
257 glVertex2f(vel_x, vel_y + 6);
260 #ifdef ENABLE_SP_FMDS
261 // OBJECT MOVING RETICLE
263 // ATTRIB - ON CONDITION
265 // undercarriage status
266 glBegin(GL_LINE_STRIP);
267 glVertex2f(vel_x + 8, vel_y);
268 glVertex2f(vel_x + 8, vel_y - 4);
271 // OBJECT MOVING RETICLE
273 // ATTRIB - ON CONDITION
274 glBegin(GL_LINE_STRIP);
275 glVertex2f(vel_x - 8, vel_y);
276 glVertex2f(vel_x - 8, vel_y - 4);
279 // OBJECT MOVING RETICLE
281 // ATTRIB - ON CONDITION
282 glBegin(GL_LINE_STRIP);
283 glVertex2f(vel_x, vel_y - 6);
284 glVertex2f(vel_x, vel_y - 10);
288 // OBJECT MOVING RETICLE
290 // ATTRIB - ON CONDITION
292 // arrestor hook status
293 glBegin(GL_LINE_STRIP);
294 glVertex2f(vel_x - 4, vel_y - 8);
295 glVertex2f(vel_x, vel_y - 10);
296 glVertex2f(vel_x + 4, vel_y - 8);
300 } // if _velocity_vector
303 //***************************************************************
304 // OBJECT MOVING RETICLE
305 // TYPE - SQUARE_BRACKET
306 // ATTRIB - ON CONDITION
308 #ifdef ENABLE_SP_FMDS
309 if (_alpha_bracket && ihook == 1) {
310 glBegin(GL_LINE_STRIP);
311 glVertex2f(vel_x - 20 , vel_y - (16 - alpha) * _compression);
312 glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
313 glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
314 glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
317 glBegin(GL_LINE_STRIP);
318 glVertex2f(vel_x + 20 , vel_y - (16 - alpha) * _compression);
319 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
320 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
321 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
325 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
326 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
328 //****************************************************************
329 // OBJECT MOVING RETICLE
330 // TYPE ENERGY_MARKERS
332 //energy markers - compute potential slope
333 if (_energy_marker) {
334 if (total_vel < 5.0) {
338 t1 = up_vel / total_vel;
339 t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
341 pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
342 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
343 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
346 glBegin(GL_LINE_STRIP);
347 glVertex2f(vel_x - 20, pot_slope - 5);
348 glVertex2f(vel_x - 15, pot_slope);
349 glVertex2f(vel_x - 20, pot_slope + 5);
352 glBegin(GL_LINE_STRIP);
353 glVertex2f(vel_x + 20, pot_slope - 5);
354 glVertex2f(vel_x + 15, pot_slope);
355 glVertex2f(vel_x + 20, pot_slope + 5);
358 if (pla > (105.0 / 131.0)) {
359 glBegin(GL_LINE_STRIP);
360 glVertex2f(vel_x - 24, pot_slope - 5);
361 glVertex2f(vel_x - 19, pot_slope);
362 glVertex2f(vel_x - 24, pot_slope + 5);
365 glBegin(GL_LINE_STRIP);
366 glVertex2f(vel_x + 24, pot_slope - 5);
367 glVertex2f(vel_x + 19, pot_slope);
368 glVertex2f(vel_x + 24, pot_slope + 5);
373 //**********************************************************
375 // OBJECT STATIC RETICLE
377 // ATTRIB - ON CONDITION
378 #ifdef ENABLE_SP_FMDS
379 if (_energy_worm && ilcanclaw == 1) {
380 glBegin(GL_LINE_STRIP);
381 glVertex2f(-15, -134);
382 glVertex2f(15, -134);
385 // OBJECT MOVING RETICLE
387 // ATTRIB - ON CONDITION
388 glBegin(GL_LINE_STRIP);
389 glVertex2f(-6, -134);
390 glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
391 glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
395 // OBJECT MOVING RETICLE
397 // ATTRIB - ON CONDITION
398 glBegin(GL_LINE_LOOP);
399 glVertex2f(-6, actslope * 4.0 - 134);
400 glVertex2f(0, actslope * 4.0 -134 + 3);
401 glVertex2f(6, actslope * 4.0 - 134);
402 glVertex2f(0, actslope * 4.0 -134 -3);
407 //*************************************************************
408 // OBJECT MOVING RETICLE
411 // Draw the locked velocity vector.
412 if (_climb_dive_marker) {
413 glBegin(GL_LINE_LOOP);
414 glVertex2f(-3.0, 0.0 + vel_y);
415 glVertex2f(0.0, 6.0 + vel_y);
416 glVertex2f(3.0, 0.0 + vel_y);
417 glVertex2f(0.0, -6.0 + vel_y);
421 //****************************************************************
423 if (climb_dive_ladder) { // CONFORMAL_HUD
424 _vmin = pitch_value - _width_units;
425 _vmax = pitch_value + _width_units;
426 glTranslatef(vel_x, vel_y, 0);
428 } else { // pitch_ladder - Default Hud
429 _vmin = pitch_value - _width_units * 0.5f;
430 _vmax = pitch_value + _width_units * 0.5f;
433 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
434 // FRL marker not rotated - this line shifted below
437 const int BUFSIZE = 8;
445 float text_offset = 4.0f;
446 float zero_offset = 0.0;
448 if (climb_dive_ladder)
449 zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
453 fntFont *font = _hud->_font_renderer->getFont(); // FIXME
454 float pointsize = _hud->_font_renderer->getPointSize();
455 float italic = _hud->_font_renderer->getSlant();
457 _locTextList.setFont(_hud->_font_renderer);
458 _locTextList.erase();
459 _locLineList.erase();
460 _locStippleLineList.erase();
462 int last = int(_vmax) + 1;
468 for (; i < last; i++) {
469 y = (i - pitch_value) * _compression + .5f;
471 if (!(i % div_units)) { // At integral multiple of div
472 snprintf(buf, BUFSIZE, "%d", i);
473 font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
474 label_length = right - left;
475 label_length += text_offset;
476 label_height = (top - bot) / 2.0f;
481 // Make zero point wider on left
483 x_ini -= zero_offset;
485 // Zero or above draw solid lines
486 draw_line(x_ini, y, x_end, y);
488 if (i == 90 && _zenith == 1)
489 draw_zenith(x_ini, x_end, y);
491 // Below zero draw dashed lines.
492 draw_stipple_line(x_ini, y, x_end, y);
494 if (i == -90 && _nadir ==1)
495 draw_nadir(x_ini, x_end, y);
498 // Calculate the position of the left text and write it.
499 draw_text(x_ini - label_length, y - label_height, buf);
500 draw_text(x_end + text_offset, y - label_height, buf);
504 } else { // if (_scr_hole)
505 // Draw ladder with space in the middle of the lines
506 float hole = _scr_hole / 2.0f;
508 x_end = -half_span + hole;
509 x_ini2 = half_span - hole;
511 for (; i < last; i++) {
513 y = float(i - pitch_value) * _compression + .5;
514 else // _type == CLIMB_DIVE
515 y = float(i - actslope) * _compression + .5;
517 if (!(i % div_units)) { // At integral multiple of div
518 snprintf(buf, BUFSIZE, "%d", i);
519 font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
520 label_length = right - left;
521 label_length += text_offset;
522 label_height = (top - bot) / 2.0f;
523 // printf("l %f r %f b %f t %f\n",left, right, bot, top);
525 // Start by calculating the points and drawing the
531 // Make zero point wider on left
533 x_ini -= zero_offset;
534 x_end2 += zero_offset;
536 //draw climb bar vertical lines
537 if (climb_dive_ladder) {
538 // Zero or above draw solid lines
539 draw_line(x_end, y - 5.0, x_end, y);
540 draw_line(x_ini2, y - 5.0, x_ini2, y);
542 // draw pitch / climb bar
543 draw_line(x_ini, y, x_end, y);
544 draw_line(x_ini2, y, x_end2, y);
546 if (i == 90 && _zenith == 1)
547 draw_zenith(x_ini2, x_end, y);
550 // draw dive bar vertical lines
551 if (climb_dive_ladder) {
552 draw_line(x_end, y + 5.0, x_end, y);
553 draw_line(x_ini2, y + 5.0, x_ini2, y);
556 // draw pitch / dive bars
557 draw_stipple_line(x_ini, y, x_end, y);
558 draw_stipple_line(x_ini2, y, x_end2, y);
560 if (i == -90 && _nadir == 1)
561 draw_nadir(x_ini2, x_end, y);
564 // Now calculate the location of the left side label using
565 draw_text(x_ini - label_length, y - label_height, buf);
566 draw_text(x_end2 + text_offset, y - label_height, buf);
570 // OBJECT LADDER MARK
572 // ATTRIB - ON CONDITION
573 // draw appraoch glide slope marker
574 #ifdef ENABLE_SP_FMDS
575 if (_glide_slope_marker && ihook) {
576 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
577 -half_span + hole, (_glide_slope - actslope) * _compression);
578 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
579 half_span - hole, (_glide_slope - actslope) * _compression);
589 glEnable(GL_LINE_STIPPLE);
590 glLineStipple(1, 0x00FF);
591 _locStippleLineList.draw();
592 glDisable(GL_LINE_STIPPLE);
594 glDisable(GL_CLIP_PLANE0);
595 glDisable(GL_CLIP_PLANE1);
596 glDisable(GL_CLIP_PLANE2);
597 // glDisable(GL_SCISSOR_TEST);
599 //*************************************************************
601 //*************************************************************
602 #ifdef ENABLE_SP_FMDS
603 if (_waypoint_marker) {
604 //waypoint marker computation
605 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
607 fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
608 fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
609 towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
610 towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
612 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
613 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
614 delx= towp_lat - fromwp_lat;
615 dely = towp_lon - fromwp_lon;
616 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
619 theta = asin(dely / hyp);
623 brg = theta * SGD_RADIANS_TO_DEGREES;
629 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
630 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
632 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
633 // end waypoint marker computation
635 //*********************************************************
636 // OBJECT MOVING RETICLE
639 if (fabs(brg-psi) > 10.0) {
641 glTranslatef(centroid.x, centroid.y, 0);
642 glTranslatef(vel_x, vel_y, 0);
643 glRotatef(brg - psi, 0.0, 0.0, -1.0);
644 glBegin(GL_LINE_LOOP);
645 glVertex2f(-2.5, 20.0);
646 glVertex2f(-2.5, 30.0);
647 glVertex2f(-5.0, 30.0);
648 glVertex2f(0.0, 35.0);
649 glVertex2f(5.0, 30.0);
650 glVertex2f(2.5, 30.0);
651 glVertex2f(2.5, 20.0);
656 // waypoint marker on heading scale
657 if (fabs(brg-psi) < 12.0) {
659 glBegin(GL_LINE_LOOP);
660 glVertex2f(((brg - psi) * 60 / 25) + 320, 240.0);
661 glVertex2f(((brg - psi) * 60 / 25) + 326, 240.0 - 4);
662 glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 4);
663 glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 8);
664 glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 8);
665 glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 4);
666 glVertex2f(((brg - psi) * 60 / 25) + 314, 240.0 - 4);
670 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
673 glEnable(GL_POINT_SMOOTH);
676 for (int count = 0; count <= 200; count++) {
677 float temp = count * SG_PI * 3 / (200.0 * 2.0);
678 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
679 x1 = x + r * cos(temp1);
680 y1 = y + r * sin(temp1);
685 glDisable(GL_POINT_SMOOTH);
689 } // if _waypoint_marker
694 /******************************************************************/
695 // draws the zenith symbol for highest possible climb angle (i.e. 90 degree climb angle)
697 void HUD::Ladder::draw_zenith(float xfirst, float xlast, float yvalue)
699 float xcentre = (xfirst + xlast) / 2.0;
700 float ycentre = yvalue;
702 draw_line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre + 1.3);
703 draw_line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre - 1.3);
705 draw_line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre + 1.3);
706 draw_line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre - 1.3);
708 draw_line(xcentre, ycentre + 9.0, xcentre - 1.3, ycentre + 3.0);
709 draw_line(xcentre, ycentre + 9.0, xcentre + 1.3, ycentre + 3.0);
711 draw_line(xcentre - 3.9, ycentre + 3.9, xcentre - 3.0, ycentre + 1.3);
712 draw_line(xcentre - 3.9, ycentre + 3.9, xcentre - 1.3, ycentre + 3.0);
714 draw_line(xcentre + 3.9, ycentre + 3.9, xcentre + 1.3, ycentre+3.0);
715 draw_line(xcentre + 3.9, ycentre + 3.9, xcentre + 3.0, ycentre+1.3);
717 draw_line(xcentre - 3.9, ycentre - 3.9, xcentre - 3.0, ycentre-1.3);
718 draw_line(xcentre - 3.9, ycentre - 3.9, xcentre - 1.3, ycentre-2.6);
720 draw_line(xcentre + 3.9, ycentre - 3.9, xcentre + 3.0, ycentre-1.3);
721 draw_line(xcentre + 3.9, ycentre - 3.9, xcentre + 1.3, ycentre-2.6);
723 draw_line(xcentre - 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
724 draw_line(xcentre + 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
728 // draws the nadir symbol for lowest possible dive angle (i.e. 90 degree dive angle)
730 void HUD::Ladder::draw_nadir(float xfirst, float xlast, float yvalue)
732 float xcentre = (xfirst + xlast) / 2.0;
733 float ycentre = yvalue;
736 float x1, y1, x2, y2;
739 float xcent1, xcent2, ycent1, ycent2;
740 xcent1 = xcentre + r;
743 for (int count = 1; count <= 400; count++) {
744 float temp = count * 2 * SG_PI / 400.0;
745 xcent2 = xcentre + r * cos(temp);
746 ycent2 = ycentre + r * sin(temp);
748 draw_line(xcent1, ycent1, xcent2, ycent2);
754 xcent2 = xcentre + r;
757 Item::draw_line(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
760 //to draw a line above the circle
761 draw_line(xcentre, ycentre + 7.5, xcentre, ycentre + 22.5);
763 //line in the middle of circle
764 draw_line(xcentre - 7.5, ycentre, xcentre + 7.5, ycentre);
766 float theta = asin(2.5 / 7.5);
767 float theta1 = asin(5.0 / 7.5);
769 x1 = xcentre + r * cos(theta);
771 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
773 draw_line(x1, y1, x2, y2);
775 x1 = xcentre + r * cos(theta1);
777 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
779 draw_line(x1, y1, x2, y2);
781 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
783 x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
785 draw_line(x1, y1, x2, y2);
787 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
789 x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
791 draw_line(x1, y1, x2, y2);