The NodeTilt( ) Function

Displays a feature on the Earth's surface as a small filled circle which is tilted if necessary so that it appears as an ellipse whose major to minor axis ratio shows the effect of the Earth's curvature according to the feature's displacement from the point of observation at the centre of the screen.
ShowNode (
  double *p,             //Pointers to feature's EARTH &
  int *q,                //SCREEN co-ordinates arrays.
  char *n,               //Pointer to annotation name.
  int c                  //Display colour (can be black)
) {
  double
    tilt = *(p + 2),     //tilt of feature on the Earth
    CosPsi = *(p + 3),   //Cosine of bearing
    TanPsi = *(p + 4),   //Bearing of feature from centre
    t,                   //Angle in generation of ellipse
    z, w;                //Working variables

  int
    x = *(q + 1),        //x-position of observed object
    y = *(q + 2),        //y-position of observed object
    i = 1,               //`first time through' switch
    r = 7,               //major axis radius of ellipse
    u,                   //Ellipse-gen X-displacement
    v,                   //Ellipse-gen Y-displacement
    l = 0,               //Nš of characters in annotation
    c = *(n + 14) - 48;  //Display colour

  If(CosPsi != 0) {      //To prevent division by zero
    if(s) c = 0;         //set colour black if re-display
    _setcolor(c);

  //Take t round in a full circle in 0.1 radian steps

    for(t = 6.5; t > 0; t -= .1) {
      w = tilt * r * cos(t);
      z = CosPsi * (r * sin(t) - w * TanPsi);
      v = w / CosPsi + z * TanPsi;
      u = z;
      if(i == 0)                 //If not first pass of loop,
        _lineto( x + u, y + v ); //draw line to next valid point
      else {
        i = 0;                   //else clear `first pass' flag
        _moveto( x + u, y + v ); //and set position to start of 
      }                          //ellipse locus.
    }
    _floodfill(x, y, c);         //Fill in the ellipse
    while(*n != ' ') {l++; n++;} //Find length of city name
    n -= l;

    /* Annotate the ellipse with the name of the city or way 
       point it represents. Place the name at the left, right,
       above or below the ellipse as appropriate. */

    switch(*(n + 15)) {
      case 'L': x -= (7 + l * 7); break;            //left
      case 'R': x += 10; break;                     //right
      case 'A': x -= (l * 7 / 2); y -= 13; break;   //above
      case 'B': x -= (l * 7 / 2); y += 13;          //below
    } annotate( x, y, l, n );
  }
}
Please note that this function is not used in the current demonstrator.
This page's parent within this Web Site. About this Web Site. Its home page. Email its Author.