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;
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;
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 == "tanker" || name == "aircraft" || name == "multiplayer") {
278 bool valid = chld->getBoolValue("valid");
279 bool in_range = chld->getBoolValue("radar/in-range", true);
280 if (valid && in_range) {
281 float h_deg = chld->getFloatValue("radar/h-offset");
282 float v_deg = chld->getFloatValue("radar/v-offset");
283 float pos_x = (h_deg * cos(roll_value) -
284 v_deg * sin(roll_value)) * _compression;
285 float pos_y = (v_deg * cos(roll_value) +
286 h_deg * sin(roll_value)) * _compression;
287 draw_circle(pos_x, pos_y, 8);
293 //***************************************************************
294 // OBJECT MOVING RETICLE
295 // TYPE - SQUARE_BRACKET
296 // ATTRIB - ON CONDITION
299 alpha = get__alpha();
301 if (_alpha_bracket && ihook == 1) {
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);
309 glBegin(GL_LINE_STRIP);
310 glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
311 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
312 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
313 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
317 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
318 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
320 //****************************************************************
321 // OBJECT MOVING RETICLE
322 // TYPE ENERGY_MARKERS
324 //energy markers - compute potential slope
325 float pla = get__throttleval();
328 if (_energy_marker) {
329 if (total_vel < 5.0) {
333 // t1 = up_vel / total_vel;
334 t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
336 pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
337 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
338 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
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 glBegin(GL_LINE_STRIP);
348 glVertex2f(vel_x + 20, pot_slope - 5);
349 glVertex2f(vel_x + 15, pot_slope);
350 glVertex2f(vel_x + 20, pot_slope + 5);
353 if (pla > (105.0 / 131.0)) {
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);
360 glBegin(GL_LINE_STRIP);
361 glVertex2f(vel_x + 24, pot_slope - 5);
362 glVertex2f(vel_x + 19, pot_slope);
363 glVertex2f(vel_x + 24, pot_slope + 5);
368 //**********************************************************
370 // OBJECT STATIC RETICLE
372 // ATTRIB - ON CONDITION
374 int ilcanclaw = get__iaux2();
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 //****************************************************************
422 if (_dynamic_origin) {
423 // ladder moves with alpha/beta offset projected onto horizon
424 // line (so that the horizon line always aligns with the
426 _vmin = pitch_value - _width_units * 0.5f;
427 _vmax = pitch_value + _width_units * 0.5f;
429 // the hud ladder center point should move relative to alpha/beta
430 // however the horizon line should always stay on the horizon. We
431 // project the alpha/beta offset onto the horizon line to get the
434 SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
435 SGRayd r(SGVec3d::zeros(), d);
436 SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
437 glTranslatef(p[0], p[1], 0);
440 // ladder position is fixed relative to the center of the screen.
441 _vmin = pitch_value - _width_units * 0.5f;
442 _vmax = pitch_value + _width_units * 0.5f;
445 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
447 // FRL marker not rotated - this line shifted below
448 float half_span = _w * 0.5f;
450 struct { float x, y; } lo, li, ri, ro, numoffs; // left/right inner/outer
453 _locTextList.setFont(_hud->_font_renderer);
454 _locTextList.erase();
455 _locLineList.erase();
456 _locStippleLineList.erase();
458 for (int i = int(_vmin); i < int(_vmax) + 1; i++) {
463 y = float(i - pitch_value) * _compression + .5;
464 else // _type == CLIMB_DIVE
465 y = float(i - actslope) * _compression + .5;
467 // OBJECT LADDER MARK
469 // ATTRIB - ON CONDITION
470 // draw approach glide slope marker
472 if (_glide_slope_marker && ihook) {
473 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
474 -half_span + hole, (_glide_slope - actslope) * _compression);
475 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
476 half_span - hole, (_glide_slope - actslope) * _compression);
481 if (i == 90 && _zenith)
483 else if (i == -90 && _nadir)
486 if ((_zenith && i > 85) || i > 90)
488 if ((_nadir && i < -85) || i < -90)
494 lo.y = ro.y = li.y = ri.y = y;
499 lo.x -= _zero_bar_overlength;
500 ro.x += _zero_bar_overlength;
503 if (_scr_hole > 0.0f) {
507 if (_dive_bar_angle && i < 0) {
508 float alpha = i * SG_DEGREES_TO_RADIANS * 0.5;
509 float xoffs = (ro.x - ri.x) * cos(alpha);
510 float yoffs = (ro.x - ri.x) * sin(alpha);
513 lo.y = ro.y = li.y + yoffs;
515 numoffs.y = 4 - yoffs * 0.3;
521 draw_line(li.x, li.y, lo.x, lo.y, i < 0);
522 draw_line(ri.x, ri.y, ro.x, ro.y, i < 0);
524 draw_line(lo.x, lo.y, ro.x, ro.y, i < 0);
530 draw_line(li.x, li.y, li.x, li.y + _tick_length);
531 draw_line(ri.x, ri.y, ri.x, ri.y + _tick_length);
532 } else if (i > 0 || _zero_bar_overlength == 0) {
533 if (_tick_length > 0) {
536 draw_line(lo.x, lo.y, lo.x, lo.y - _tick_length);
537 draw_line(ro.x, ro.y, ro.x, ro.y - _tick_length);
539 draw_line(li.x, li.y, li.x, li.y - _tick_length);
540 draw_line(ri.x, ri.y, ri.x, ri.y - _tick_length);
546 std::ostringstream str;
548 // must keep this string, otherwise it will free the c_str!
549 string num_str = str.str();
550 const char *num = num_str.c_str();
551 int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
552 draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
553 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
554 draw_text(ro.x + numoffs.x, lo.y + numoffs.y, num,
555 valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? LEFT : RIGHT));
564 glEnable(GL_LINE_STIPPLE);
565 glLineStipple(1, 0x00FF);
566 _locStippleLineList.draw();
567 glDisable(GL_LINE_STIPPLE);
571 //*************************************************************
573 //*************************************************************
575 if (_waypoint_marker) {
576 //waypoint marker computation
577 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
579 fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
580 fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
581 towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
582 towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
584 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
585 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
586 delx= towp_lat - fromwp_lat;
587 dely = towp_lon - fromwp_lon;
588 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
591 theta = asin(dely / hyp);
595 brg = theta * SGD_RADIANS_TO_DEGREES;
601 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
602 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
604 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
605 // end waypoint marker computation
607 //*********************************************************
608 // OBJECT MOVING RETICLE
611 if (fabs(brg - psi) > 10.0) {
613 glTranslatef(_center_x, _center_y, 0);
614 glTranslatef(vel_x, vel_y, 0);
615 glRotatef(brg - psi, 0.0, 0.0, -1.0);
616 glBegin(GL_LINE_LOOP);
617 glVertex2f(-2.5, 20.0);
618 glVertex2f(-2.5, 30.0);
619 glVertex2f(-5.0, 30.0);
620 glVertex2f(0.0, 35.0);
621 glVertex2f(5.0, 30.0);
622 glVertex2f(2.5, 30.0);
623 glVertex2f(2.5, 20.0);
628 // waypoint marker on heading scale
629 if (fabs(brg - psi) < 12.0) {
631 glBegin(GL_LINE_LOOP);
632 GLfloat x = (brg - psi) * 60 / 25;
633 glVertex2f(x + 320, 240.0);
634 glVertex2f(x + 326, 240.0 - 4);
635 glVertex2f(x + 323, 240.0 - 4);
636 glVertex2f(x + 323, 240.0 - 8);
637 glVertex2f(x + 317, 240.0 - 8);
638 glVertex2f(x + 317, 240.0 - 4);
639 glVertex2f(x + 314, 240.0 - 4);
642 } else { // if (_hat)
643 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
646 glEnable(GL_POINT_SMOOTH);
649 for (int count = 0; count <= 200; count++) {
650 float temp = count * SG_PI * 3 / (200.0 * 2.0);
651 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
652 x1 = x + r * cos(temp1);
653 y1 = y + r * sin(temp1);
658 glDisable(GL_POINT_SMOOTH);
662 } // if _waypoint_marker
667 /******************************************************************/
668 // draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
670 void HUD::Ladder::draw_zenith(float x, float y)
672 draw_line(x - 9.0, y, x - 3.0, y + 1.3);
673 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);
676 draw_line(x + 9.0, y, x + 3.0, y - 1.3);
678 draw_line(x, y + 9.0, x - 1.3, y + 3.0);
679 draw_line(x, y + 9.0, x + 1.3, y + 3.0);
681 draw_line(x - 3.9, y + 3.9, x - 3.0, y + 1.3);
682 draw_line(x - 3.9, y + 3.9, x - 1.3, y + 3.0);
684 draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
685 draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
687 draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
688 draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
690 draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
691 draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
693 draw_line(x - 1.3, y - 2.6, x, y - 27.0);
694 draw_line(x + 1.3, y - 2.6, x, y - 27.0);
698 // draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
700 void HUD::Ladder::draw_nadir(float x, float y)
704 draw_circle(x, y, R);
705 draw_line(x, y + R, x, y + 22.5); // line above the circle
706 draw_line(x - R, y, x + R, y); // line at middle of circle
708 float theta = asin(2.5 / R);
709 float theta1 = asin(5.0 / R);
710 float x1, y1, x2, y2;
712 x1 = x + R * cos(theta);
714 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
716 draw_line(x1, y1, x2, y2);
718 x1 = x + R * cos(theta1);
720 x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
722 draw_line(x1, y1, x2, y2);
724 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
726 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
728 draw_line(x1, y1, x2, y2);
730 x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
732 x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
734 draw_line(x1, y1, x2, y2);