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.
27 #include <simgear/math/SGGeometry.hxx>
28 #include <Main/viewer.hxx>
32 static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
33 static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
34 static float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
35 static float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
36 static float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
37 static float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
38 static float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
39 static float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
40 static float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
41 static float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
45 HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
47 _pitch(n->getNode("pitch-input", false)),
48 _roll(n->getNode("roll-input", false)),
49 _width_units(int(n->getFloatValue("display-span"))),
50 _div_units(int(fabs(n->getFloatValue("divisions")))),
51 _scr_hole(fabs(n->getFloatValue("screen-hole")) * 0.5f),
52 _zero_bar_overlength(n->getFloatValue("zero-bar-overlength", 10)),
53 _dive_bar_angle(n->getBoolValue("enable-dive-bar-angle")),
54 _tick_length(n->getFloatValue("tick-length")),
55 _compression(n->getFloatValue("compression-factor")),
56 _dynamic_origin(n->getBoolValue("enable-dynamic-origin")),
57 _frl(n->getBoolValue("enable-fuselage-ref-line")),
58 _target_spot(n->getBoolValue("enable-target-spot")),
59 _target_markers(n->getBoolValue("enable-target-markers")),
60 _velocity_vector(n->getBoolValue("enable-velocity-vector")),
61 _drift_marker(n->getBoolValue("enable-drift-marker")),
62 _alpha_bracket(n->getBoolValue("enable-alpha-bracket")),
63 _energy_marker(n->getBoolValue("enable-energy-marker")),
64 _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker")),
65 _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker")),
66 _glide_slope(n->getFloatValue("glide-slope", -4.0)),
67 _energy_worm(n->getBoolValue("enable-energy-marker")),
68 _waypoint_marker(n->getBoolValue("enable-waypoint-marker")),
69 _zenith(n->getBoolValue("enable-zenith")),
70 _nadir(n->getBoolValue("enable-nadir")),
71 _hat(n->getBoolValue("enable-hat")),
72 _clip_box(new ClipBox(n->getNode("clipping")))
74 const char *t = n->getStringValue("type");
75 _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
80 _vmax = _width_units / 2;
85 HUD::Ladder::~Ladder()
90 void HUD::Ladder::draw(void)
92 if (!_pitch.isValid() || !_roll.isValid())
95 float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS;
96 float pitch_value = _pitch.getFloatValue();
98 //**************************************************************
100 glTranslatef(_center_x, _center_y, 0);
102 // OBJECT STATIC RETICLE
103 // TYPE FRL (FUSELAGE REFERENCE LINE)
105 // Draw the FRL spot and line
107 #define FRL_DIAMOND_SIZE 2.0
108 glBegin(GL_LINE_LOOP);
109 glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
110 glVertex2f(0.0, FRL_DIAMOND_SIZE);
111 glVertex2f(FRL_DIAMOND_SIZE, 0.0);
112 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
115 glBegin(GL_LINE_STRIP);
116 glVertex2f(0, FRL_DIAMOND_SIZE);
119 #undef FRL_DIAMOND_SIZE
121 // TYPE WATERLINE_MARK (W shaped _ _ ) // TODO (-> HUD_misc.cxx)
124 //****************************************************************
126 // Draw the target spot.
128 #define CENTER_DIAMOND_SIZE 6.0
129 glBegin(GL_LINE_LOOP);
130 glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
131 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
132 glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
133 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
135 #undef CENTER_DIAMOND_SIZE
138 //****************************************************************
139 //velocity vector reticle - computations
140 float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
141 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope; //, t1;
142 float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
143 float vel_x = 0.0, vel_y = 0.0, drift;
146 if (_velocity_vector) {
148 alpha = get__alpha();
156 psi = get__heading();
161 total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
162 ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
165 if (ground_vel < 2.0) {
166 if (fabs(up_vel) < 2.0)
169 actslope = (up_vel / fabs(up_vel)) * 90.0;
172 actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
175 xvvr = (-drift * (_compression / globals->get_current_view()->get_aspect_ratio()));
176 // drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
177 // yvvr = (-alpha * _compression);
178 // vel_y = (-alpha * cos(roll_value) + drift * sin(roll_value)) * _compression;
179 // vel_x = (alpha * sin(roll_value) + drift * cos(roll_value))
180 // * (_compression / globals->get_current_view()->get_aspect_ratio());
181 vel_y = -alpha * _compression;
182 vel_x = -drift * (_compression / globals->get_current_view()->get_aspect_ratio());
183 // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
185 //****************************************************************
186 // OBJECT MOVING RETICLE
187 // TYPE - DRIFT MARKER
191 glBegin(GL_LINE_STRIP);
192 glVertex2f((xvvr * 25 / 120) - 6, -4);
193 glVertex2f(xvvr * 25 / 120, 8);
194 glVertex2f((xvvr * 25 / 120) + 6, -4);
198 //****************************************************************
199 // OBJECT MOVING RETICLE
200 // TYPE VELOCITY VECTOR
203 draw_circle(vel_x, vel_y, 6);
205 //velocity vector reticle orientation lines
206 glBegin(GL_LINE_STRIP);
207 glVertex2f(vel_x - 12, vel_y);
208 glVertex2f(vel_x - 6, vel_y);
210 glBegin(GL_LINE_STRIP);
211 glVertex2f(vel_x + 12, vel_y);
212 glVertex2f(vel_x + 6, vel_y);
214 glBegin(GL_LINE_STRIP);
215 glVertex2f(vel_x, vel_y + 12);
216 glVertex2f(vel_x, vel_y + 6);
220 int lgear = get__iaux3();
221 int ihook = get__iaux6();
223 // OBJECT MOVING RETICLE
225 // ATTRIB - ON CONDITION
227 // undercarriage status
228 glBegin(GL_LINE_STRIP);
229 glVertex2f(vel_x + 8, vel_y);
230 glVertex2f(vel_x + 8, vel_y - 4);
233 // OBJECT MOVING RETICLE
235 // ATTRIB - ON CONDITION
236 glBegin(GL_LINE_STRIP);
237 glVertex2f(vel_x - 8, vel_y);
238 glVertex2f(vel_x - 8, vel_y - 4);
241 // OBJECT MOVING RETICLE
243 // ATTRIB - ON CONDITION
244 glBegin(GL_LINE_STRIP);
245 glVertex2f(vel_x, vel_y - 6);
246 glVertex2f(vel_x, vel_y - 10);
250 // OBJECT MOVING RETICLE
252 // ATTRIB - ON CONDITION
254 // arrestor hook status
255 glBegin(GL_LINE_STRIP);
256 glVertex2f(vel_x - 4, vel_y - 8);
257 glVertex2f(vel_x, vel_y - 10);
258 glVertex2f(vel_x + 4, vel_y - 8);
262 } // if _velocity_vector
264 // draw hud markers on top of each AI/MP target
265 if (_target_markers) {
266 SGPropertyNode *models = globals->get_props()->getNode("/ai/models", true);
267 for (int i = 0; i < models->nChildren(); i++) {
268 SGPropertyNode *chld = models->getChild(i);
270 name = chld->getName();
271 if (name == "aircraft" || name == "multiplayer") {
272 string callsign = chld->getStringValue("callsign");
273 if (callsign != "") {
274 float h_deg = chld->getFloatValue("radar/h-offset");
275 float v_deg = chld->getFloatValue("radar/v-offset");
276 float pos_x = (h_deg * cos(roll_value) -
277 v_deg * sin(roll_value)) * _compression;
278 float pos_y = (v_deg * cos(roll_value) +
279 h_deg * sin(roll_value)) * _compression;
280 draw_circle(pos_x, pos_y, 8);
286 //***************************************************************
287 // OBJECT MOVING RETICLE
288 // TYPE - SQUARE_BRACKET
289 // ATTRIB - ON CONDITION
292 alpha = get__alpha();
294 if (_alpha_bracket && ihook == 1) {
295 glBegin(GL_LINE_STRIP);
296 glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
297 glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
298 glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
299 glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
302 glBegin(GL_LINE_STRIP);
303 glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
304 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
305 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
306 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
310 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
311 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
313 //****************************************************************
314 // OBJECT MOVING RETICLE
315 // TYPE ENERGY_MARKERS
317 //energy markers - compute potential slope
318 float pla = get__throttleval();
321 if (_energy_marker) {
322 if (total_vel < 5.0) {
326 // t1 = up_vel / total_vel;
327 t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
329 pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
330 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
331 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
334 glBegin(GL_LINE_STRIP);
335 glVertex2f(vel_x - 20, pot_slope - 5);
336 glVertex2f(vel_x - 15, pot_slope);
337 glVertex2f(vel_x - 20, pot_slope + 5);
340 glBegin(GL_LINE_STRIP);
341 glVertex2f(vel_x + 20, pot_slope - 5);
342 glVertex2f(vel_x + 15, pot_slope);
343 glVertex2f(vel_x + 20, pot_slope + 5);
346 if (pla > (105.0 / 131.0)) {
347 glBegin(GL_LINE_STRIP);
348 glVertex2f(vel_x - 24, pot_slope - 5);
349 glVertex2f(vel_x - 19, pot_slope);
350 glVertex2f(vel_x - 24, pot_slope + 5);
353 glBegin(GL_LINE_STRIP);
354 glVertex2f(vel_x + 24, pot_slope - 5);
355 glVertex2f(vel_x + 19, pot_slope);
356 glVertex2f(vel_x + 24, pot_slope + 5);
361 //**********************************************************
363 // OBJECT STATIC RETICLE
365 // ATTRIB - ON CONDITION
367 int ilcanclaw = get__iaux2();
369 if (_energy_worm && ilcanclaw == 1) {
370 glBegin(GL_LINE_STRIP);
371 glVertex2f(-15, -134);
372 glVertex2f(15, -134);
375 // OBJECT MOVING RETICLE
377 // ATTRIB - ON CONDITION
378 glBegin(GL_LINE_STRIP);
379 glVertex2f(-6, -134);
380 glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
381 glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
385 // OBJECT MOVING RETICLE
387 // ATTRIB - ON CONDITION
388 glBegin(GL_LINE_LOOP);
389 glVertex2f(-6, actslope * 4.0 - 134);
390 glVertex2f(0, actslope * 4.0 -134 + 3);
391 glVertex2f(6, actslope * 4.0 - 134);
392 glVertex2f(0, actslope * 4.0 -134 -3);
397 //*************************************************************
398 // OBJECT MOVING RETICLE
401 // Draw the locked velocity vector.
402 if (_climb_dive_marker) {
403 glBegin(GL_LINE_LOOP);
404 glVertex2f(-3.0, 0.0 + vel_y);
405 glVertex2f(0.0, 6.0 + vel_y);
406 glVertex2f(3.0, 0.0 + vel_y);
407 glVertex2f(0.0, -6.0 + vel_y);
411 //****************************************************************
415 if (_dynamic_origin) {
416 // ladder moves with alpha/beta offset projected onto horizon
417 // line (so that the horizon line always aligns with the
419 _vmin = pitch_value - _width_units * 0.5f;
420 _vmax = pitch_value + _width_units * 0.5f;
422 // the hud ladder center point should move relative to alpha/beta
423 // however the horizon line should always stay on the horizon. We
424 // project the alpha/beta offset onto the horizon line to get the
427 SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
428 SGRayd r(SGVec3d::zeros(), d);
429 SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
430 glTranslatef(p[0], p[1], 0);
433 // ladder position is fixed relative to the center of the screen.
434 _vmin = pitch_value - _width_units * 0.5f;
435 _vmax = pitch_value + _width_units * 0.5f;
438 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
440 // FRL marker not rotated - this line shifted below
441 float half_span = _w * 0.5f;
443 struct { float x, y; } lo, li, ri, ro, numoffs; // left/right inner/outer
446 _locTextList.setFont(_hud->_font_renderer);
447 _locTextList.erase();
448 _locLineList.erase();
449 _locStippleLineList.erase();
451 for (int i = int(_vmin); i < int(_vmax) + 1; i++) {
456 y = float(i - pitch_value) * _compression + .5;
457 else // _type == CLIMB_DIVE
458 y = float(i - actslope) * _compression + .5;
460 // OBJECT LADDER MARK
462 // ATTRIB - ON CONDITION
463 // draw approach glide slope marker
465 if (_glide_slope_marker && ihook) {
466 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
467 -half_span + hole, (_glide_slope - actslope) * _compression);
468 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
469 half_span - hole, (_glide_slope - actslope) * _compression);
474 if (i == 90 && _zenith)
476 else if (i == -90 && _nadir)
479 if ((_zenith && i > 85) || i > 90)
481 if ((_nadir && i < -85) || i < -90)
487 lo.y = ro.y = li.y = ri.y = y;
492 lo.x -= _zero_bar_overlength;
493 ro.x += _zero_bar_overlength;
496 if (_scr_hole > 0.0f) {
500 if (_dive_bar_angle && i < 0) {
501 float alpha = i * SG_DEGREES_TO_RADIANS * 0.5;
502 float xoffs = (ro.x - ri.x) * cos(alpha);
503 float yoffs = (ro.x - ri.x) * sin(alpha);
506 lo.y = ro.y = li.y + yoffs;
508 numoffs.y = 4 - yoffs * 0.3;
514 draw_line(li.x, li.y, lo.x, lo.y, i < 0);
515 draw_line(ri.x, ri.y, ro.x, ro.y, i < 0);
517 draw_line(lo.x, lo.y, ro.x, ro.y, i < 0);
523 draw_line(li.x, li.y, li.x, li.y + _tick_length);
524 draw_line(ri.x, ri.y, ri.x, ri.y + _tick_length);
525 } else if (i > 0 || _zero_bar_overlength == 0) {
526 if (_tick_length > 0) {
529 draw_line(lo.x, lo.y, lo.x, lo.y - _tick_length);
530 draw_line(ro.x, ro.y, ro.x, ro.y - _tick_length);
532 draw_line(li.x, li.y, li.x, li.y - _tick_length);
533 draw_line(ri.x, ri.y, ri.x, ri.y - _tick_length);
539 std::ostringstream str;
541 // must keep this string, otherwise it will free the c_str!
542 string num_str = str.str();
543 const char *num = num_str.c_str();
544 int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
545 draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
546 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
547 draw_text(ro.x + numoffs.x, lo.y + numoffs.y, num,
548 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? LEFT : RIGHT));
557 glEnable(GL_LINE_STIPPLE);
558 glLineStipple(1, 0x00FF);
559 _locStippleLineList.draw();
560 glDisable(GL_LINE_STIPPLE);
564 //*************************************************************
566 //*************************************************************
568 if (_waypoint_marker) {
569 //waypoint marker computation
570 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
572 fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
573 fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
574 towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
575 towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
577 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
578 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
579 delx= towp_lat - fromwp_lat;
580 dely = towp_lon - fromwp_lon;
581 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
584 theta = asin(dely / hyp);
588 brg = theta * SGD_RADIANS_TO_DEGREES;
594 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
595 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
597 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
598 // end waypoint marker computation
600 //*********************************************************
601 // OBJECT MOVING RETICLE
604 if (fabs(brg - psi) > 10.0) {
606 glTranslatef(_center_x, _center_y, 0);
607 glTranslatef(vel_x, vel_y, 0);
608 glRotatef(brg - psi, 0.0, 0.0, -1.0);
609 glBegin(GL_LINE_LOOP);
610 glVertex2f(-2.5, 20.0);
611 glVertex2f(-2.5, 30.0);
612 glVertex2f(-5.0, 30.0);
613 glVertex2f(0.0, 35.0);
614 glVertex2f(5.0, 30.0);
615 glVertex2f(2.5, 30.0);
616 glVertex2f(2.5, 20.0);
621 // waypoint marker on heading scale
622 if (fabs(brg - psi) < 12.0) {
624 glBegin(GL_LINE_LOOP);
625 GLfloat x = (brg - psi) * 60 / 25;
626 glVertex2f(x + 320, 240.0);
627 glVertex2f(x + 326, 240.0 - 4);
628 glVertex2f(x + 323, 240.0 - 4);
629 glVertex2f(x + 323, 240.0 - 8);
630 glVertex2f(x + 317, 240.0 - 8);
631 glVertex2f(x + 317, 240.0 - 4);
632 glVertex2f(x + 314, 240.0 - 4);
635 } else { // if (_hat)
636 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
639 glEnable(GL_POINT_SMOOTH);
642 for (int count = 0; count <= 200; count++) {
643 float temp = count * SG_PI * 3 / (200.0 * 2.0);
644 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
645 x1 = x + r * cos(temp1);
646 y1 = y + r * sin(temp1);
651 glDisable(GL_POINT_SMOOTH);
655 } // if _waypoint_marker
660 /******************************************************************/
661 // draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
663 void HUD::Ladder::draw_zenith(float x, float y)
665 draw_line(x - 9.0, y, x - 3.0, y + 1.3);
666 draw_line(x - 9.0, y, x - 3.0, y - 1.3);
668 draw_line(x + 9.0, y, x + 3.0, y + 1.3);
669 draw_line(x + 9.0, y, x + 3.0, y - 1.3);
671 draw_line(x, y + 9.0, x - 1.3, y + 3.0);
672 draw_line(x, y + 9.0, x + 1.3, y + 3.0);
674 draw_line(x - 3.9, y + 3.9, x - 3.0, y + 1.3);
675 draw_line(x - 3.9, y + 3.9, x - 1.3, y + 3.0);
677 draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
678 draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
680 draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
681 draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
683 draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
684 draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
686 draw_line(x - 1.3, y - 2.6, x, y - 27.0);
687 draw_line(x + 1.3, y - 2.6, x, y - 27.0);
691 // draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
693 void HUD::Ladder::draw_nadir(float x, float y)
697 draw_circle(x, y, R);
698 draw_line(x, y + R, x, y + 22.5); // line above the circle
699 draw_line(x - R, y, x + R, y); // line at middle of circle
701 float theta = asin(2.5 / R);
702 float theta1 = asin(5.0 / R);
703 float x1, y1, x2, y2;
705 x1 = x + R * cos(theta);
707 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
709 draw_line(x1, y1, x2, y2);
711 x1 = x + R * cos(theta1);
713 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
715 draw_line(x1, y1, x2, y2);
717 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
719 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
721 draw_line(x1, y1, x2, y2);
723 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
725 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
727 draw_line(x1, y1, x2, y2);