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/vector.hxx>
28 #include <Main/viewer.hxx>
33 float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
34 float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
35 float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
36 float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
37 float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
38 float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
39 float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
40 float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
41 float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
42 float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
46 HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
48 _pitch(n->getNode("pitch-input", false)),
49 _roll(n->getNode("roll-input", false)),
50 _width_units(int(n->getFloatValue("display-span"))),
51 _div_units(int(fabs(n->getFloatValue("divisions")))),
52 _scr_hole(fabsf(n->getFloatValue("screen-hole")) * 0.5f),
53 _zero_bar_overlength(n->getFloatValue("zero-bar-overlength", 10)),
54 _dive_bar_angle(n->getBoolValue("enable-dive-bar-angle")),
55 _tick_length(n->getFloatValue("tick-length")),
56 _compression(n->getFloatValue("compression-factor")),
57 _dynamic_origin(n->getBoolValue("enable-dynamic-origin")),
58 _frl(n->getBoolValue("enable-fuselage-ref-line")),
59 _target_spot(n->getBoolValue("enable-target-spot")),
60 _target_markers(n->getBoolValue("enable-target-markers")),
61 _velocity_vector(n->getBoolValue("enable-velocity-vector")),
62 _drift_marker(n->getBoolValue("enable-drift-marker")),
63 _alpha_bracket(n->getBoolValue("enable-alpha-bracket")),
64 _energy_marker(n->getBoolValue("enable-energy-marker")),
65 _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker")),
66 _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker")),
67 _glide_slope(n->getFloatValue("glide-slope", -4.0)),
68 _energy_worm(n->getBoolValue("enable-energy-marker")),
69 _waypoint_marker(n->getBoolValue("enable-waypoint-marker")),
70 _zenith(n->getBoolValue("enable-zenith")),
71 _nadir(n->getBoolValue("enable-nadir")),
72 _hat(n->getBoolValue("enable-hat")),
73 _clip_box(new ClipBox(n->getNode("clipping")))
75 const char *t = n->getStringValue("type");
76 _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
81 _vmax = _width_units / 2;
86 HUD::Ladder::~Ladder()
91 void HUD::Ladder::draw(void)
93 if (!_pitch.isValid() || !_roll.isValid())
96 float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS;
97 float pitch_value = _pitch.getFloatValue();
99 //**************************************************************
101 glTranslatef(_center_x, _center_y, 0);
103 // OBJECT STATIC RETICLE
104 // TYPE FRL (FUSELAGE REFERENCE LINE)
106 // Draw the FRL spot and line
108 #define FRL_DIAMOND_SIZE 2.0
109 glBegin(GL_LINE_LOOP);
110 glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
111 glVertex2f(0.0, FRL_DIAMOND_SIZE);
112 glVertex2f(FRL_DIAMOND_SIZE, 0.0);
113 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
116 glBegin(GL_LINE_STRIP);
117 glVertex2f(0, FRL_DIAMOND_SIZE);
120 #undef FRL_DIAMOND_SIZE
122 // TYPE WATERLINE_MARK (W shaped _ _ ) // TODO (-> HUD_misc.cxx)
125 //****************************************************************
127 // Draw the target spot.
129 #define CENTER_DIAMOND_SIZE 6.0
130 glBegin(GL_LINE_LOOP);
131 glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
132 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
133 glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
134 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
136 #undef CENTER_DIAMOND_SIZE
139 //****************************************************************
140 //velocity vector reticle - computations
141 float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
142 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
143 float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
144 float vel_x = 0.0, vel_y = 0.0, drift;
147 if (_velocity_vector) {
149 alpha = get__alpha();
157 psi = get__heading();
162 total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
163 ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
166 if (ground_vel < 2.0) {
167 if (fabs(up_vel) < 2.0)
170 actslope = (up_vel / fabs(up_vel)) * 90.0;
173 actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
176 xvvr = (-drift * (_compression / globals->get_current_view()->get_aspect_ratio()));
177 // drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
178 // yvvr = (-alpha * _compression);
179 // vel_y = (-alpha * cos(roll_value) + drift * sin(roll_value)) * _compression;
180 // vel_x = (alpha * sin(roll_value) + drift * cos(roll_value))
181 // * (_compression / globals->get_current_view()->get_aspect_ratio());
182 vel_y = -alpha * _compression;
183 vel_x = -drift * (_compression / globals->get_current_view()->get_aspect_ratio());
184 // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
186 //****************************************************************
187 // OBJECT MOVING RETICLE
188 // TYPE - DRIFT MARKER
192 glBegin(GL_LINE_STRIP);
193 glVertex2f((xvvr * 25 / 120) - 6, -4);
194 glVertex2f(xvvr * 25 / 120, 8);
195 glVertex2f((xvvr * 25 / 120) + 6, -4);
199 //****************************************************************
200 // OBJECT MOVING RETICLE
201 // TYPE VELOCITY VECTOR
204 draw_circle(vel_x, vel_y, 6);
206 //velocity vector reticle orientation lines
207 glBegin(GL_LINE_STRIP);
208 glVertex2f(vel_x - 12, vel_y);
209 glVertex2f(vel_x - 6, vel_y);
211 glBegin(GL_LINE_STRIP);
212 glVertex2f(vel_x + 12, vel_y);
213 glVertex2f(vel_x + 6, vel_y);
215 glBegin(GL_LINE_STRIP);
216 glVertex2f(vel_x, vel_y + 12);
217 glVertex2f(vel_x, vel_y + 6);
221 int lgear = get__iaux3();
222 int ihook = get__iaux6();
224 // OBJECT MOVING RETICLE
226 // ATTRIB - ON CONDITION
228 // undercarriage status
229 glBegin(GL_LINE_STRIP);
230 glVertex2f(vel_x + 8, vel_y);
231 glVertex2f(vel_x + 8, vel_y - 4);
234 // OBJECT MOVING RETICLE
236 // ATTRIB - ON CONDITION
237 glBegin(GL_LINE_STRIP);
238 glVertex2f(vel_x - 8, vel_y);
239 glVertex2f(vel_x - 8, vel_y - 4);
242 // OBJECT MOVING RETICLE
244 // ATTRIB - ON CONDITION
245 glBegin(GL_LINE_STRIP);
246 glVertex2f(vel_x, vel_y - 6);
247 glVertex2f(vel_x, vel_y - 10);
251 // OBJECT MOVING RETICLE
253 // ATTRIB - ON CONDITION
255 // arrestor hook status
256 glBegin(GL_LINE_STRIP);
257 glVertex2f(vel_x - 4, vel_y - 8);
258 glVertex2f(vel_x, vel_y - 10);
259 glVertex2f(vel_x + 4, vel_y - 8);
263 } // if _velocity_vector
265 // draw hud markers on top of each AI/MP target
266 if (_target_markers) {
267 SGPropertyNode *models = globals->get_props()->getNode("/ai/models", true);
268 for (int i = 0; i < models->nChildren(); i++) {
269 SGPropertyNode *chld = models->getChild(i);
271 name = chld->getName();
272 if (name == "aircraft" || name == "multiplayer") {
273 string callsign = chld->getStringValue("callsign");
274 if (callsign != "") {
275 float h_deg = chld->getFloatValue("radar/h-offset");
276 float v_deg = chld->getFloatValue("radar/v-offset");
277 float pos_x = (h_deg * cos(roll_value) -
278 v_deg * sin(roll_value)) * _compression;
279 float pos_y = (v_deg * cos(roll_value) +
280 h_deg * sin(roll_value)) * _compression;
281 draw_circle(pos_x, pos_y, 8);
287 //***************************************************************
288 // OBJECT MOVING RETICLE
289 // TYPE - SQUARE_BRACKET
290 // ATTRIB - ON CONDITION
293 alpha = get__alpha();
295 if (_alpha_bracket && ihook == 1) {
296 glBegin(GL_LINE_STRIP);
297 glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
298 glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
299 glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
300 glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
303 glBegin(GL_LINE_STRIP);
304 glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
305 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
306 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
307 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
311 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
312 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
314 //****************************************************************
315 // OBJECT MOVING RETICLE
316 // TYPE ENERGY_MARKERS
318 //energy markers - compute potential slope
319 float pla = get__throttleval();
322 if (_energy_marker) {
323 if (total_vel < 5.0) {
327 t1 = up_vel / total_vel;
328 t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
330 pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
331 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
332 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
335 glBegin(GL_LINE_STRIP);
336 glVertex2f(vel_x - 20, pot_slope - 5);
337 glVertex2f(vel_x - 15, pot_slope);
338 glVertex2f(vel_x - 20, pot_slope + 5);
341 glBegin(GL_LINE_STRIP);
342 glVertex2f(vel_x + 20, pot_slope - 5);
343 glVertex2f(vel_x + 15, pot_slope);
344 glVertex2f(vel_x + 20, pot_slope + 5);
347 if (pla > (105.0 / 131.0)) {
348 glBegin(GL_LINE_STRIP);
349 glVertex2f(vel_x - 24, pot_slope - 5);
350 glVertex2f(vel_x - 19, pot_slope);
351 glVertex2f(vel_x - 24, pot_slope + 5);
354 glBegin(GL_LINE_STRIP);
355 glVertex2f(vel_x + 24, pot_slope - 5);
356 glVertex2f(vel_x + 19, pot_slope);
357 glVertex2f(vel_x + 24, pot_slope + 5);
362 //**********************************************************
364 // OBJECT STATIC RETICLE
366 // ATTRIB - ON CONDITION
368 int ilcanclaw = get__iaux2();
370 if (_energy_worm && ilcanclaw == 1) {
371 glBegin(GL_LINE_STRIP);
372 glVertex2f(-15, -134);
373 glVertex2f(15, -134);
376 // OBJECT MOVING RETICLE
378 // ATTRIB - ON CONDITION
379 glBegin(GL_LINE_STRIP);
380 glVertex2f(-6, -134);
381 glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
382 glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
386 // OBJECT MOVING RETICLE
388 // ATTRIB - ON CONDITION
389 glBegin(GL_LINE_LOOP);
390 glVertex2f(-6, actslope * 4.0 - 134);
391 glVertex2f(0, actslope * 4.0 -134 + 3);
392 glVertex2f(6, actslope * 4.0 - 134);
393 glVertex2f(0, actslope * 4.0 -134 -3);
398 //*************************************************************
399 // OBJECT MOVING RETICLE
402 // Draw the locked velocity vector.
403 if (_climb_dive_marker) {
404 glBegin(GL_LINE_LOOP);
405 glVertex2f(-3.0, 0.0 + vel_y);
406 glVertex2f(0.0, 6.0 + vel_y);
407 glVertex2f(3.0, 0.0 + vel_y);
408 glVertex2f(0.0, -6.0 + vel_y);
412 //****************************************************************
416 if (_dynamic_origin) {
417 // ladder moves with alpha/beta offset projected onto horizon
418 // line (so that the horizon line always aligns with the
420 _vmin = pitch_value - _width_units * 0.5f;
421 _vmax = pitch_value + _width_units * 0.5f;
423 // the hud ladder center point should move relative to alpha/beta
424 // however the horizon line should always stay on the horizon. We
425 // project the alpha/beta offset onto the horizon line to get the
427 sgdVec3 p1; // result
428 sgdVec3 p; sgdSetVec3(p, vel_x, vel_y, 0.0);
429 sgdVec3 p0; sgdSetVec3(p0, 0.0, 0.0, 0.0);
430 sgdVec3 d; sgdSetVec3(d, cos(roll_value), sin(roll_value), 0.0);
431 sgdClosestPointToLine(p1, p, p0, d);
432 glTranslatef(p1[0], p1[1], 0);
435 // ladder position is fixed relative to the center of the screen.
436 _vmin = pitch_value - _width_units * 0.5f;
437 _vmax = pitch_value + _width_units * 0.5f;
440 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
442 // FRL marker not rotated - this line shifted below
443 float half_span = _w * 0.5f;
445 struct { float x, y; } lo, li, ri, ro, numoffs; // left/right inner/outer
448 _locTextList.setFont(_hud->_font_renderer);
449 _locTextList.erase();
450 _locLineList.erase();
451 _locStippleLineList.erase();
453 for (int i = int(_vmin); i < int(_vmax) + 1; i++) {
458 y = float(i - pitch_value) * _compression + .5;
459 else // _type == CLIMB_DIVE
460 y = float(i - actslope) * _compression + .5;
462 // OBJECT LADDER MARK
464 // ATTRIB - ON CONDITION
465 // draw approach glide slope marker
467 if (_glide_slope_marker && ihook) {
468 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
469 -half_span + hole, (_glide_slope - actslope) * _compression);
470 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
471 half_span - hole, (_glide_slope - actslope) * _compression);
476 if (i == 90 && _zenith)
478 else if (i == -90 && _nadir)
481 if (_zenith && i > 85 || i > 90)
483 if (_nadir && i < -85 || i < -90)
489 lo.y = ro.y = li.y = ri.y = y;
494 lo.x -= _zero_bar_overlength;
495 ro.x += _zero_bar_overlength;
498 if (_scr_hole > 0.0f) {
502 if (_dive_bar_angle && i < 0) {
503 float alpha = i * SG_DEGREES_TO_RADIANS * 0.5;
504 float xoffs = (ro.x - ri.x) * cos(alpha);
505 float yoffs = (ro.x - ri.x) * sin(alpha);
508 lo.y = ro.y = li.y + yoffs;
510 numoffs.y = 4 - yoffs * 0.3;
516 draw_line(li.x, li.y, lo.x, lo.y, i < 0);
517 draw_line(ri.x, ri.y, ro.x, ro.y, i < 0);
519 draw_line(lo.x, lo.y, ro.x, ro.y, i < 0);
525 draw_line(li.x, li.y, li.x, li.y + _tick_length);
526 draw_line(ri.x, ri.y, ri.x, ri.y + _tick_length);
527 } else if (i > 0 || _zero_bar_overlength == 0) {
528 if (_tick_length > 0) {
531 draw_line(lo.x, lo.y, lo.x, lo.y - _tick_length);
532 draw_line(ro.x, ro.y, ro.x, ro.y - _tick_length);
534 draw_line(li.x, li.y, li.x, li.y - _tick_length);
535 draw_line(ri.x, ri.y, ri.x, ri.y - _tick_length);
541 std::ostringstream str;
543 // must keep this string, otherwise it will free the c_str!
544 string num_str = str.str();
545 const char *num = num_str.c_str();
546 int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
547 draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
548 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
549 draw_text(ro.x + numoffs.x, lo.y + numoffs.y, num,
550 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? LEFT : RIGHT));
559 glEnable(GL_LINE_STIPPLE);
560 glLineStipple(1, 0x00FF);
561 _locStippleLineList.draw();
562 glDisable(GL_LINE_STIPPLE);
566 //*************************************************************
568 //*************************************************************
570 if (_waypoint_marker) {
571 //waypoint marker computation
572 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
574 fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
575 fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
576 towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
577 towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
579 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
580 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
581 delx= towp_lat - fromwp_lat;
582 dely = towp_lon - fromwp_lon;
583 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
586 theta = asin(dely / hyp);
590 brg = theta * SGD_RADIANS_TO_DEGREES;
596 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
597 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
599 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
600 // end waypoint marker computation
602 //*********************************************************
603 // OBJECT MOVING RETICLE
606 if (fabs(brg - psi) > 10.0) {
608 glTranslatef(_center_x, _center_y, 0);
609 glTranslatef(vel_x, vel_y, 0);
610 glRotatef(brg - psi, 0.0, 0.0, -1.0);
611 glBegin(GL_LINE_LOOP);
612 glVertex2f(-2.5, 20.0);
613 glVertex2f(-2.5, 30.0);
614 glVertex2f(-5.0, 30.0);
615 glVertex2f(0.0, 35.0);
616 glVertex2f(5.0, 30.0);
617 glVertex2f(2.5, 30.0);
618 glVertex2f(2.5, 20.0);
623 // waypoint marker on heading scale
624 if (fabs(brg - psi) < 12.0) {
626 glBegin(GL_LINE_LOOP);
627 GLfloat x = (brg - psi) * 60 / 25;
628 glVertex2f(x + 320, 240.0);
629 glVertex2f(x + 326, 240.0 - 4);
630 glVertex2f(x + 323, 240.0 - 4);
631 glVertex2f(x + 323, 240.0 - 8);
632 glVertex2f(x + 317, 240.0 - 8);
633 glVertex2f(x + 317, 240.0 - 4);
634 glVertex2f(x + 314, 240.0 - 4);
637 } else { // if (_hat)
638 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
641 glEnable(GL_POINT_SMOOTH);
644 for (int count = 0; count <= 200; count++) {
645 float temp = count * SG_PI * 3 / (200.0 * 2.0);
646 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
647 x1 = x + r * cos(temp1);
648 y1 = y + r * sin(temp1);
653 glDisable(GL_POINT_SMOOTH);
657 } // if _waypoint_marker
662 /******************************************************************/
663 // draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
665 void HUD::Ladder::draw_zenith(float x, float y)
667 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);
670 draw_line(x + 9.0, y, x + 3.0, y + 1.3);
671 draw_line(x + 9.0, y, x + 3.0, y - 1.3);
673 draw_line(x, y + 9.0, x - 1.3, y + 3.0);
674 draw_line(x, y + 9.0, x + 1.3, y + 3.0);
676 draw_line(x - 3.9, y + 3.9, x - 3.0, y + 1.3);
677 draw_line(x - 3.9, y + 3.9, x - 1.3, y + 3.0);
679 draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
680 draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
682 draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
683 draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
685 draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
686 draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
688 draw_line(x - 1.3, y - 2.6, x, y - 27.0);
689 draw_line(x + 1.3, y - 2.6, x, y - 27.0);
693 // draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
695 void HUD::Ladder::draw_nadir(float x, float y)
699 draw_circle(x, y, R);
700 draw_line(x, y + R, x, y + 22.5); // line above the circle
701 draw_line(x - R, y, x + R, y); // line at middle of circle
703 float theta = asin(2.5 / R);
704 float theta1 = asin(5.0 / R);
705 float x1, y1, x2, y2;
707 x1 = x + R * cos(theta);
709 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
711 draw_line(x1, y1, x2, y2);
713 x1 = x + R * cos(theta1);
715 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
717 draw_line(x1, y1, x2, y2);
719 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
721 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
723 draw_line(x1, y1, x2, y2);
725 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
727 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
729 draw_line(x1, y1, x2, y2);