5 #include <simgear/constants.h>
12 extern float get_roll(void);
13 extern float get_pitch(void);
16 HudLadder::HudLadder(const SGPropertyNode *node) :
18 node->getIntValue("x"),
19 node->getIntValue("y"),
20 node->getIntValue("width"),
21 node->getIntValue("height"),
23 get_pitch, // FIXME getter functions from cockpit.cxx
24 node->getBoolValue("working"),
26 width_units(int(node->getFloatValue("span_units"))),
27 div_units(int(fabs(node->getFloatValue("division_units")))),
28 minor_div(0 /* hud.cxx: static float minor_division = 0 */),
29 label_pos(node->getIntValue("lbl_pos")),
30 scr_hole(node->getIntValue("screen_hole")),
31 factor(node->getFloatValue("compression_factor")),
32 hudladder_type(node->getStringValue("name")),
33 frl(node->getBoolValue("enable_frl", false)),
34 target_spot(node->getBoolValue("enable_target_spot", false)),
35 velocity_vector(node->getBoolValue("enable_velocity_vector", false)),
36 drift_marker(node->getBoolValue("enable_drift_marker", false)),
37 alpha_bracket(node->getBoolValue("enable_alpha_bracket", false)),
38 energy_marker(node->getBoolValue("enable_energy_marker", false)),
39 climb_dive_marker(node->getBoolValue("enable_climb_dive_marker", false)),
40 glide_slope_marker(node->getBoolValue("enable_glide_slope_marker",false)),
41 glide_slope(node->getFloatValue("glide_slope", -4.0)),
42 energy_worm(node->getBoolValue("enable_energy_marker", false)),
43 waypoint_marker(node->getBoolValue("enable_waypoint_marker", false)),
44 zenith(node->getIntValue("zenith")),
45 nadir(node->getIntValue("nadir")),
46 hat(node->getIntValue("hat"))
48 // The factor assumes a base of 55 degrees per 640 pixels.
49 // Invert to convert the "compression" factor to a
50 // pixels-per-degree number.
51 if (fgGetBool("/sim/hud/enable3d", true) && HUD_style == 1)
52 factor = 640.0 / 55.0;
54 SG_LOG(SG_INPUT, SG_INFO, "Done reading HudLadder instrument"
55 << node->getStringValue("name", "[NONE]"));
60 vmax = width_units / 2;
65 HudLadder::~HudLadder()
71 // Draws a climb ladder in the center of the HUD
74 void HudLadder::draw(void)
81 float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
82 float up_vel, ground_vel, actslope = 0.0;
83 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
84 float t2 = 0.0, psi = 0.0, alpha, pla;
85 float vel_x = 0.0, vel_y = 0.0, drift;
86 bool pitch_ladder = false;
87 bool climb_dive_ladder = false;
88 bool clip_plane = false;
90 GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
91 GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
92 GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
94 POINT centroid = get_centroid();
95 RECT box = get_location();
97 float half_span = box.right / 2.0;
98 float roll_value = current_ch2();
100 pla = get_throttleval();
102 #ifdef ENABLE_SP_FMDS
103 int lgear, wown, wowm, ilcanclaw, ihook;
104 ilcanclaw = get_iaux2();
110 float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES;
112 if (hudladder_type == "Climb/Dive Ladder") {
113 pitch_ladder = false;
114 climb_dive_ladder = true;
117 } else { // hudladder_type == "Pitch Ladder"
119 climb_dive_ladder = false;
123 //**************************************************************
125 // define (0, 0) as center of screen
126 glTranslatef(centroid.x, centroid.y, 0);
128 // OBJECT STATIC RETICLE
131 // Draw the FRL spot and line
133 #define FRL_DIAMOND_SIZE 2.0
134 glBegin(GL_LINE_LOOP);
135 glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
136 glVertex2f(0.0, FRL_DIAMOND_SIZE);
137 glVertex2f(FRL_DIAMOND_SIZE, 0.0);
138 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
141 glBegin(GL_LINE_STRIP);
142 glVertex2f(0, FRL_DIAMOND_SIZE);
145 #undef FRL_DIAMOND_SIZE
147 // TYPE WATERLINE_MARK (W shaped _ _ )
150 //****************************************************************
152 // Draw the target spot.
154 #define CENTER_DIAMOND_SIZE 6.0
155 glBegin(GL_LINE_LOOP);
156 glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
157 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
158 glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
159 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
161 #undef CENTER_DIAMOND_SIZE
164 //****************************************************************
165 //velocity vector reticle - computations
166 if (velocity_vector) {
178 total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
179 ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
182 if (ground_vel < 2.0) {
183 if (fabs(up_vel) < 2.0)
186 actslope = (up_vel / fabs(up_vel)) * 90.0;
189 actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
192 xvvr = (((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi)
193 * (factor / globals->get_current_view()->get_aspect_ratio()));
194 drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
195 yvvr = ((actslope - pitch_value) * factor);
196 vel_y = ((actslope - pitch_value) * cos(roll_value) + drift * sin(roll_value)) * factor;
197 vel_x = (-(actslope - pitch_value) * sin(roll_value) + drift * cos(roll_value))
198 * (factor/globals->get_current_view()->get_aspect_ratio());
199 // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
201 //****************************************************************
202 // OBJECT MOVING RETICLE
203 // TYPE - DRIFT MARKER
207 glBegin(GL_LINE_STRIP);
208 glVertex2f((xvvr * 25 / 120) - 6, -4);
209 glVertex2f(xvvr * 25 / 120, 8);
210 glVertex2f((xvvr * 25 / 120) + 6, -4);
214 //****************************************************************
215 // Clipping coordinates for ladder to be input from xml file
218 glClipPlane(GL_CLIP_PLANE0, eqn_top);
219 glEnable(GL_CLIP_PLANE0);
220 glClipPlane(GL_CLIP_PLANE1, eqn_left);
221 glEnable(GL_CLIP_PLANE1);
222 glClipPlane(GL_CLIP_PLANE2, eqn_right);
223 glEnable(GL_CLIP_PLANE2);
224 // glScissor(-100,-240, 200, 240);
225 // glEnable(GL_SCISSOR_TEST);
228 //****************************************************************
229 // OBJECT MOVING RETICLE
230 // TYPE VELOCITY VECTOR
233 glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
234 for (count = 0; count < 50; count++) {
235 cosine = 6 * cos(count * SGD_2PI / 50.0);
236 sine = 6 * sin(count * SGD_2PI / 50.0);
237 glVertex2f(cosine + vel_x, sine + vel_y);
241 //velocity vector reticle orientation lines
242 glBegin(GL_LINE_STRIP);
243 glVertex2f(vel_x - 12, vel_y);
244 glVertex2f(vel_x - 6, vel_y);
246 glBegin(GL_LINE_STRIP);
247 glVertex2f(vel_x + 12, vel_y);
248 glVertex2f(vel_x + 6, vel_y);
250 glBegin(GL_LINE_STRIP);
251 glVertex2f(vel_x, vel_y + 12);
252 glVertex2f(vel_x, vel_y + 6);
255 #ifdef ENABLE_SP_FMDS
256 // OBJECT MOVING RETICLE
258 // ATTRIB - ON CONDITION
260 // undercarriage status
261 glBegin(GL_LINE_STRIP);
262 glVertex2f(vel_x + 8, vel_y);
263 glVertex2f(vel_x + 8, vel_y - 4);
266 // OBJECT MOVING RETICLE
268 // ATTRIB - ON CONDITION
269 glBegin(GL_LINE_STRIP);
270 glVertex2f(vel_x - 8, vel_y);
271 glVertex2f(vel_x - 8, vel_y - 4);
274 // OBJECT MOVING RETICLE
276 // ATTRIB - ON CONDITION
277 glBegin(GL_LINE_STRIP);
278 glVertex2f(vel_x, vel_y - 6);
279 glVertex2f(vel_x, vel_y - 10);
283 // OBJECT MOVING RETICLE
285 // ATTRIB - ON CONDITION
287 // arrestor hook status
288 glBegin(GL_LINE_STRIP);
289 glVertex2f(vel_x - 4, vel_y - 8);
290 glVertex2f(vel_x, vel_y - 10);
291 glVertex2f(vel_x + 4, vel_y - 8);
295 } // if velocity_vector
298 //***************************************************************
299 // OBJECT MOVING RETICLE
300 // TYPE - SQUARE_BRACKET
301 // ATTRIB - ON CONDITION
303 #ifdef ENABLE_SP_FMDS
304 if (alpha_bracket && ihook == 1) {
305 glBegin(GL_LINE_STRIP);
306 glVertex2f(vel_x - 20 , vel_y - (16 - alpha) * factor);
307 glVertex2f(vel_x - 17, vel_y - (16 - alpha) * factor);
308 glVertex2f(vel_x - 17, vel_y - (14 - alpha) * factor);
309 glVertex2f(vel_x - 20, vel_y - (14 - alpha) * factor);
312 glBegin(GL_LINE_STRIP);
313 glVertex2f(vel_x + 20 , vel_y - (16 - alpha) * factor);
314 glVertex2f(vel_x + 17, vel_y - (16 - alpha) * factor);
315 glVertex2f(vel_x + 17, vel_y - (14 - alpha) * factor);
316 glVertex2f(vel_x + 20, vel_y - (14 - alpha) * factor);
320 //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
321 //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
323 //****************************************************************
324 // OBJECT MOVING RETICLE
325 // TYPE ENERGY_MARKERS
327 //energy markers - compute potential slope
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) * factor + 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
373 #ifdef ENABLE_SP_FMDS
374 if (energy_worm && ilcanclaw == 1) {
375 glBegin(GL_LINE_STRIP);
376 glVertex2f(-15, -134);
377 glVertex2f(15, -134);
380 // OBJECT MOVING RETICLE
382 // ATTRIB - ON CONDITION
383 glBegin(GL_LINE_STRIP);
384 glVertex2f(-6, -134);
385 glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
386 glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
390 // OBJECT MOVING RETICLE
392 // ATTRIB - ON CONDITION
393 glBegin(GL_LINE_LOOP);
394 glVertex2f(-6, actslope * 4.0 - 134);
395 glVertex2f(0, actslope * 4.0 -134 + 3);
396 glVertex2f(6, actslope * 4.0 - 134);
397 glVertex2f(0, actslope * 4.0 -134 -3);
402 //*************************************************************
403 // OBJECT MOVING RETICLE
406 // Draw the locked velocity vector.
407 if (climb_dive_marker) {
408 glBegin(GL_LINE_LOOP);
409 glVertex2f(-3.0, 0.0 + vel_y);
410 glVertex2f(0.0, 6.0 + vel_y);
411 glVertex2f(3.0, 0.0 + vel_y);
412 glVertex2f(0.0, -6.0 + vel_y);
416 //****************************************************************
418 if (climb_dive_ladder) { // CONFORMAL_HUD
419 vmin = pitch_value - (float)width_units;
420 vmax = pitch_value + (float)width_units;
421 glTranslatef(vel_x, vel_y, 0);
423 } else { // pitch_ladder - Default Hud
424 vmin = pitch_value - (float)width_units * 0.5f;
425 vmax = pitch_value + (float)width_units * 0.5f;
428 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
429 // FRL marker not rotated - this line shifted below
439 float text_offset = 4.0f;
440 float zero_offset = 0.0;
442 if (climb_dive_ladder)
443 zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
447 fntFont *font = HUDtext->getFont(); // FIXME
448 float pointsize = HUDtext->getPointSize();
449 float italic = HUDtext->getSlant();
451 TextList.setFont(HUDtext);
454 StippleLineList.erase();
456 int last = FloatToInt(vmax) + 1;
457 int i = FloatToInt(vmin);
462 for (; i<last; i++) {
463 y = (((float)(i - pitch_value) * factor) + .5f);
465 if (!(i % div_units)) { // At integral multiple of div
466 sprintf(TextLadder, "%d", i);
467 font->getBBox(TextLadder, pointsize, italic,
468 &left, &right, &bot, &top);
469 label_length = right - left;
470 label_length += text_offset;
471 label_height = (top - bot) / 2.0f;
476 // Make zero point wider on left
478 x_ini -= zero_offset;
480 // Zero or above draw solid lines
481 Line(x_ini, y, x_end, y);
483 if (i == 90 && zenith == 1)
484 drawZenith(x_ini, x_end, y);
486 // Below zero draw dashed lines.
487 StippleLine(x_ini, y, x_end, y);
489 if (i == -90 && nadir ==1)
490 drawNadir(x_ini, x_end, y);
493 // Calculate the position of the left text and write it.
494 Text(x_ini-label_length, y-label_height, TextLadder);
495 Text(x_end+text_offset, y-label_height, TextLadder);
499 } else { // if (scr_hole)
500 // Draw ladder with space in the middle of the lines
501 float hole = (float)((scr_hole) / 2.0f);
503 x_end = -half_span + hole;
504 x_ini2 = half_span - hole;
506 for (; i < last; i++) {
507 if (hudladder_type == "Pitch Ladder")
508 y = (((float)(i - pitch_value) * factor) + .5);
509 else if (hudladder_type == "Climb/Dive Ladder")
510 y = (((float)(i - actslope) * factor) + .5);
512 if (!(i % div_units)) { // At integral multiple of div
513 sprintf(TextLadder, "%d", i);
514 font->getBBox(TextLadder, pointsize, italic,
515 &left, &right, &bot, &top);
516 label_length = right - left;
517 label_length += text_offset;
518 label_height = (top - bot) / 2.0f;
519 // printf("l %f r %f b %f t %f\n",left, right, bot, top);
521 // Start by calculating the points and drawing the
527 // Make zero point wider on left
529 x_ini -= zero_offset;
530 x_end2 += zero_offset;
532 //draw climb bar vertical lines
533 if (climb_dive_ladder) {
534 // Zero or above draw solid lines
535 Line(x_end, y - 5.0, x_end, y);
536 Line(x_ini2, y - 5.0, x_ini2, y);
538 // draw pitch / climb bar
539 Line(x_ini, y, x_end, y);
540 Line(x_ini2, y, x_end2, y);
542 if (i == 90 && zenith == 1)
543 drawZenith(x_ini2, x_end, y);
546 // draw dive bar vertical lines
547 if (climb_dive_ladder) {
548 Line(x_end, y + 5.0, x_end, y);
549 Line(x_ini2, y + 5.0, x_ini2, y);
552 // draw pitch / dive bars
553 StippleLine(x_ini, y, x_end, y);
554 StippleLine(x_ini2, y, x_end2, y);
556 if (i == -90 && nadir == 1)
557 drawNadir(x_ini2, x_end, y);
560 // Now calculate the location of the left side label using
561 Text(x_ini-label_length, y - label_height, TextLadder);
562 Text(x_end2+text_offset, y - label_height, TextLadder);
566 // OBJECT LADDER MARK
568 // ATTRIB - ON CONDITION
569 // draw appraoch glide slope marker
570 #ifdef ENABLE_SP_FMDS
571 if (glide_slope_marker && ihook) {
572 Line(-half_span + 15, (glide_slope-actslope) * factor,
573 -half_span + hole, (glide_slope - actslope) * factor);
574 Line(half_span - 15, (glide_slope-actslope) * factor,
575 half_span - hole, (glide_slope - actslope) * factor);
585 glEnable(GL_LINE_STIPPLE);
586 glLineStipple(1, 0x00FF);
587 StippleLineList.draw();
588 glDisable(GL_LINE_STIPPLE);
590 glDisable(GL_CLIP_PLANE0);
591 glDisable(GL_CLIP_PLANE1);
592 glDisable(GL_CLIP_PLANE2);
593 // glDisable(GL_SCISSOR_TEST);
595 //*************************************************************
597 //*************************************************************
598 #ifdef ENABLE_SP_FMDS
599 if (waypoint_marker) {
600 //waypoint marker computation
601 float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
603 fromwp_lon = get_longitude() * SGD_DEGREES_TO_RADIANS;
604 fromwp_lat = get_latitude() * SGD_DEGREES_TO_RADIANS;
605 towp_lon = get_aux2() * SGD_DEGREES_TO_RADIANS;
606 towp_lat = get_aux1() * SGD_DEGREES_TO_RADIANS;
608 dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
609 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
610 delx= towp_lat - fromwp_lat;
611 dely = towp_lon - fromwp_lon;
612 hyp = sqrt(pow(delx, 2) + pow(dely, 2));
615 theta = asin(dely / hyp);
619 brg = theta * SGD_RADIANS_TO_DEGREES;
625 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
626 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
628 dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
629 // end waypoint marker computation
631 //*********************************************************
632 // OBJECT MOVING RETICLE
635 if (fabs(brg-psi) > 10.0) {
637 glTranslatef(centroid.x, centroid.y, 0);
638 glTranslatef(vel_x, vel_y, 0);
639 glRotatef(brg - psi, 0.0, 0.0, -1.0);
640 glBegin(GL_LINE_LOOP);
641 glVertex2f(-2.5, 20.0);
642 glVertex2f(-2.5, 30.0);
643 glVertex2f(-5.0, 30.0);
644 glVertex2f(0.0, 35.0);
645 glVertex2f(5.0, 30.0);
646 glVertex2f(2.5, 30.0);
647 glVertex2f(2.5, 20.0);
652 // waypoint marker on heading scale
653 if (fabs(brg-psi) < 12.0) {
655 glBegin(GL_LINE_LOOP);
656 glVertex2f(((brg - psi) * 60 / 25) + 320, 240.0);
657 glVertex2f(((brg - psi) * 60 / 25) + 326, 240.0 - 4);
658 glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 4);
659 glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 8);
660 glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 8);
661 glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 4);
662 glVertex2f(((brg - psi) * 60 / 25) + 314, 240.0 - 4);
666 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
669 glEnable(GL_POINT_SMOOTH);
672 for (int count = 0; count <= 200; count++) {
673 float temp = count * 3.142 * 3 / (200.0 * 2.0);
674 float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
675 x1 = x + r * cos(temp1);
676 y1 = y + r * sin(temp1);
681 glDisable(GL_POINT_SMOOTH);
685 } // if waypoint_marker
690 /******************************************************************/
691 // draws the zenith symbol for highest possible climb angle (i.e. 90 degree climb angle)
693 void HudLadder::drawZenith(float xfirst, float xlast, float yvalue)
695 float xcentre = (xfirst + xlast) / 2.0;
696 float ycentre = yvalue;
698 Line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre + 1.3);
699 Line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre - 1.3);
701 Line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre + 1.3);
702 Line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre - 1.3);
704 Line(xcentre, ycentre + 9.0, xcentre - 1.3, ycentre + 3.0);
705 Line(xcentre, ycentre + 9.0, xcentre + 1.3, ycentre + 3.0);
707 Line(xcentre - 3.9, ycentre + 3.9, xcentre - 3.0, ycentre + 1.3);
708 Line(xcentre - 3.9, ycentre + 3.9, xcentre - 1.3, ycentre + 3.0);
710 Line(xcentre + 3.9, ycentre + 3.9, xcentre + 1.3, ycentre+3.0);
711 Line(xcentre + 3.9, ycentre + 3.9, xcentre + 3.0, ycentre+1.3);
713 Line(xcentre - 3.9, ycentre - 3.9, xcentre - 3.0, ycentre-1.3);
714 Line(xcentre - 3.9, ycentre - 3.9, xcentre - 1.3, ycentre-2.6);
716 Line(xcentre + 3.9, ycentre - 3.9, xcentre + 3.0, ycentre-1.3);
717 Line(xcentre + 3.9, ycentre - 3.9, xcentre + 1.3, ycentre-2.6);
719 Line(xcentre - 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
720 Line(xcentre + 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
724 // draws the nadir symbol for lowest possible dive angle (i.e. 90 degree dive angle)
726 void HudLadder::drawNadir(float xfirst, float xlast, float yvalue)
728 float xcentre = (xfirst + xlast) / 2.0;
729 float ycentre = yvalue;
732 float x1, y1, x2, y2;
735 float xcent1, xcent2, ycent1, ycent2;
736 xcent1 = xcentre + r;
739 for (int count = 1; count <= 400; count++) {
740 float temp = count * 2 * 3.142 / 400.0;
741 xcent2 = xcentre + r * cos(temp);
742 ycent2 = ycentre + r * sin(temp);
744 Line(xcent1, ycent1, xcent2, ycent2);
750 xcent2 = xcentre + r;
753 drawOneLine(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
756 //to draw a line above the circle
757 Line(xcentre, ycentre + 7.5, xcentre, ycentre + 22.5);
759 //line in the middle of circle
760 Line(xcentre - 7.5, ycentre, xcentre + 7.5, ycentre);
762 float theta = asin (2.5 / 7.5);
763 float theta1 = asin(5.0 / 7.5);
765 x1 = xcentre + r * cos(theta);
767 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
769 Line(x1, y1, x2, y2);
771 x1 = xcentre + r * cos(theta1);
773 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
775 Line(x1, y1, x2, y2);
777 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
779 x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
781 Line(x1, y1, x2, y2);
783 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
785 x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
787 Line(x1, y1, x2, y2);