6 #include <simgear/constants.h>
12 //====================== Top of HudLadder Class =======================
13 HudLadder::HudLadder(const string& name,
34 float glide_slope_val,
41 dual_instr_item( x, y, width, height,
42 ptch_source, roll_source, working, HUDS_RIGHT),
43 width_units ( (int)(span_units) ),
44 div_units ( (int)(major_div < 0? -major_div: major_div) ),
45 minor_div ( (int)(minor_div) ),
46 label_pos ( lbl_pos ),
47 scr_hole ( screen_hole ),
48 vmax ( span_units/2 ),
51 hudladder_type ( name ),
53 target_spot ( target ),
54 velocity_vector ( vel_vec ),
55 drift_marker ( drift ),
56 alpha_bracket ( alpha ),
57 energy_marker ( energy ),
58 climb_dive_marker ( climb ),
59 glide_slope_marker ( glide ),
60 glide_slope ( glide_slope_val),
61 energy_worm ( worm_energy),
62 waypoint_marker ( waypoint)
75 HudLadder::~HudLadder()
80 HudLadder::HudLadder( const HudLadder & image ) :
81 dual_instr_item ( (dual_instr_item &) image),
82 width_units ( image.width_units ),
83 div_units ( image.div_units ),
84 label_pos ( image.label_pos ),
85 scr_hole ( image.scr_hole ),
88 factor ( image.factor ),
89 hudladder_type ( image.hudladder_type),
91 target_spot ( image.target_spot),
92 velocity_vector ( image.velocity_vector),
93 drift_marker ( image.drift_marker),
94 alpha_bracket ( image.alpha_bracket),
95 energy_marker ( image.energy_marker),
96 climb_dive_marker ( image.climb_dive_marker),
97 glide_slope_marker ( image.glide_slope_marker),
98 glide_slope ( image.glide_slope),
99 energy_worm ( image.energy_worm),
100 waypoint_marker ( image.waypoint_marker)
105 HudLadder& HudLadder::operator=( const HudLadder & rhs )
107 if (!(this == &rhs)) {
108 (dual_instr_item &)(*this) = (dual_instr_item &)rhs;
109 width_units = rhs.width_units;
110 div_units = rhs.div_units;
111 label_pos = rhs.label_pos;
112 scr_hole = rhs.scr_hole;
116 hudladder_type = rhs.hudladder_type;
118 velocity_vector = rhs.velocity_vector;
119 drift_marker = rhs.drift_marker;
120 alpha_bracket = rhs.alpha_bracket;
121 energy_marker = rhs.energy_marker;
122 climb_dive_marker = rhs.climb_dive_marker;
123 target_spot = rhs.target_spot;
124 glide_slope_marker = rhs.glide_slope_marker;
125 glide_slope = rhs.glide_slope;
126 energy_worm = rhs.energy_worm;
127 waypoint_marker = rhs.waypoint_marker;
134 // Draws a climb ladder in the center of the HUD
137 void HudLadder::draw( void )
144 float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0,
145 up_vel, ground_vel, actslope = 0.0;
146 float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1,
147 t2 = 0.0, psi = 0.0, alpha,pla;
148 float vel_x = 0.0, vel_y = 0.0, drift;
150 bool pitch_ladder = false;
151 bool climb_dive_ladder = false;
152 bool clip_plane = false;
154 GLdouble eqn_top[4] = {0.0,-1.0,0.0,0.0};
155 GLdouble eqn_left[4] = {-1.0,0.0,0.0,100.0};
156 GLdouble eqn_right[4] = {1.0,0.0,0.0,100.0};
158 POINT centroid = get_centroid();
159 RECT box = get_location();
161 float half_span = box.right / 2.0;
162 float roll_value = current_ch2();
164 pla = get_throttleval();
166 #ifdef ENABLE_SP_FMDS
167 int lgear,wown,wowm,ilcanclaw,ihook;
168 ilcanclaw = get_iaux2();
174 float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES;
176 if (hudladder_type=="Climb/Dive Ladder") {
177 pitch_ladder = false;
178 climb_dive_ladder = true;
181 // hudladder_type=="Pitch Ladder"
183 climb_dive_ladder = false;
187 //**************************************************************
189 // define (0,0) as center of screen
190 glTranslatef( centroid.x, centroid.y, 0);
192 // OBJECT STATIC RETICLE
195 // Draw the FRL spot and line
197 #define FRL_DIAMOND_SIZE 2.0
198 glBegin(GL_LINE_LOOP);
199 glVertex2f( -FRL_DIAMOND_SIZE, 0.0);
200 glVertex2f(0.0, FRL_DIAMOND_SIZE);
201 glVertex2f( FRL_DIAMOND_SIZE, 0.0);
202 glVertex2f(0.0, -FRL_DIAMOND_SIZE);
205 glBegin(GL_LINE_STRIP);
206 glVertex2f(0, FRL_DIAMOND_SIZE);
209 #undef FRL_DIAMOND_SIZE
211 // TYPE WATERLINE_MARK (W shaped _ _ )
214 //****************************************************************
216 // Draw the target spot.
218 #define CENTER_DIAMOND_SIZE 6.0
219 glBegin(GL_LINE_LOOP);
220 glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
221 glVertex2f(0.0, CENTER_DIAMOND_SIZE);
222 glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
223 glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
225 #undef CENTER_DIAMOND_SIZE
228 //****************************************************************
229 //velocity vector reticle - computations
230 if (velocity_vector) {
242 total_vel = sqrt(Vxx*Vxx + Vyy*Vyy + Vzz*Vzz);
243 ground_vel = sqrt(Vxx*Vxx + Vyy*Vyy);
246 if (ground_vel < 2.0) {
247 if (fabs(up_vel) < 2.0)
250 actslope = (up_vel/fabs(up_vel))*90.0;
253 actslope = atan(up_vel/ground_vel)*SGD_RADIANS_TO_DEGREES;
256 xvvr = (((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi)
257 * (factor/globals->get_current_view()->get_aspect_ratio()));
258 drift = ((atan2(Vyy,Vxx)*SGD_RADIANS_TO_DEGREES)-psi);
259 yvvr = ((actslope - pitch_value)*factor);
260 vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
261 vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))
262 * (factor/globals->get_current_view()->get_aspect_ratio());
263 // printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
265 //****************************************************************
266 // OBJECT MOVING RETICLE
267 // TYPE - DRIFT MARKER
271 glBegin(GL_LINE_STRIP);
272 glVertex2f((xvvr*25/120)-6, -4);
273 glVertex2f(xvvr*25/120, 8);
274 glVertex2f((xvvr*25/120)+6, -4);
278 //****************************************************************
279 // Clipping coordinates for ladder to be input from xml file
282 glClipPlane(GL_CLIP_PLANE0,eqn_top);
283 glEnable(GL_CLIP_PLANE0);
284 glClipPlane(GL_CLIP_PLANE1,eqn_left);
285 glEnable(GL_CLIP_PLANE1);
286 glClipPlane(GL_CLIP_PLANE2,eqn_right);
287 glEnable(GL_CLIP_PLANE2);
288 // glScissor(-100,-240,200,240);
289 // glEnable(GL_SCISSOR_TEST);
292 //****************************************************************
293 // OBJECT MOVING RETICLE
294 // TYPE VELOCITY VECTOR
297 glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
298 for (count=0; count<50; count++) {
299 cosine = 6 * cos(count * SGD_2PI/50.0);
300 sine = 6 * sin(count * SGD_2PI/50.0);
301 glVertex2f(cosine+vel_x, sine+vel_y);
305 //velocity vector reticle orientation lines
306 glBegin(GL_LINE_STRIP);
307 glVertex2f(vel_x-12, vel_y);
308 glVertex2f(vel_x-6, vel_y);
310 glBegin(GL_LINE_STRIP);
311 glVertex2f(vel_x+12, vel_y);
312 glVertex2f(vel_x+6, vel_y);
314 glBegin(GL_LINE_STRIP);
315 glVertex2f(vel_x, vel_y+12);
316 glVertex2f(vel_x, vel_y+6);
319 #ifdef ENABLE_SP_FMDS
320 // OBJECT MOVING RETICLE
322 // ATTRIB - ON CONDITION
324 // undercarriage status
325 glBegin(GL_LINE_STRIP);
326 glVertex2f(vel_x+8, vel_y);
327 glVertex2f(vel_x+8, vel_y-4);
330 // OBJECT MOVING RETICLE
332 // ATTRIB - ON CONDITION
333 glBegin(GL_LINE_STRIP);
334 glVertex2f(vel_x-8, vel_y);
335 glVertex2f(vel_x-8, vel_y-4);
338 // OBJECT MOVING RETICLE
340 // ATTRIB - ON CONDITION
341 glBegin(GL_LINE_STRIP);
342 glVertex2f(vel_x, vel_y-6);
343 glVertex2f(vel_x, vel_y-10);
347 // OBJECT MOVING RETICLE
349 // ATTRIB - ON CONDITION
351 // arrestor hook status
352 glBegin(GL_LINE_STRIP);
353 glVertex2f(vel_x-4, vel_y-8);
354 glVertex2f(vel_x, vel_y-10);
355 glVertex2f(vel_x+4, vel_y-8);
359 } // if velocity_vector
362 //***************************************************************
363 // OBJECT MOVING RETICLE
364 // TYPE - SQUARE_BRACKET
365 // ATTRIB - ON CONDITION
367 #ifdef ENABLE_SP_FMDS
368 if (alpha_bracket && ihook == 1) {
369 glBegin(GL_LINE_STRIP);
370 glVertex2f(vel_x-20 , vel_y-(16-alpha)*factor);
371 glVertex2f(vel_x-17, vel_y-(16-alpha)*factor);
372 glVertex2f(vel_x-17, vel_y-(14-alpha)*factor);
373 glVertex2f(vel_x-20, vel_y-(14-alpha)*factor);
376 glBegin(GL_LINE_STRIP);
377 glVertex2f(vel_x+20 , vel_y-(16-alpha)*factor);
378 glVertex2f(vel_x+17, vel_y-(16-alpha)*factor);
379 glVertex2f(vel_x+17, vel_y-(14-alpha)*factor);
380 glVertex2f(vel_x+20, vel_y-(14-alpha)*factor);
384 //printf("xvr=%f,yvr=%f,Vx=%f,Vy=%f,Vz=%f\n",xvvr,yvvr,Vx,Vy,Vz);
385 //printf("Ax=%f,Ay=%f,Az=%f\n",Ax,Ay,Az);
387 //****************************************************************
388 // OBJECT MOVING RETICLE
389 // TYPE ENERGY_MARKERS
391 //energy markers - compute potential slope
393 if (total_vel < 5.0) {
397 t1 = up_vel/total_vel;
398 t2 = asin((Vxx*Axx + Vyy*Ayy + Vzz*Azz)/(9.81*total_vel));
400 pot_slope = ((t2/3)*SGD_RADIANS_TO_DEGREES)*factor + vel_y;
401 // if (pot_slope < (vel_y - 45)) pot_slope = vel_y-45;
402 // if (pot_slope > (vel_y + 45)) pot_slope = vel_y+45;
405 glBegin(GL_LINE_STRIP);
406 glVertex2f(vel_x-20, pot_slope-5);
407 glVertex2f(vel_x-15, pot_slope);
408 glVertex2f(vel_x-20, pot_slope+5);
411 glBegin(GL_LINE_STRIP);
412 glVertex2f(vel_x+20, pot_slope-5);
413 glVertex2f(vel_x+15, pot_slope);
414 glVertex2f(vel_x+20, pot_slope+5);
417 if (pla > (105.0/131.0)) {
418 glBegin(GL_LINE_STRIP);
419 glVertex2f(vel_x-24, pot_slope-5);
420 glVertex2f(vel_x-19, pot_slope);
421 glVertex2f(vel_x-24, pot_slope+5);
424 glBegin(GL_LINE_STRIP);
425 glVertex2f(vel_x+24, pot_slope-5);
426 glVertex2f(vel_x+19, pot_slope);
427 glVertex2f(vel_x+24, pot_slope+5);
432 //**********************************************************
434 // OBJECT STATIC RETICLE
436 // ATTRIB - ON CONDITION
437 #ifdef ENABLE_SP_FMDS
438 if (energy_worm && ilcanclaw == 1) {
439 glBegin(GL_LINE_STRIP);
440 glVertex2f(-15, -134);
441 glVertex2f(15, -134);
444 // OBJECT MOVING RETICLE
446 // ATTRIB - ON CONDITION
447 glBegin(GL_LINE_STRIP);
448 glVertex2f(-6, -134);
449 glVertex2f(-6, t2*SGD_RADIANS_TO_DEGREES*4.0 - 134);
450 glVertex2f(+6, t2*SGD_RADIANS_TO_DEGREES*4.0 - 134);
454 // OBJECT MOVING RETICLE
456 // ATTRIB - ON CONDITION
457 glBegin(GL_LINE_LOOP);
458 glVertex2f(-6, actslope*4.0 - 134);
459 glVertex2f(0, actslope*4.0 -134 +3);
460 glVertex2f(6, actslope*4.0 - 134);
461 glVertex2f(0, actslope*4.0 -134 -3);
466 //*************************************************************
467 // OBJECT MOVING RETICLE
470 // Draw the locked velocity vector.
471 if (climb_dive_marker) {
472 glBegin(GL_LINE_LOOP);
473 glVertex2f( -3.0, 0.0+vel_y);
474 glVertex2f(0.0, 6.0+vel_y);
475 glVertex2f( 3.0, 0.0+vel_y);
476 glVertex2f(0.0, -6.0+vel_y);
480 //****************************************************************
482 if (climb_dive_ladder) { // CONFORMAL_HUD
483 vmin = pitch_value - (float)width_units;
484 vmax = pitch_value + (float)width_units;
485 glTranslatef( vel_x, vel_y, 0);
487 } else { // pitch_ladder - Default Hud
488 vmin = pitch_value - (float)width_units * 0.5f;
489 vmax = pitch_value + (float)width_units * 0.5f;
492 glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
493 // FRL marker not rotated - this line shifted below
503 float text_offset = 4.0f;
504 float zero_offset = 0.0;
506 if (climb_dive_ladder)
507 zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
511 fntFont *font = HUDtext->getFont();
512 float pointsize = HUDtext->getPointSize();
513 float italic = HUDtext->getSlant();
515 TextList.setFont( HUDtext );
518 StippleLineList.erase();
520 int last = FloatToInt(vmax)+1;
521 int i = FloatToInt(vmin);
526 for (; i<last; i++) {
527 y = (((float)(i - pitch_value) * factor) + .5f);
529 if ( !(i % div_units )) { // At integral multiple of div
530 sprintf( TextLadder, "%d", i );
531 font->getBBox ( TextLadder, pointsize, italic,
532 &left, &right, &bot, &top ) ;
533 label_length = right - left;
534 label_length += text_offset;
535 label_height = (top - bot)/2.0f;
540 // Make zero point wider on left
542 x_ini -= zero_offset;
544 // Zero or above draw solid lines
545 Line(x_ini, y, x_end, y);
547 if (i == 90 && zenith == 1)
548 drawZenith(x_ini, x_end,y);
550 // Below zero draw dashed lines.
551 StippleLine(x_ini, y, x_end, y);
553 if (i == -90 && nadir ==1)
554 drawNadir(x_ini, x_end,y);
557 // Calculate the position of the left text and write it.
558 Text( x_ini-label_length, y-label_height, TextLadder );
559 Text( x_end+text_offset, y-label_height, TextLadder );
563 } else { // if (scr_hole )
564 // Draw ladder with space in the middle of the lines
565 float hole = (float)((scr_hole)/2.0f);
567 x_end = -half_span + hole;
568 x_ini2= half_span - hole;
570 for (; i<last; i++) {
571 if (hudladder_type=="Pitch Ladder")
572 y = (((float)(i - pitch_value) * factor) + .5);
573 else if (hudladder_type=="Climb/Dive Ladder")
574 y = (((float)(i - actslope) * factor) + .5);
576 if (!(i % div_units)) { // At integral multiple of div
577 sprintf( TextLadder, "%d", i );
578 font->getBBox ( TextLadder, pointsize, italic,
579 &left, &right, &bot, &top ) ;
580 label_length = right - left;
581 label_length += text_offset;
582 label_height = (top - bot)/2.0f;
583 // printf("l %f r %f b %f t %f\n",left, right, bot, top );
585 // Start by calculating the points and drawing the
591 // Make zero point wider on left
593 x_ini -= zero_offset;
594 x_end2 +=zero_offset;
596 //draw climb bar vertical lines
597 if (climb_dive_ladder) {
598 // Zero or above draw solid lines
599 Line(x_end, y-5.0, x_end, y);
600 Line(x_ini2, y-5.0, x_ini2, y);
602 // draw pitch / climb bar
603 Line(x_ini, y, x_end, y);
604 Line(x_ini2, y, x_end2, y);
606 if (i == 90 && zenith == 1)
607 drawZenith(x_ini2, x_end,y);
610 // draw dive bar vertical lines
611 if (climb_dive_ladder) {
612 Line(x_end, y+5.0, x_end, y);
613 Line(x_ini2, y+5.0, x_ini2, y);
616 // draw pitch / dive bars
617 StippleLine(x_ini, y, x_end, y);
618 StippleLine(x_ini2, y, x_end2, y);
620 if (i == -90 && nadir == 1)
621 drawNadir(x_ini2, x_end,y);
624 // Now calculate the location of the left side label using
625 Text( x_ini-label_length, y-label_height, TextLadder );
626 Text(x_end2+text_offset, y-label_height, TextLadder );
630 // OBJECT LADDER MARK
632 // ATTRIB - ON CONDITION
633 // draw appraoch glide slope marker
634 #ifdef ENABLE_SP_FMDS
635 if (glide_slope_marker && ihook) {
636 Line(-half_span+15, (glide_slope-actslope)*factor, -half_span + hole, (glide_slope-actslope)*factor);
637 Line(half_span-15, (glide_slope-actslope)*factor, half_span - hole, (glide_slope-actslope)*factor);
638 } // if glide_slope_marker
647 glEnable(GL_LINE_STIPPLE);
648 glLineStipple( 1, 0x00FF );
649 StippleLineList.draw( );
650 glDisable(GL_LINE_STIPPLE);
652 glDisable(GL_CLIP_PLANE0);
653 glDisable(GL_CLIP_PLANE1);
654 glDisable(GL_CLIP_PLANE2);
655 // glDisable(GL_SCISSOR_TEST);
657 //*************************************************************
659 //*************************************************************
660 #ifdef ENABLE_SP_FMDS
661 if (waypoint_marker) {
662 //waypoint marker computation
663 float fromwp_lat,towp_lat,fromwp_lon,towp_lon,dist,delx,dely,hyp,theta,brg;
665 fromwp_lon = get_longitude()*SGD_DEGREES_TO_RADIANS;
666 fromwp_lat = get_latitude()*SGD_DEGREES_TO_RADIANS;
667 towp_lon = get_aux2()*SGD_DEGREES_TO_RADIANS;
668 towp_lat = get_aux1()*SGD_DEGREES_TO_RADIANS;
670 dist = acos(sin(fromwp_lat)*sin(towp_lat)+cos(fromwp_lat)*cos(towp_lat)*cos(fabs(fromwp_lon-towp_lon)));
671 delx= towp_lat - fromwp_lat;
672 dely = towp_lon - fromwp_lon;
673 hyp = sqrt(pow(delx,2)+pow(dely,2));
676 theta = asin(dely/hyp);
680 brg = theta*SGD_RADIANS_TO_DEGREES;
686 // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
687 // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
689 dist = dist*SGD_RADIANS_TO_DEGREES * 60.0*1852.0; //rad->deg->nm->m
690 // end waypoint marker computation
692 //*********************************************************
693 // OBJECT MOVING RETICLE
696 if (fabs(brg-psi) > 10.0) {
698 glTranslatef( centroid.x, centroid.y, 0);
699 glTranslatef( vel_x, vel_y, 0);
700 glRotatef(brg - psi,0.0,0.0,-1.0);
701 glBegin(GL_LINE_LOOP);
702 glVertex2f(-2.5,20.0);
703 glVertex2f(-2.5,30.0);
704 glVertex2f(-5.0,30.0);
705 glVertex2f(0.0,35.0);
706 glVertex2f(5.0,30.0);
707 glVertex2f(2.5,30.0);
708 glVertex2f(2.5,20.0);
713 // waypoint marker on heading scale
714 if (fabs(brg-psi) < 12.0) {
716 glBegin(GL_LINE_LOOP);
717 glVertex2f(((brg-psi)*60/25)+320,240.0);
718 glVertex2f(((brg-psi)*60/25)+326,240.0-4);
719 glVertex2f(((brg-psi)*60/25)+323,240.0-4);
720 glVertex2f(((brg-psi)*60/25)+323,240.0-8);
721 glVertex2f(((brg-psi)*60/25)+317,240.0-8);
722 glVertex2f(((brg-psi)*60/25)+317,240.0-4);
723 glVertex2f(((brg-psi)*60/25)+314,240.0-4);
727 float x = (brg-psi)*60/25 + 320, y = 240.0, r = 5.0;
730 glEnable(GL_POINT_SMOOTH);
733 for (int count = 0; count <= 200; count++) {
734 float temp = count * 3.142 * 3 / (200.0*2.0);
735 float temp1 = temp-(45.0*SGD_DEGREES_TO_RADIANS);
736 x1 = x + r * cos(temp1);
737 y1 = y + r * sin(temp1);
742 glDisable(GL_POINT_SMOOTH);
746 } // if waypoint_marker
751 /******************************************************************/
752 // draws the zenith symbol for highest possible climb angle (i,e 90 degree climb angle)
754 void HudLadder::drawZenith(float xfirst,float xlast,float yvalue)
756 float xcentre = (xfirst + xlast)/2.0;
757 float ycentre = yvalue;
759 Line(xcentre-9.0, ycentre, xcentre-3.0, ycentre+1.3);
760 Line(xcentre-9.0, ycentre, xcentre-3.0, ycentre-1.3);
762 Line(xcentre+9.0, ycentre, xcentre+3.0, ycentre+1.3);
763 Line(xcentre+9.0, ycentre, xcentre+3.0, ycentre-1.3);
765 Line(xcentre, ycentre+9.0, xcentre-1.3, ycentre+3.0);
766 Line(xcentre, ycentre+9.0, xcentre+1.3, ycentre+3.0);
768 Line(xcentre-3.9, ycentre+3.9, xcentre-3.0, ycentre+1.3);
769 Line(xcentre-3.9, ycentre+3.9, xcentre-1.3, ycentre+3.0);
771 Line(xcentre+3.9, ycentre+3.9, xcentre+1.3, ycentre+3.0);
772 Line(xcentre+3.9, ycentre+3.9, xcentre+3.0, ycentre+1.3);
774 Line(xcentre-3.9, ycentre-3.9, xcentre-3.0, ycentre-1.3);
775 Line(xcentre-3.9, ycentre-3.9, xcentre-1.3, ycentre-2.6);
777 Line(xcentre+3.9, ycentre-3.9, xcentre+3.0, ycentre-1.3);
778 Line(xcentre+3.9, ycentre-3.9, xcentre+1.3, ycentre-2.6);
780 Line(xcentre-1.3, ycentre-2.6, xcentre, ycentre-27.0);
781 Line(xcentre+1.3, ycentre-2.6, xcentre, ycentre-27.0);
785 // draws the nadir symbol for lowest possible dive angle (i,e 90 degree dive angle)
787 void HudLadder::drawNadir(float xfirst, float xlast, float yvalue)
789 float xcentre = (xfirst + xlast)/2.0;
790 float ycentre = yvalue;
796 float xcent1, xcent2, ycent1, ycent2;
797 xcent1 = xcentre + r * cos(0.0);
798 ycent1 = ycentre + r * sin(0.0);
800 for (int count=1; count<=400; count++) {
801 float temp = count * 2 * 3.142 / 400.0;
802 xcent2 = xcentre + r * cos(temp);
803 ycent2 = ycentre + r * sin(temp);
805 Line(xcent1, ycent1, xcent2, ycent2);
811 xcent2 = xcentre + r * cos(0.0);
812 ycent2 = ycentre + r * sin(0.0);
814 drawOneLine(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
817 Line(xcentre, ycentre+7.5, xcentre, ycentre+22.5); //to draw a line above the circle
819 Line(xcentre-7.5, ycentre, xcentre+7.5,ycentre); //line in the middle of circle
821 float theta = asin (2.5/7.5);
822 float theta1 = asin(5.0/7.5);
824 x1 = xcentre + r * cos(theta);
826 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
830 x1 = xcentre + r * cos(theta1);
832 x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS)-theta1);
836 x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) +theta);
838 x2 = xcentre + r * cos((360.0* SGD_DEGREES_TO_RADIANS)-theta);
842 x1 = xcentre + r * cos((180.0* SGD_DEGREES_TO_RADIANS) +theta1);
844 x2 = xcentre + r * cos((360.0* SGD_DEGREES_TO_RADIANS)-theta1);