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 <Viewer/viewer.hxx>
31 #include "HUD_private.hxx"
33 #include <Main/fg_props.hxx>
38 static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
39 static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
40 static float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
41 static float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
42 static float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
43 static float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
44 static float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
45 static float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
46 static float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
47 static float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
51 HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
53 _pitch(n->getNode("pitch-input", false)),
54 _roll(n->getNode("roll-input", false)),
55 _width_units(int(n->getFloatValue("display-span"))),
56 _div_units(int(fabs(n->getFloatValue("divisions")))),
57 _scr_hole(fabs(n->getFloatValue("screen-hole")) * 0.5f),
58 _zero_bar_overlength(n->getFloatValue("zero-bar-overlength", 10)),
59 _dive_bar_angle(n->getBoolValue("enable-dive-bar-angle")),
60 _tick_length(n->getFloatValue("tick-length")),
61 _compression(n->getFloatValue("compression-factor")),
62 _dynamic_origin(n->getBoolValue("enable-dynamic-origin")),
63 _frl(n->getBoolValue("enable-fuselage-ref-line")),
64 _target_spot(n->getBoolValue("enable-target-spot")),
65 _target_markers(n->getBoolValue("enable-target-markers")),
66 _velocity_vector(n->getBoolValue("enable-velocity-vector")),
67 _drift_marker(n->getBoolValue("enable-drift-marker")),
68 _alpha_bracket(n->getBoolValue("enable-alpha-bracket")),
69 _energy_marker(n->getBoolValue("enable-energy-marker")),
70 _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker")),
71 _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker")),
72 _glide_slope(n->getFloatValue("glide-slope", -4.0)),
73 _energy_worm(n->getBoolValue("enable-energy-marker")),
74 _waypoint_marker(n->getBoolValue("enable-waypoint-marker")),
75 _zenith(n->getBoolValue("enable-zenith")),
76 _nadir(n->getBoolValue("enable-nadir")),
77 _hat(n->getBoolValue("enable-hat")),
78 _clip_box(new ClipBox(n->getNode("clipping")))
80 const char *t = n->getStringValue("type");
81 _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
86 _vmax = _width_units / 2;
91 HUD::Ladder::~Ladder()
96 void HUD::Ladder::draw(void)
98 if (!_pitch.isValid() || !_roll.isValid())
101 float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS;
102 float pitch_value = _pitch.getFloatValue();
104 //**************************************************************
106 glTranslatef(_center_x, _center_y, 0);
108 // OBJECT STATIC RETICLE
109 // TYPE FRL (FUSELAGE REFERENCE LINE)
111 // Draw the FRL spot and line
113 #define FRL_DIAMOND_SIZE 2.0
114 glBegin(GL_LINE_LOOP);
115 glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
116 glVertex2f(0.0, FRL_DIAMOND_SIZE);
117 glVertex2f(FRL_DIAMOND_SIZE, 0.0);
118 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
121 glBegin(GL_LINE_STRIP);
122 glVertex2f(0, FRL_DIAMOND_SIZE);
125 #undef FRL_DIAMOND_SIZE
127 // TYPE WATERLINE_MARK (W shaped _ _ ) // TODO (-> HUD_misc.cxx)
130 //****************************************************************
132 // Draw the target spot.
134 #define CENTER_DIAMOND_SIZE 6.0
135 glBegin(GL_LINE_LOOP);
136 glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
137 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
138 glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
139 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
141 #undef CENTER_DIAMOND_SIZE
144 //****************************************************************
145 //velocity vector reticle - computations
146 float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
147 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope; //, t1;
148 float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
149 float vel_x = 0.0, vel_y = 0.0, drift;
152 if (_velocity_vector) {
154 alpha = get__alpha();
162 psi = get__heading();
167 total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
168 ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
171 if (ground_vel < 2.0) {
172 if (fabs(up_vel) < 2.0)
175 actslope = (up_vel / fabs(up_vel)) * 90.0;
178 actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
181 xvvr = (-drift * (_compression / globals->get_current_view()->get_aspect_ratio()));
182 // drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
183 // yvvr = (-alpha * _compression);
184 // vel_y = (-alpha * cos(roll_value) + drift * sin(roll_value)) * _compression;
185 // vel_x = (alpha * sin(roll_value) + drift * cos(roll_value))
186 // * (_compression / globals->get_current_view()->get_aspect_ratio());
187 vel_y = -alpha * _compression;
188 vel_x = -drift * (_compression / globals->get_current_view()->get_aspect_ratio());
189 // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
191 //****************************************************************
192 // OBJECT MOVING RETICLE
193 // TYPE - DRIFT MARKER
197 glBegin(GL_LINE_STRIP);
198 glVertex2f((xvvr * 25 / 120) - 6, -4);
199 glVertex2f(xvvr * 25 / 120, 8);
200 glVertex2f((xvvr * 25 / 120) + 6, -4);
204 //****************************************************************
205 // OBJECT MOVING RETICLE
206 // TYPE VELOCITY VECTOR
209 draw_circle(vel_x, vel_y, 6);
211 //velocity vector reticle orientation lines
212 glBegin(GL_LINE_STRIP);
213 glVertex2f(vel_x - 12, vel_y);
214 glVertex2f(vel_x - 6, vel_y);
216 glBegin(GL_LINE_STRIP);
217 glVertex2f(vel_x + 12, vel_y);
218 glVertex2f(vel_x + 6, vel_y);
220 glBegin(GL_LINE_STRIP);
221 glVertex2f(vel_x, vel_y + 12);
222 glVertex2f(vel_x, vel_y + 6);
226 int lgear = get__iaux3();
227 int ihook = get__iaux6();
229 // OBJECT MOVING RETICLE
231 // ATTRIB - ON CONDITION
233 // undercarriage status
234 glBegin(GL_LINE_STRIP);
235 glVertex2f(vel_x + 8, vel_y);
236 glVertex2f(vel_x + 8, vel_y - 4);
239 // OBJECT MOVING RETICLE
241 // ATTRIB - ON CONDITION
242 glBegin(GL_LINE_STRIP);
243 glVertex2f(vel_x - 8, vel_y);
244 glVertex2f(vel_x - 8, vel_y - 4);
247 // OBJECT MOVING RETICLE
249 // ATTRIB - ON CONDITION
250 glBegin(GL_LINE_STRIP);
251 glVertex2f(vel_x, vel_y - 6);
252 glVertex2f(vel_x, vel_y - 10);
256 // OBJECT MOVING RETICLE
258 // ATTRIB - ON CONDITION
260 // arrestor hook status
261 glBegin(GL_LINE_STRIP);
262 glVertex2f(vel_x - 4, vel_y - 8);
263 glVertex2f(vel_x, vel_y - 10);
264 glVertex2f(vel_x + 4, vel_y - 8);
268 } // if _velocity_vector
270 // draw hud markers on top of each AI/MP target
271 if (_target_markers) {
272 SGPropertyNode *models = globals->get_props()->getNode("/ai/models", true);
273 for (int i = 0; i < models->nChildren(); i++) {
274 SGPropertyNode *chld = models->getChild(i);
276 name = chld->getName();
277 if (name == "aircraft" || name == "multiplayer") {
278 string callsign = chld->getStringValue("callsign");
279 if (callsign != "") {
280 float h_deg = chld->getFloatValue("radar/h-offset");
281 float v_deg = chld->getFloatValue("radar/v-offset");
282 float pos_x = (h_deg * cos(roll_value) -
283 v_deg * sin(roll_value)) * _compression;
284 float pos_y = (v_deg * cos(roll_value) +
285 h_deg * sin(roll_value)) * _compression;
286 draw_circle(pos_x, pos_y, 8);
292 //***************************************************************
293 // OBJECT MOVING RETICLE
294 // TYPE - SQUARE_BRACKET
295 // ATTRIB - ON CONDITION
298 alpha = get__alpha();
300 if (_alpha_bracket && ihook == 1) {
301 glBegin(GL_LINE_STRIP);
302 glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
303 glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
304 glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
305 glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
308 glBegin(GL_LINE_STRIP);
309 glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
310 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
311 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
312 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
316 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
317 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
319 //****************************************************************
320 // OBJECT MOVING RETICLE
321 // TYPE ENERGY_MARKERS
323 //energy markers - compute potential slope
324 float pla = get__throttleval();
327 if (_energy_marker) {
328 if (total_vel < 5.0) {
332 // t1 = up_vel / total_vel;
333 t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
335 pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
336 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
337 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
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 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 if (pla > (105.0 / 131.0)) {
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);
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);
367 //**********************************************************
369 // OBJECT STATIC RETICLE
371 // ATTRIB - ON CONDITION
373 int ilcanclaw = get__iaux2();
375 if (_energy_worm && ilcanclaw == 1) {
376 glBegin(GL_LINE_STRIP);
377 glVertex2f(-15, -134);
378 glVertex2f(15, -134);
381 // OBJECT MOVING RETICLE
383 // ATTRIB - ON CONDITION
384 glBegin(GL_LINE_STRIP);
385 glVertex2f(-6, -134);
386 glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
387 glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
391 // OBJECT MOVING RETICLE
393 // ATTRIB - ON CONDITION
394 glBegin(GL_LINE_LOOP);
395 glVertex2f(-6, actslope * 4.0 - 134);
396 glVertex2f(0, actslope * 4.0 -134 + 3);
397 glVertex2f(6, actslope * 4.0 - 134);
398 glVertex2f(0, actslope * 4.0 -134 -3);
403 //*************************************************************
404 // OBJECT MOVING RETICLE
407 // Draw the locked velocity vector.
408 if (_climb_dive_marker) {
409 glBegin(GL_LINE_LOOP);
410 glVertex2f(-3.0, 0.0 + vel_y);
411 glVertex2f(0.0, 6.0 + vel_y);
412 glVertex2f(3.0, 0.0 + vel_y);
413 glVertex2f(0.0, -6.0 + vel_y);
417 //****************************************************************
421 if (_dynamic_origin) {
422 // ladder moves with alpha/beta offset projected onto horizon
423 // line (so that the horizon line always aligns with the
425 _vmin = pitch_value - _width_units * 0.5f;
426 _vmax = pitch_value + _width_units * 0.5f;
428 // the hud ladder center point should move relative to alpha/beta
429 // however the horizon line should always stay on the horizon. We
430 // project the alpha/beta offset onto the horizon line to get the
433 SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
434 SGRayd r(SGVec3d::zeros(), d);
435 SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
436 glTranslatef(p[0], p[1], 0);
439 // ladder position is fixed relative to the center of the screen.
440 _vmin = pitch_value - _width_units * 0.5f;
441 _vmax = pitch_value + _width_units * 0.5f;
444 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
446 // FRL marker not rotated - this line shifted below
447 float half_span = _w * 0.5f;
449 struct { float x, y; } lo, li, ri, ro, numoffs; // left/right inner/outer
452 _locTextList.setFont(_hud->_font_renderer);
453 _locTextList.erase();
454 _locLineList.erase();
455 _locStippleLineList.erase();
457 for (int i = int(_vmin); i < int(_vmax) + 1; i++) {
462 y = float(i - pitch_value) * _compression + .5;
463 else // _type == CLIMB_DIVE
464 y = float(i - actslope) * _compression + .5;
466 // OBJECT LADDER MARK
468 // ATTRIB - ON CONDITION
469 // draw approach glide slope marker
471 if (_glide_slope_marker && ihook) {
472 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
473 -half_span + hole, (_glide_slope - actslope) * _compression);
474 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
475 half_span - hole, (_glide_slope - actslope) * _compression);
480 if (i == 90 && _zenith)
482 else if (i == -90 && _nadir)
485 if ((_zenith && i > 85) || i > 90)
487 if ((_nadir && i < -85) || i < -90)
493 lo.y = ro.y = li.y = ri.y = y;
498 lo.x -= _zero_bar_overlength;
499 ro.x += _zero_bar_overlength;
502 if (_scr_hole > 0.0f) {
506 if (_dive_bar_angle && i < 0) {
507 float alpha = i * SG_DEGREES_TO_RADIANS * 0.5;
508 float xoffs = (ro.x - ri.x) * cos(alpha);
509 float yoffs = (ro.x - ri.x) * sin(alpha);
512 lo.y = ro.y = li.y + yoffs;
514 numoffs.y = 4 - yoffs * 0.3;
520 draw_line(li.x, li.y, lo.x, lo.y, i < 0);
521 draw_line(ri.x, ri.y, ro.x, ro.y, i < 0);
523 draw_line(lo.x, lo.y, ro.x, ro.y, i < 0);
529 draw_line(li.x, li.y, li.x, li.y + _tick_length);
530 draw_line(ri.x, ri.y, ri.x, ri.y + _tick_length);
531 } else if (i > 0 || _zero_bar_overlength == 0) {
532 if (_tick_length > 0) {
535 draw_line(lo.x, lo.y, lo.x, lo.y - _tick_length);
536 draw_line(ro.x, ro.y, ro.x, ro.y - _tick_length);
538 draw_line(li.x, li.y, li.x, li.y - _tick_length);
539 draw_line(ri.x, ri.y, ri.x, ri.y - _tick_length);
545 std::ostringstream str;
547 // must keep this string, otherwise it will free the c_str!
548 string num_str = str.str();
549 const char *num = num_str.c_str();
550 int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
551 draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
552 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
553 draw_text(ro.x + numoffs.x, lo.y + numoffs.y, num,
554 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? LEFT : RIGHT));
563 glEnable(GL_LINE_STIPPLE);
564 glLineStipple(1, 0x00FF);
565 _locStippleLineList.draw();
566 glDisable(GL_LINE_STIPPLE);
570 //*************************************************************
572 //*************************************************************
574 if (_waypoint_marker) {
575 //waypoint marker computation
576 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
578 fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
579 fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
580 towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
581 towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
583 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
584 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
585 delx= towp_lat - fromwp_lat;
586 dely = towp_lon - fromwp_lon;
587 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
590 theta = asin(dely / hyp);
594 brg = theta * SGD_RADIANS_TO_DEGREES;
600 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
601 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
603 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
604 // end waypoint marker computation
606 //*********************************************************
607 // OBJECT MOVING RETICLE
610 if (fabs(brg - psi) > 10.0) {
612 glTranslatef(_center_x, _center_y, 0);
613 glTranslatef(vel_x, vel_y, 0);
614 glRotatef(brg - psi, 0.0, 0.0, -1.0);
615 glBegin(GL_LINE_LOOP);
616 glVertex2f(-2.5, 20.0);
617 glVertex2f(-2.5, 30.0);
618 glVertex2f(-5.0, 30.0);
619 glVertex2f(0.0, 35.0);
620 glVertex2f(5.0, 30.0);
621 glVertex2f(2.5, 30.0);
622 glVertex2f(2.5, 20.0);
627 // waypoint marker on heading scale
628 if (fabs(brg - psi) < 12.0) {
630 glBegin(GL_LINE_LOOP);
631 GLfloat x = (brg - psi) * 60 / 25;
632 glVertex2f(x + 320, 240.0);
633 glVertex2f(x + 326, 240.0 - 4);
634 glVertex2f(x + 323, 240.0 - 4);
635 glVertex2f(x + 323, 240.0 - 8);
636 glVertex2f(x + 317, 240.0 - 8);
637 glVertex2f(x + 317, 240.0 - 4);
638 glVertex2f(x + 314, 240.0 - 4);
641 } else { // if (_hat)
642 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
645 glEnable(GL_POINT_SMOOTH);
648 for (int count = 0; count <= 200; count++) {
649 float temp = count * SG_PI * 3 / (200.0 * 2.0);
650 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
651 x1 = x + r * cos(temp1);
652 y1 = y + r * sin(temp1);
657 glDisable(GL_POINT_SMOOTH);
661 } // if _waypoint_marker
666 /******************************************************************/
667 // draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
669 void HUD::Ladder::draw_zenith(float x, float y)
671 draw_line(x - 9.0, y, x - 3.0, y + 1.3);
672 draw_line(x - 9.0, y, x - 3.0, y - 1.3);
674 draw_line(x + 9.0, y, x + 3.0, y + 1.3);
675 draw_line(x + 9.0, y, x + 3.0, y - 1.3);
677 draw_line(x, y + 9.0, x - 1.3, y + 3.0);
678 draw_line(x, y + 9.0, x + 1.3, y + 3.0);
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 + 3.0);
683 draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
684 draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
686 draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
687 draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
689 draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
690 draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
692 draw_line(x - 1.3, y - 2.6, x, y - 27.0);
693 draw_line(x + 1.3, y - 2.6, x, y - 27.0);
697 // draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
699 void HUD::Ladder::draw_nadir(float x, float y)
703 draw_circle(x, y, R);
704 draw_line(x, y + R, x, y + 22.5); // line above the circle
705 draw_line(x - R, y, x + R, y); // line at middle of circle
707 float theta = asin(2.5 / R);
708 float theta1 = asin(5.0 / R);
709 float x1, y1, x2, y2;
711 x1 = x + R * cos(theta);
713 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
715 draw_line(x1, y1, x2, y2);
717 x1 = x + R * cos(theta1);
719 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
721 draw_line(x1, y1, x2, y2);
723 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
725 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
727 draw_line(x1, y1, x2, y2);
729 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
731 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
733 draw_line(x1, y1, x2, y2);