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 _scr_hole(n->getIntValue("screen-hole")),
50 _compression(n->getFloatValue("compression-factor")),
51 _frl(n->getBoolValue("enable-fuselage-ref-line", false)),
52 _target_spot(n->getBoolValue("enable-target-spot", false)),
53 _velocity_vector(n->getBoolValue("enable-velocity-vector", false)),
54 _drift_marker(n->getBoolValue("enable-drift-marker", false)),
55 _alpha_bracket(n->getBoolValue("enable-alpha-bracket", false)),
56 _energy_marker(n->getBoolValue("enable-energy-marker", false)),
57 _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker", false)),
58 _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker",false)),
59 _glide_slope(n->getFloatValue("glide-slope", -4.0)),
60 _energy_worm(n->getBoolValue("enable-energy-marker", false)),
61 _waypoint_marker(n->getBoolValue("enable-waypoint-marker", false)),
62 _zenith(n->getIntValue("zenith")),
63 _nadir(n->getIntValue("nadir")),
64 _hat(n->getIntValue("hat"))
66 const char *t = n->getStringValue("type");
67 _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
72 _vmax = _width_units / 2;
77 void HUD::Ladder::draw(void)
79 if (!_pitch.isValid() || !_roll.isValid())
86 float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
87 float up_vel, ground_vel, actslope = 0.0;
88 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
89 float t2 = 0.0, psi = 0.0, alpha, pla;
90 float vel_x = 0.0, vel_y = 0.0, drift;
91 bool pitch_ladder = false;
92 bool climb_dive_ladder = false;
93 bool clip_plane = false;
95 GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
96 GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
97 GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
99 float half_span = _w / 2.0;
100 float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS; // FIXME rad/deg conversion
102 pla = get__throttleval();
105 int lgear, wown, wowm, ilcanclaw, ihook;
106 ilcanclaw = get__iaux2();
107 lgear = get__iaux3();
110 ihook = get__iaux6();
112 float pitch_value = _pitch.getFloatValue();
114 if (_type == CLIMB_DIVE) {
115 pitch_ladder = false;
116 climb_dive_ladder = true;
119 } else { // _type == PITCH
121 climb_dive_ladder = false;
125 //**************************************************************
127 // define (0, 0) as center of screen
128 glTranslatef(_center_x, _center_y, 0);
130 // OBJECT STATIC RETICLE
131 // TYPE FRL (FUSELAGE REFERENCE LINE)
133 // Draw the FRL spot and line
135 #define FRL_DIAMOND_SIZE 2.0
136 glBegin(GL_LINE_LOOP);
137 glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
138 glVertex2f(0.0, FRL_DIAMOND_SIZE);
139 glVertex2f(FRL_DIAMOND_SIZE, 0.0);
140 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
143 glBegin(GL_LINE_STRIP);
144 glVertex2f(0, FRL_DIAMOND_SIZE);
147 #undef FRL_DIAMOND_SIZE
149 // TYPE WATERLINE_MARK (W shaped _ _ )
152 //****************************************************************
154 // Draw the target spot.
156 #define CENTER_DIAMOND_SIZE 6.0
157 glBegin(GL_LINE_LOOP);
158 glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
159 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
160 glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
161 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
163 #undef CENTER_DIAMOND_SIZE
166 //****************************************************************
167 //velocity vector reticle - computations
168 if (_velocity_vector) {
175 psi = get__heading();
180 total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
181 ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
184 if (ground_vel < 2.0) {
185 if (fabs(up_vel) < 2.0)
188 actslope = (up_vel / fabs(up_vel)) * 90.0;
191 actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
194 xvvr = (((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi)
195 * (_compression / globals->get_current_view()->get_aspect_ratio()));
196 drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
197 yvvr = ((actslope - pitch_value) * _compression);
198 vel_y = ((actslope - pitch_value) * cos(roll_value) + drift * sin(roll_value)) * _compression;
199 vel_x = (-(actslope - pitch_value) * sin(roll_value) + drift * cos(roll_value))
200 * (_compression / globals->get_current_view()->get_aspect_ratio());
201 // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
203 //****************************************************************
204 // OBJECT MOVING RETICLE
205 // TYPE - DRIFT MARKER
209 glBegin(GL_LINE_STRIP);
210 glVertex2f((xvvr * 25 / 120) - 6, -4);
211 glVertex2f(xvvr * 25 / 120, 8);
212 glVertex2f((xvvr * 25 / 120) + 6, -4);
216 //****************************************************************
217 // Clipping coordinates for ladder to be input from xml file
220 glClipPlane(GL_CLIP_PLANE0, eqn_top);
221 glEnable(GL_CLIP_PLANE0);
222 glClipPlane(GL_CLIP_PLANE1, eqn_left);
223 glEnable(GL_CLIP_PLANE1);
224 glClipPlane(GL_CLIP_PLANE2, eqn_right);
225 glEnable(GL_CLIP_PLANE2);
226 // glScissor(-100,-240, 200, 240);
227 // glEnable(GL_SCISSOR_TEST);
230 //****************************************************************
231 // OBJECT MOVING RETICLE
232 // TYPE VELOCITY VECTOR
235 glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
236 for (count = 0; count < 50; count++) {
237 cosine = 6 * cos(count * SGD_2PI / 50.0);
238 sine = 6 * sin(count * SGD_2PI / 50.0);
239 glVertex2f(cosine + vel_x, sine + vel_y);
243 //velocity vector reticle orientation lines
244 glBegin(GL_LINE_STRIP);
245 glVertex2f(vel_x - 12, vel_y);
246 glVertex2f(vel_x - 6, vel_y);
248 glBegin(GL_LINE_STRIP);
249 glVertex2f(vel_x + 12, vel_y);
250 glVertex2f(vel_x + 6, vel_y);
252 glBegin(GL_LINE_STRIP);
253 glVertex2f(vel_x, vel_y + 12);
254 glVertex2f(vel_x, vel_y + 6);
258 // OBJECT MOVING RETICLE
260 // ATTRIB - ON CONDITION
262 // undercarriage status
263 glBegin(GL_LINE_STRIP);
264 glVertex2f(vel_x + 8, vel_y);
265 glVertex2f(vel_x + 8, vel_y - 4);
268 // OBJECT MOVING RETICLE
270 // ATTRIB - ON CONDITION
271 glBegin(GL_LINE_STRIP);
272 glVertex2f(vel_x - 8, vel_y);
273 glVertex2f(vel_x - 8, vel_y - 4);
276 // OBJECT MOVING RETICLE
278 // ATTRIB - ON CONDITION
279 glBegin(GL_LINE_STRIP);
280 glVertex2f(vel_x, vel_y - 6);
281 glVertex2f(vel_x, vel_y - 10);
285 // OBJECT MOVING RETICLE
287 // ATTRIB - ON CONDITION
289 // arrestor hook status
290 glBegin(GL_LINE_STRIP);
291 glVertex2f(vel_x - 4, vel_y - 8);
292 glVertex2f(vel_x, vel_y - 10);
293 glVertex2f(vel_x + 4, vel_y - 8);
297 } // if _velocity_vector
300 //***************************************************************
301 // OBJECT MOVING RETICLE
302 // TYPE - SQUARE_BRACKET
303 // ATTRIB - ON CONDITION
306 if (_alpha_bracket && ihook == 1) {
307 glBegin(GL_LINE_STRIP);
308 glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
309 glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
310 glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
311 glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
314 glBegin(GL_LINE_STRIP);
315 glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
316 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
317 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
318 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
322 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
323 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
325 //****************************************************************
326 // OBJECT MOVING RETICLE
327 // TYPE ENERGY_MARKERS
329 //energy markers - compute potential slope
330 if (_energy_marker) {
331 if (total_vel < 5.0) {
335 t1 = up_vel / total_vel;
336 t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
338 pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
339 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
340 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
343 glBegin(GL_LINE_STRIP);
344 glVertex2f(vel_x - 20, pot_slope - 5);
345 glVertex2f(vel_x - 15, pot_slope);
346 glVertex2f(vel_x - 20, pot_slope + 5);
349 glBegin(GL_LINE_STRIP);
350 glVertex2f(vel_x + 20, pot_slope - 5);
351 glVertex2f(vel_x + 15, pot_slope);
352 glVertex2f(vel_x + 20, pot_slope + 5);
355 if (pla > (105.0 / 131.0)) {
356 glBegin(GL_LINE_STRIP);
357 glVertex2f(vel_x - 24, pot_slope - 5);
358 glVertex2f(vel_x - 19, pot_slope);
359 glVertex2f(vel_x - 24, pot_slope + 5);
362 glBegin(GL_LINE_STRIP);
363 glVertex2f(vel_x + 24, pot_slope - 5);
364 glVertex2f(vel_x + 19, pot_slope);
365 glVertex2f(vel_x + 24, pot_slope + 5);
370 //**********************************************************
372 // OBJECT STATIC RETICLE
374 // ATTRIB - ON CONDITION
376 if (_energy_worm && ilcanclaw == 1) {
377 glBegin(GL_LINE_STRIP);
378 glVertex2f(-15, -134);
379 glVertex2f(15, -134);
382 // OBJECT MOVING RETICLE
384 // ATTRIB - ON CONDITION
385 glBegin(GL_LINE_STRIP);
386 glVertex2f(-6, -134);
387 glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
388 glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
392 // OBJECT MOVING RETICLE
394 // ATTRIB - ON CONDITION
395 glBegin(GL_LINE_LOOP);
396 glVertex2f(-6, actslope * 4.0 - 134);
397 glVertex2f(0, actslope * 4.0 -134 + 3);
398 glVertex2f(6, actslope * 4.0 - 134);
399 glVertex2f(0, actslope * 4.0 -134 -3);
404 //*************************************************************
405 // OBJECT MOVING RETICLE
408 // Draw the locked velocity vector.
409 if (_climb_dive_marker) {
410 glBegin(GL_LINE_LOOP);
411 glVertex2f(-3.0, 0.0 + vel_y);
412 glVertex2f(0.0, 6.0 + vel_y);
413 glVertex2f(3.0, 0.0 + vel_y);
414 glVertex2f(0.0, -6.0 + vel_y);
418 //****************************************************************
420 if (climb_dive_ladder) { // CONFORMAL_HUD
421 _vmin = pitch_value - _width_units;
422 _vmax = pitch_value + _width_units;
423 glTranslatef(vel_x, vel_y, 0);
425 } else { // pitch_ladder - Default Hud
426 _vmin = pitch_value - _width_units * 0.5f;
427 _vmax = pitch_value + _width_units * 0.5f;
430 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
431 // FRL marker not rotated - this line shifted below
434 const int BUFSIZE = 8;
442 float text_offset = 4.0f;
443 float zero_offset = 0.0;
445 if (climb_dive_ladder)
446 zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
450 fntFont *font = _hud->_font_renderer->getFont(); // FIXME
451 float pointsize = _hud->_font_renderer->getPointSize();
452 float italic = _hud->_font_renderer->getSlant();
454 _locTextList.setFont(_hud->_font_renderer);
455 _locTextList.erase();
456 _locLineList.erase();
457 _locStippleLineList.erase();
459 int last = int(_vmax) + 1;
465 for (; i < last; i++) {
466 y = (i - pitch_value) * _compression + .5f;
468 if (!(i % _div_units)) { // At integral multiple of div
469 snprintf(buf, BUFSIZE, "%d", i);
470 font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
471 label_length = right + left;
472 label_height = (top + bot) / 2.0f;
477 // Make zero point wider on left
479 x_ini -= zero_offset;
481 // Zero or above draw solid lines
482 draw_line(x_ini, y, x_end, y);
484 if (i == 90 && _zenith == 1)
485 draw_zenith(x_ini, x_end, y);
487 // Below zero draw dashed lines.
488 draw_stipple_line(x_ini, y, x_end, y);
490 if (i == -90 && _nadir ==1)
491 draw_nadir(x_ini, x_end, y);
494 // Calculate the position of the left text and write it.
495 draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
496 draw_text(x_end + text_offset, y - label_height, buf);
500 } else { // if (_scr_hole)
501 // Draw ladder with space in the middle of the lines
502 float hole = _scr_hole / 2.0f;
504 x_end = -half_span + hole;
505 x_ini2 = half_span - hole;
507 for (; i < last; i++) {
509 y = float(i - pitch_value) * _compression + .5;
510 else // _type == CLIMB_DIVE
511 y = float(i - actslope) * _compression + .5;
513 if (!(i % _div_units)) { // At integral multiple of div
514 snprintf(buf, BUFSIZE, "%d", i);
515 font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
516 label_length = right + left;
517 label_height = (top + bot) / 2.0f;
518 //printf("%s -- l %f r %f b %f t %f\n", buf, left, right, bot, top);
520 // Start by calculating the points and drawing the
526 // Make zero point wider on left
528 x_ini -= zero_offset;
529 x_end2 += zero_offset;
531 //draw climb bar vertical lines
532 if (climb_dive_ladder) {
533 // Zero or above draw solid lines
534 draw_line(x_end, y - 5.0, x_end, y);
535 draw_line(x_ini2, y - 5.0, x_ini2, y);
537 // draw pitch / climb bar
538 draw_line(x_ini, y, x_end, y);
539 draw_line(x_ini2, y, x_end2, y);
541 if (i == 90 && _zenith == 1)
542 draw_zenith(x_ini2, x_end, y);
545 // draw dive bar vertical lines
546 if (climb_dive_ladder) {
547 draw_line(x_end, y + 5.0, x_end, y);
548 draw_line(x_ini2, y + 5.0, x_ini2, y);
551 // draw pitch / dive bars
552 draw_stipple_line(x_ini, y, x_end, y);
553 draw_stipple_line(x_ini2, y, x_end2, y);
555 if (i == -90 && _nadir == 1)
556 draw_nadir(x_ini2, x_end, y);
559 // Now calculate the location of the left side label using
560 draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
561 draw_text(x_end2 + text_offset, y - label_height, buf);
565 // OBJECT LADDER MARK
567 // ATTRIB - ON CONDITION
568 // draw appraoch glide slope marker
570 if (_glide_slope_marker && ihook) {
571 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
572 -half_span + hole, (_glide_slope - actslope) * _compression);
573 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
574 half_span - hole, (_glide_slope - actslope) * _compression);
584 glEnable(GL_LINE_STIPPLE);
585 glLineStipple(1, 0x00FF);
586 _locStippleLineList.draw();
587 glDisable(GL_LINE_STIPPLE);
589 glDisable(GL_CLIP_PLANE0);
590 glDisable(GL_CLIP_PLANE1);
591 glDisable(GL_CLIP_PLANE2);
592 // glDisable(GL_SCISSOR_TEST);
594 //*************************************************************
596 //*************************************************************
598 if (_waypoint_marker) {
599 //waypoint marker computation
600 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
602 fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
603 fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
604 towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
605 towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
607 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
608 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
609 delx= towp_lat - fromwp_lat;
610 dely = towp_lon - fromwp_lon;
611 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
614 theta = asin(dely / hyp);
618 brg = theta * SGD_RADIANS_TO_DEGREES;
624 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
625 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
627 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
628 // end waypoint marker computation
630 //*********************************************************
631 // OBJECT MOVING RETICLE
634 if (fabs(brg-psi) > 10.0) {
636 glTranslatef(_center_x, _center_y, 0);
637 glTranslatef(vel_x, vel_y, 0);
638 glRotatef(brg - psi, 0.0, 0.0, -1.0);
639 glBegin(GL_LINE_LOOP);
640 glVertex2f(-2.5, 20.0);
641 glVertex2f(-2.5, 30.0);
642 glVertex2f(-5.0, 30.0);
643 glVertex2f(0.0, 35.0);
644 glVertex2f(5.0, 30.0);
645 glVertex2f(2.5, 30.0);
646 glVertex2f(2.5, 20.0);
651 // waypoint marker on heading scale
652 if (fabs(brg-psi) < 12.0) {
654 glBegin(GL_LINE_LOOP);
655 glVertex2f(((brg - psi) * 60 / 25) + 320, 240.0);
656 glVertex2f(((brg - psi) * 60 / 25) + 326, 240.0 - 4);
657 glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 4);
658 glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 8);
659 glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 8);
660 glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 4);
661 glVertex2f(((brg - psi) * 60 / 25) + 314, 240.0 - 4);
665 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
668 glEnable(GL_POINT_SMOOTH);
671 for (int count = 0; count <= 200; count++) {
672 float temp = count * SG_PI * 3 / (200.0 * 2.0);
673 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
674 x1 = x + r * cos(temp1);
675 y1 = y + r * sin(temp1);
680 glDisable(GL_POINT_SMOOTH);
684 } // if _waypoint_marker
689 /******************************************************************/
690 // draws the zenith symbol for highest possible climb angle (i.e. 90 degree climb angle)
692 void HUD::Ladder::draw_zenith(float xfirst, float xlast, float yvalue)
694 float xcentre = (xfirst + xlast) / 2.0;
695 float ycentre = yvalue;
697 draw_line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre + 1.3);
698 draw_line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre - 1.3);
700 draw_line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre + 1.3);
701 draw_line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre - 1.3);
703 draw_line(xcentre, ycentre + 9.0, xcentre - 1.3, ycentre + 3.0);
704 draw_line(xcentre, ycentre + 9.0, xcentre + 1.3, ycentre + 3.0);
706 draw_line(xcentre - 3.9, ycentre + 3.9, xcentre - 3.0, ycentre + 1.3);
707 draw_line(xcentre - 3.9, ycentre + 3.9, xcentre - 1.3, ycentre + 3.0);
709 draw_line(xcentre + 3.9, ycentre + 3.9, xcentre + 1.3, ycentre+3.0);
710 draw_line(xcentre + 3.9, ycentre + 3.9, xcentre + 3.0, ycentre+1.3);
712 draw_line(xcentre - 3.9, ycentre - 3.9, xcentre - 3.0, ycentre-1.3);
713 draw_line(xcentre - 3.9, ycentre - 3.9, xcentre - 1.3, ycentre-2.6);
715 draw_line(xcentre + 3.9, ycentre - 3.9, xcentre + 3.0, ycentre-1.3);
716 draw_line(xcentre + 3.9, ycentre - 3.9, xcentre + 1.3, ycentre-2.6);
718 draw_line(xcentre - 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
719 draw_line(xcentre + 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
723 // draws the nadir symbol for lowest possible dive angle (i.e. 90 degree dive angle)
725 void HUD::Ladder::draw_nadir(float xfirst, float xlast, float yvalue)
727 float xcentre = (xfirst + xlast) / 2.0;
728 float ycentre = yvalue;
731 float x1, y1, x2, y2;
734 float xcent1, xcent2, ycent1, ycent2;
735 xcent1 = xcentre + r;
738 for (int count = 1; count <= 400; count++) {
739 float temp = count * 2 * SG_PI / 400.0;
740 xcent2 = xcentre + r * cos(temp);
741 ycent2 = ycentre + r * sin(temp);
743 draw_line(xcent1, ycent1, xcent2, ycent2);
749 xcent2 = xcentre + r;
752 Item::draw_line(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
755 //to draw a line above the circle
756 draw_line(xcentre, ycentre + 7.5, xcentre, ycentre + 22.5);
758 //line in the middle of circle
759 draw_line(xcentre - 7.5, ycentre, xcentre + 7.5, ycentre);
761 float theta = asin(2.5 / 7.5);
762 float theta1 = asin(5.0 / 7.5);
764 x1 = xcentre + r * cos(theta);
766 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
768 draw_line(x1, y1, x2, y2);
770 x1 = xcentre + r * cos(theta1);
772 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
774 draw_line(x1, y1, x2, y2);
776 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
778 x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
780 draw_line(x1, y1, x2, y2);
782 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
784 x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
786 draw_line(x1, y1, x2, y2);