/** Air Navigation Waypoint Intercept Demonstrator by Robert J Morton UK-YE572246C 21 Oct 1997 */ /* Plots the encounter on a 350 by 200 colour raster which is displayed by the applet class WayPtApp.class */ import java.awt.Color; class wpcolour { // Waypoint Colour Array double π = Math.PI, // the circular constant two_π = π + π, half_π = π / 2; int XW = 330, // x-width: horizontal width of tracking area YH = 200; // y-height: vertical height of tracking area Color BGC, // background colour of track area ATC = Color.white, // aircraft track colour SRC, // selected radial colour GCC, // green circle colour RCC, // red circle colour C[][]; // to store the picture so far wpcolour() { // CONSTRUCTOR C = new Color[XW][YH]; // create the tracking area array GCC = new java.awt.Color(0,255,72); // bright green for circle RCC = new java.awt.Color(255,0,72); // bright red for circle BGC = new java.awt.Color(0,0,160); // browny-green for axes SRC = new java.awt.Color(0,192,192); // cyan for selected radial } // DRAW THE APPROACH CONSTRUCTS ON THE DISPLAY RASTER void InitC(aircraft ac, waypoint wp, double OSR) { int i, j; // Set all pixels in the tracking square to the background colour. for(i = 0 ; i < XW ; i++) for(j = 0 ; j < YH ; j++) C[i][j] = BGC; /* DRAW THE RED AND GREEN GUDE CIRCLES The radius of the right-hand guide circle perpendicular to the selected radial line. */ double a = OSR + half_π, /* The co-ordinates of the centre of the right-hand guide circle expressed as displacements from the waypoint. */ xr = ac.r * Math.sin(a), yr = ac.r * Math.cos(a); /* The radius of the left-hand guide circle perpendicular to the selected radial line. */ a = OSR - half_π; /* The co-ordinates of the centre of the left-hand guide circle expressed as displacements from the waypoint. */ double xl = ac.r * Math.sin(a), yl = ac.r * Math.cos(a), x, y; // local working variables for use within the 'for' loops // For every degree round a guide circle... for(a = 0; a <= two_π; a += .017453292) { /* Compute the absolute co-ordinates of one point on a generic guide circle centred on the waypoint. */ x = wp.X + ac.r * Math.sin(a); y = wp.Y + ac.r * Math.cos(a); /* Compute the pixel position appropriately biased for the right-hand circle and set it green. Do the same for the left-hand circle and set it red. */ C[(int)(xr + x)][(int)(yr + y)] = GCC; C[(int)(xl + x)][(int)(yl + y)] = RCC; } // DRAW THE SELECTED RADIAL LINE IN THE APPROPRIATE COLOUR for(i = 0 ; i < wp.R ; i++) { x = i * Math.sin(OSR); y = i * Math.cos(OSR); C[(int)(x + wp.X)][(int)(y + wp.Y)] = SRC; } // Draw the waypoint as a small white square ... int I = (int)wp.X, J = (int)wp.Y; for(i = I - 2 ; i < I + 3 ; i++) for(j = J - 2 ; j < J + 3 ; j++) C[i][j] = ATC; // ... rounded off at the corners to make it into a circular blob. C[I - 2][J - 2] = BGC; C[I + 2][J + 2] = BGC; C[I - 2][J + 2] = BGC; C[I + 2][J - 2] = BGC; // DRAW THE LITTLE NORTH ARROW I = 30; J = 150; for(i = -10 ; i < 11 ; i++) C[I + i][J] = Color.white; for(j = -20 ; j < 21 ; j++) C[I][J + j] = Color.white; for(i = -3 ; i < 0 ; i++) { C[I + i][J + 20 + i] = Color.white; C[I - i][J + 20 + i] = Color.white; } for(j = -2 ; j < 3 ; j++) C[I - 2][J + 25 + j] = Color.white; for(j = -2 ; j < 3 ; j++) C[I + 2][J + 25 + j] = Color.white; for(j = -1 ; j < 2 ; j++) C[I - j][J + 25 + j] = Color.white; } // Plot the air4craft's current position on the tracking display raster. void PlotPosn(aircraft ac) { C[(int)ac.x][(int)ac.y] = ATC; } }