Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/hp2graph/area.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include "hp2graph.h"


double areaID(double *xs, UInt *ys, int size)
{
  double area = 0;
  int i;
  for(i=1; i<size; i++)
    area += (xs[i]-xs[i-1])/2*(double)(ys[i]+ys[i-1]);
  return area;
}
   
int areaEntries(Entry *ep)
{
  int no = 0;
  while (ep) {
    UInt height = 0;
    Value *vp = ep->value;
    memset(yUInts,0,samplesize*sizeof(UInt));
    no++;
    while(vp) {
      yUInts[vp->census] = vp->size;
      if(vp->size > height) height = vp->size;
      vp = vp->next;
    }
    ep->height = height;
    ep->area = areaID(sampledata,yUInts,samplesize);
    ep = ep->next;
  }
  return no;
}

double areaAll(void)
{
  int i;
  double area = 0;
  for(i=0; i<entrysize; i++)
    area += entrydata[i]->area;
  return area;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.