Beispiel #1
0
calc::calc(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

    setFixedSize(sizeHint());

    clearall();

    connect (Button1,SIGNAL(clicked()),this,SLOT(add1()));
    connect (Button2,SIGNAL(clicked()),this,SLOT(add2()));
    connect (Button3,SIGNAL(clicked()),this,SLOT(add3()));
    connect (Button4,SIGNAL(clicked()),this,SLOT(add4()));
    connect (Button5,SIGNAL(clicked()),this,SLOT(add5()));
    connect (Button6,SIGNAL(clicked()),this,SLOT(add6()));
    connect (Button7,SIGNAL(clicked()),this,SLOT(add7()));
    connect (Button8,SIGNAL(clicked()),this,SLOT(add8()));
    connect (Button9,SIGNAL(clicked()),this,SLOT(add9()));
    connect (Button0,SIGNAL(clicked()),this,SLOT(add0()));
    connect (backButton,SIGNAL(clicked()),this,SLOT(delnum()));
    connect (pointButton,SIGNAL(clicked()),this,SLOT(insertpoint()));
    connect (plusButton,SIGNAL(clicked()),this,SLOT(plus()));
    connect (minusButton,SIGNAL(clicked()),this,SLOT(minus()));
    connect (multiplyButton,SIGNAL(clicked()),this,SLOT(multiply()));
    connect (divideButton,SIGNAL(clicked()),this,SLOT(divide()));
    connect (equalButton,SIGNAL(clicked()),this,SLOT(equal()));
    connect (CButton,SIGNAL(clicked()),this,SLOT(clearall()));
    connect (actionAbout_Qt,SIGNAL(triggered()),this,SLOT(about()));
    connect (actionExit,SIGNAL(triggered()),this,SLOT(close()));
    connect (pmButton,SIGNAL(clicked()),this,SLOT(togglepm()));
}
Beispiel #2
0
void  scopePlot::plotData(unsigned int size,
                          double * dData1, QString curve1Name, QString yLLabel,
                          double * dData2, QString curve2Name, QString yRLabel)
{	
  add1(dData1,size,curve1Name,yLLabel);
  add3(dData2,size,curve2Name,yRLabel);
  show();
}
int init (int v) {
  int zero = 0;
  int sept = 7;
  x = v;
  y = sept;
  z = add3 (x, y, zero); // TODO: add3(x, 7, 0); z = 12;
  int z1 = z ;
  return zero ;
}
Beispiel #4
0
// This function will be inlined into external callers by
// interprocedural optimization (IPO).
float sum(float a[], int n)
{
  float result; 
  int i;
  result = 0;
  for (i = 0; i < n; i++) 
    result += a[i] + add3(a[i]);
  return result; 
}
int main(void)
{
	printf("add2(%d, %d)     = %d\n", 3, 1,    add2(3, 1));
	printf("add3(%d, %d, %d) = %d\n", 1, 3, 1, add3(1, 3, 1));
	printf("bic(%d, %d)      = %d\n", 3, 1,    bic(3, 1));
	printf("mvn(%d, %d)      = %d\n", 3, 1,    mvn(3, 1));
	printf("rsb3(%d, %d, %d) = %d\n", 3, 1, 1, rsb3(3, 1, 1));
	printf("rsb1(%d)         = %d\n", 3,       rsb1(3));
	return 0;
}
Beispiel #6
0
void Mesh::add3_with_auto_normals(const std::array<glm::vec3, 3> &positions, const glm::vec3 &origin)
{
  const glm::vec3 sample = glm::normalize((positions[1] - positions[0]) * (positions[2] - positions[0]));
  // TODO Handle if direction is zero vector (origin is in vertex 0) - use some other vertex
  const glm::vec3 direction = glm::normalize(positions[0] - origin);
  const float angle = glm::angle(direction, sample);
  const glm::vec3 normal = angle <= glm::radians(90.0f) ? sample : -sample;

  add3(positions, normal);
}
Beispiel #7
0
static void *start_routine_3(void *arg)
{
    int x, status;
    x = add3(1000, 200, 30, 4);
    assert(x == 1234);

    status = sem_post(&done);
    assert(status == 0);

    return arg;
}
Beispiel #8
0
void test_vector_ifft() {
	logMsg("playing IFFT crossfade...");
	IFFT vox1, vox2;

	vox1.set_bin_mag_phase(2, 0.25, 0);
	vox1.set_bin_mag_phase(4, 0.25, 0);
	vox2.set_bin_mag_phase(6, 0.25, 0);
	vox2.set_bin_mag_phase(8, 0.25, 0);
	LineSegment env1(3, 1, 0);	// fade out
	LineSegment env2(3, 0, 1);	// fade in
	MulOp mul1(vox1, env1);	
	MulOp mul2(vox2, env2);
	AddOp add3(mul1, mul2);	
	run_test(add3);
	logMsg("IFFT crossfade done.");
}
void main(int a) {
  test_ull ();
  test_struct () ;
  test_struct_ptr () ;
  test_tab (13) ;
  test_float_double ();

  int b = init(5);  // TODO: init(5); b = 0;
  z = add3 (a, 0, 0);

  int *p = test_ptr (y);
  //@ assert *p == 7 ;
  int *q = a?p:&y;
  int yy = *q;
  //@ assert a==0 ==> q==&y ;
  //@ assert *q == 7 ;

}
Beispiel #10
0
int main () {
    /* Create custom arbitrary data. */
    const uint8_t uint8_data[] = { 1, 2, 3, 4, 5, 6, 7, 8,
				   9, 10, 11, 12, 13, 14, 15, 16 };

    /* Create the vector with our data. */
    uint8x16_t data;

    /* Load our custom data into the vector register. */
    data = vld1q_u8 (uint8_data);

    print_uint8 (data, "data");
    
    /* Call of the add3 function. */
    add3(&data);

    print_uint8 (data, "data (new)");
    
    return 0;
}
Beispiel #11
0
MobileWindow::MobileWindow(MusicPlayer* player) 
{
	ui.setupUi(this);

	this->player = player;

	//initFolderList();

	// SIGNALS
	// CALL NUMBERS
	connect(ui.call1Button, SIGNAL(clicked()), this, SLOT(add1()));
	connect(ui.call2Button, SIGNAL(clicked()), this, SLOT(add2()));
	connect(ui.call3Button, SIGNAL(clicked()), this, SLOT(add3()));
	connect(ui.call4Button, SIGNAL(clicked()), this, SLOT(add4()));
	connect(ui.call5Button, SIGNAL(clicked()), this, SLOT(add5()));
	connect(ui.call6Button, SIGNAL(clicked()), this, SLOT(add6()));
	connect(ui.call7Button, SIGNAL(clicked()), this, SLOT(add7()));
	connect(ui.call8Button, SIGNAL(clicked()), this, SLOT(add8()));
	connect(ui.call9Button, SIGNAL(clicked()), this, SLOT(add9()));
	connect(ui.call0Button, SIGNAL(clicked()), this, SLOT(add0()));
	connect(ui.callAsteriskButton, SIGNAL(clicked()), this, SLOT(addAsterisk()));
	connect(ui.callHashButton, SIGNAL(clicked()), this, SLOT(addHash()));
	
	// CALL, HANG UP AND DELETE BUTTONS
	connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDigit()));
	connect(ui.callButton, SIGNAL(clicked()), this, SLOT(call()));
	connect(ui.hangUpButton, SIGNAL(clicked()), this, SLOT(hangUp()));

	// CONTACTS 
	connect(ui.contactList, SIGNAL(itemSelectionChanged()), this, SLOT(contactSelected()));
		
	// FILL CONTACTS
	ddbb.readFromFile("ddbb\\contacts.xml");
	QList<Contact*> contacts = ddbb.getContacts();

	foreach (Contact* c,contacts) {
		ui.contactList->addItem(c->name);
	}
Beispiel #12
0
void addtraverse(node2 *a, node2 *b, node2 *c, long *m, long *n,
                 valptr valyew, placeptr place)
{
    /* traverse all places to add b */
    if (done)
        return;
    if ((*m) <= 2 || !(noroot && (a == root || a == root->next->back))) {
        add3(a, b, c, &root, treenode);
        (*n)++;
        evaluate(root);
        examined++;
        if (examined == howoften) {
            examined = 0;
            mults++;
            if (mults == howmanny)
                done = true;
            if (progress) {
                printf("%6ld", mults);
                if (bestyet >= 0)
                    printf("%18.5f", bestyet);
                else
                    printf("         -        ");
                printf("%17ld%20.2f\n", nextree - 1, fracdone * 100);
#ifdef WIN32
                phyFillScreenColor();
#endif
            }
        }
        valyew[(*n) - 1] = like;
        place[(*n) - 1] = a->index;
        re_move3(&b, &c, &root, treenode);
    }
    if (!a->tip) {
        addtraverse(a->next->back, b, c, m,n,valyew,place);
        addtraverse(a->next->next->back, b, c, m,n,valyew,place);
    }
}  /* addtraverse */
Beispiel #13
0
int
MeshEdgeElementTable::calcLineIntersections(int elem_index, short elem_dir,
                                            Point3& lstart, Point3& ldir, Point3* isec_points)
{
  meshElementCode elem_code = getElementCode(elem_index);

  if (elem_code <  MEC_202 || elem_code >= 303)
    return 0;

  const int* nodeIds = getNodeIds(elem_index, elem_dir);

  Point3& p0 = meshNodes[nodeIds[0]];
  Point3& p1 = meshNodes[nodeIds[1]];
  
  Point3& normal = normals[elem_index];
  if (elem_dir == -1)
    scalarmult(-1, normal, normal);

  // Check end-point cases
  if ( samepoint(p0, lstart) ){
    copy3(p0, *isec_points);
    return 1;
  }
  if ( samepoint(p1, lstart) ){
    copy3(p1, *isec_points);
    return 1;
  }


  Point3 edge_dir, l_delta0, tmp;
 
  // Edge direction vector (normalized)
  edge_dir[0] = normal[1];
  edge_dir[1] = -1 * normal[0];
  edge_dir[2] = 0.0;

  // Edge length
  diff3(p1, p0, tmp);
  double edge_len = dot3(edge_dir, tmp);

  // Vector l_delta0 = lstart - p0
  diff3(lstart, p0, l_delta0);

  // Check that intersection is "within" the edge
  // project the intersection point to the edge
  double t = dot3(edge_dir, l_delta0);
  if ( isLess(t, 0.0) ||
       isGreater(t, edge_len)
     )
    return 0;

  // Check that intersection distance from the edge is ok
  // project intersection point to the edge normal
  double d = dot3(normal, l_delta0);
  if (d < 0)
    d *= -1;
  if ( isGreater(d, MeshEdgeElementTable::pickingTolerance) )
    return 0;

  // Intersection point is: p0 + t * (p1 - p0)
  scalarmult(t, edge_dir, tmp);
  add3(p0, tmp, *isec_points);

  return 1;
}
Beispiel #14
0
void addit(long m)
{
    /* adds the species one by one, recursively */
    long n;
    valptr valyew;
    placeptr place;
    long i, j, n1, besttoadd = 0;
    valptr bestval;
    placeptr bestplace;
    double oldfrac, oldfdone, sum, bestsum;

    valyew = (valptr)Malloc(nonodes*sizeof(double));
    bestval = (valptr)Malloc(nonodes*sizeof(double));
    place = (placeptr)Malloc(nonodes*sizeof(long));
    bestplace = (placeptr)Malloc(nonodes*sizeof(long));
    if (simple && !firsttime) {
        n = 0;
        added[order[m - 1] - 1] = true;
        addtraverse(root, treenode[order[m - 1] - 1],
                    treenode[spp + m - 2], &m,&n,valyew,place);
        besttoadd = order[m - 1];
        memcpy(bestplace, place, nonodes*sizeof(long));
        memcpy(bestval, valyew, nonodes*sizeof(double));
    } else {
        bestsum = -1.0;
        for (i = 1; i <= (spp); i++) {
            if (!added[i - 1]) {
                n = 0;
                added[i - 1] = true;
                addtraverse(root, treenode[i - 1], treenode[spp + m - 2], &m,
                            &n,valyew,place);
                added[i - 1] = false;
                sum = 0.0;
                for (j = 0; j < (n); j++)
                    sum += valyew[j];
                if (sum > bestsum) {
                    bestsum = sum;
                    besttoadd = i;
                    memcpy(bestplace, place, nonodes*sizeof(long));
                    memcpy(bestval, valyew, nonodes*sizeof(double));
                }
            }
        }
    }
    order[m - 1] = besttoadd;
    memcpy(place, bestplace, nonodes*sizeof(long));
    memcpy(valyew, bestval, nonodes*sizeof(double));
    shellsort(valyew, place, n);
    oldfrac = fracinc;
    oldfdone = fracdone;
    n1 = 0;
    for (i = 0; i < (n); i++) {
        if (valyew[i] <= bestyet || bestyet < 0.0)
            n1++;
    }
    if (n1 > 0)
        fracinc /= n1;
    for (i = 0; i < (n); i++) {
        if (valyew[i] <= bestyet || bestyet < 0.0) {
            current[m - 1] = place[i];
            add3(treenode[place[i] - 1], treenode[besttoadd - 1],
                 treenode[spp + m - 2], &root, treenode);
            added[besttoadd - 1] = true;
            if (m < spp)
                addit(m + 1);
            else {
                if (valyew[i] < bestyet || bestyet < 0.0) {
                    nextree = 1;
                    bestyet = valyew[i];
                }
                if (nextree <= maxtrees) {
                    memcpy(bestorders[nextree - 1], order,
                           spp*sizeof(long));
                    memcpy(bestrees[nextree - 1], current,
                           spp*sizeof(long));
                }
                nextree++;
                firsttime = false;
            }
            re_move3(&treenode[besttoadd - 1], &treenode[spp + m - 2], &root, treenode);
            added[besttoadd - 1] = false;
        }
        fracdone += fracinc;
    }
    fracinc = oldfrac;
    fracdone = oldfdone;
    free(valyew);
    free(bestval);
    free(place);
    free(bestplace);
}  /* addit */
Beispiel #15
0
void rf (const char *name)
{
  struct stat st, st2, st3;
  const size_t namelen = strlen(name);
  nobjects++;
  if (lstat (name, &st))
    return;
  if (st.st_dev != dev && !force) {
    if (dev) {
      fprintf(stderr, "%s is on different filesystem than the rest.\nUse -f option to override.\n", name);
      doexit(6);
    }
    dev = st.st_dev;
  }
  if (S_ISDIR (st.st_mode)) {
    d * dp = malloc(add3(sizeof(d), namelen, 1));
    if (!dp) {
      fprintf(stderr, "\nOut of memory 3\n");
      doexit(3);
    }
    memcpy(dp->name, name, namelen + 1);
    dp->next = dirs;
    dirs = dp;
  } else if (S_ISREG (st.st_mode)) {
    int fd, i;
    f * fp, * fp2;
    h * hp;
    const char *n1, *n2;
    int cksumsize = sizeof(buf);
    unsigned int cksum;
    time_t mtime = content_only ? 0 : st.st_mtime;
    unsigned int hsh = hash (st.st_size, mtime);
    off_t fsize;
    nregfiles++;
    if (verbose > 1)
      fprintf(stderr, "  %s", name);
    fd = open (name, O_RDONLY);
    if (fd < 0) return;
    if (st.st_size < sizeof(buf)) {
      cksumsize = st.st_size;
      memset (((char *)buf) + cksumsize, 0, (sizeof(buf) - cksumsize) % sizeof(buf[0]));
    }
    if (read (fd, buf, cksumsize) != cksumsize) {
      close(fd);
      if (verbose > 1 && namelen <= NAMELEN)
        fprintf(stderr, "\r%*s\r", (int)(namelen + 2), "");
      return;
    }
    cksumsize = (cksumsize + sizeof(buf[0]) - 1) / sizeof(buf[0]);
    for (i = 0, cksum = 0; i < cksumsize; i++) {
      if (cksum + buf[i] < cksum)
        cksum += buf[i] + 1;
      else
        cksum += buf[i];
    }
    for (hp = hps[hsh]; hp; hp = hp->next)
      if (hp->size == st.st_size && hp->mtime == mtime)
        break;
    if (!hp) {
      hp = malloc(sizeof(h));
      if (!hp) {
        fprintf(stderr, "\nOut of memory 1\n");
        doexit(1);
      }
      hp->size = st.st_size;
      hp->mtime = mtime;
      hp->chain = NULL;
      hp->next = hps[hsh];
      hps[hsh] = hp;
    }
    for (fp = hp->chain; fp; fp = fp->next)
      if (fp->cksum == cksum)
        break;
    for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next)
      if (fp2->ino == st.st_ino && fp2->dev == st.st_dev) {
        close(fd);
        if (verbose > 1 && namelen <= NAMELEN)
          fprintf(stderr, "\r%*s\r", (int)(namelen + 2), "");
        return;
      }
    for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next)
      if (!lstat (fp2->name, &st2) && S_ISREG (st2.st_mode) &&
          !stcmp (&st, &st2, content_only) &&
          st2.st_ino != st.st_ino &&
          st2.st_dev == st.st_dev) {
        int fd2 = open (fp2->name, O_RDONLY);
        if (fd2 < 0) continue;
        if (fstat (fd2, &st2) || !S_ISREG (st2.st_mode) || st2.st_size == 0) {
          close (fd2);
          continue;
        }
        ncomp++;
	lseek(fd, 0, SEEK_SET);
	for (fsize = st.st_size; fsize > 0; fsize -= NIOBUF) {
	  off_t rsize = fsize >= NIOBUF ? NIOBUF : fsize;
	  if (read (fd, iobuf1, rsize) != rsize || read (fd2, iobuf2, rsize) != rsize) {
	    close(fd);
	    close(fd2);
	    fprintf(stderr, "\nReading error\n");
	    return;
	  }
	  if (memcmp (iobuf1, iobuf2, rsize)) break;
	}
	close(fd2);
	if (fsize > 0) continue;
        if (lstat (name, &st3)) {
          fprintf(stderr, "\nCould not stat %s again\n", name);
          close(fd);
          return;
        }
        st3.st_atime = st.st_atime;
        if (stcmp (&st, &st3, 0)) {
          fprintf(stderr, "\nFile %s changed underneath us\n", name);
          close(fd);
          return;
        }
        n1 = fp2->name;
        n2 = name;
        if (!no_link) {
          const char *suffix = ".$$$___cleanit___$$$";
          const size_t suffixlen = strlen(suffix);
          size_t n2len = strlen(n2);
          dynstr nam2 = {NULL, 0};
          growstr(&nam2, add2(n2len, suffixlen));
          memcpy(nam2.buf, n2, n2len);
          memcpy(&nam2.buf[n2len], suffix, suffixlen + 1);
          if (rename (n2, nam2.buf)) {
            fprintf(stderr, "\nFailed to rename %s to %s\n", n2, nam2.buf);
            free(nam2.buf);
            continue;
          }
          if (link (n1, n2)) {
            fprintf(stderr, "\nFailed to hardlink %s to %s\n", n1, n2);
            if (rename (nam2.buf, n2)) {
              fprintf(stderr, "\nBad bad - failed to rename back %s to %s\n", nam2.buf, n2);
            }
            close(fd);
            free(nam2.buf);
            return;
          }
          unlink (nam2.buf);
          free(nam2.buf);
        }
        nlinks++;
        if (st3.st_nlink > 1) {
	  /* We actually did not save anything this time, since the link second argument
	     had some other links as well.  */
          if (verbose > 1)
            fprintf(stderr, "\r%*s\r%s %s to %s\n", (int)(((namelen > NAMELEN) ? 0 : namelen) + 2), "", (no_link ? "Would link" : "Linked"), n1, n2);
        } else {
          nsaved+=((st.st_size+4095)/4096)*4096;
          if (verbose > 1)
            fprintf(stderr, "\r%*s\r%s %s to %s, %s %ld\n", (int)(((namelen > NAMELEN) ? 0 : namelen) + 2), "", (no_link ? "Would link" : "Linked"), n1, n2, (no_link ? "would save" : "saved"), st.st_size);
	}
        close(fd);
        return;
      }
    fp2 = malloc(add3(sizeof(f), namelen, 1));
    if (!fp2) {
      fprintf(stderr, "\nOut of memory 2\n");
      doexit(2);
    }
    close(fd);
    fp2->ino = st.st_ino;
    fp2->dev = st.st_dev;
    fp2->cksum = cksum;
    memcpy(fp2->name, name, namelen + 1);
    if (fp) {
      fp2->next = fp->next;
      fp->next = fp2;
    } else {
      fp2->next = hp->chain;
      hp->chain = fp2;
    }
    if (verbose > 1 && namelen <= NAMELEN)
      fprintf(stderr, "\r%*s\r", (int)(namelen + 2), "");
    return;
  }
}
Beispiel #16
0
/* todo: implement this correctly */
vec3 model_gettrans(const uint32_t *mdl, int anim_id, double frame, int bone)
{
    uint8_t ngeo, nbone, nanim;
    const uint8_t *p, *tr, *qt;

    const chunkinfo_t *ck;
    const anim_t *anim;
    const bone_t *b;
    vec3 trans, ptrans;
    vec4 rot, prot;
    int i;

    vec3 translation[maxbones];
    vec3 rtrans[maxbones];
    vec4 rotation[maxbones];

    if (bone == 0xFF)
        return vec3(0.0, 0.0, 0.0);

    /* parse header */
    p = (const uint8_t*)mdl;
    ngeo = p[0];
    nbone = p[2];
    nanim = p[3];

    anim = (const anim_t*)&p[4];
    ck = (const chunkinfo_t*)&anim[nanim];
    p = (const uint8_t*)&ck[ngeo];
    anim += anim_id;

    frame = frame * anim->frames;

    /* calculate transformations for frame */
    i = 0;
    do {
        b = (const bone_t*)p;
        tr = (const uint8_t*)&b[1];
        qt = tr + nanim;
        p = qt + nanim;
        if(nanim & 1) { /* alignment */
            p += 2;
        }

        get_trans(&trans, p, tr, anim_id, frame);
        p += b->keyframes[0] * sizeof(keyframe_t);

        get_rot(&rot, p, qt, anim_id, frame);
        p += b->keyframes[1] * sizeof(keyframe4_t);

        if(b->parent < 0) {
            ptrans = vec3(0.0, 0.0, 0.0);
            prot = vec4(0.0, 0.0, 0.0, 1.0);
        } else {
            ptrans = rtrans[b->parent];
            prot = rotation[b->parent];
        }

        rotation[i] = mul4(rot, prot);
        translation[i] = add3(ptrans, qrot3(add3(b->pivot, trans), prot));
        rtrans[i] = add3(qrot3(neg3(b->pivot), rotation[i]), translation[i]);

        if (i == bone)
            return translation[i];

    } while(++i < nbone);

    return vec3(0.0, 0.0, 0.0);
}
Beispiel #17
0
void maketree()
{
    /* tree construction recursively by branch and bound */
    long i, j, k;
    node2 *dummy;

    fullset = (1L << (bits + 1)) - (1L << 1);
    if (progress) {
        printf("\nHow many\n");
        printf("trees looked                                       Approximate\n");
        printf("at so far      Length of        How many           percentage\n");
        printf("(multiples     shortest tree    trees this long    searched\n");
        printf("of %4ld):      found so far     found so far       so far\n",
               howoften);
        printf("----------     ------------     ------------       ------------\n");
#ifdef WIN32
        phyFillScreenColor();
#endif
    }
    done = false;
    mults = 0;
    examined = 0;
    nextree = 1;
    root = treenode[0];
    firsttime = true;
    for (i = 0; i < (spp); i++)
        added[i] = false;
    added[0] = true;
    order[0] = 1;
    k = 2;
    fracdone = 0.0;
    fracinc = 1.0;
    bestyet = -1.0;
    addit(k);
    if (done) {
        if (progress) {
            printf("Search broken off!  Not guaranteed to\n");
            printf(" have found the most parsimonious trees.\n");
        }
        if (treeprint) {
            fprintf(outfile, "Search broken off!  Not guaranteed to\n");
            fprintf(outfile, " have found the most parsimonious\n");
            fprintf(outfile, " trees, but here is what we found:\n");
        }
    }
    if (treeprint) {
        fprintf(outfile, "\nrequires a total of %18.3f\n\n", bestyet);
        if (nextree == 2)
            fprintf(outfile, "One most parsimonious tree found:\n");
        else
            fprintf(outfile, "%5ld trees in all found\n", nextree - 1);
    }
    if (nextree > maxtrees + 1) {
        if (treeprint)
            fprintf(outfile, "here are the first%4ld of them\n", (long)maxtrees);
        nextree = maxtrees + 1;
    }
    if (treeprint)
        putc('\n', outfile);
    for (i = 0; i < (spp); i++)
        added[i] = true;
    for (i = 0; i <= (nextree - 2); i++) {
        for (j = k; j <= (spp); j++)
            add3(treenode[bestrees[i][j - 1] - 1],
                 treenode[bestorders[i][j - 1] - 1], treenode[spp + j - 2],
                 &root, treenode);
        if (noroot)
            reroot(treenode[outgrno - 1]);
        didreroot = (outgropt && noroot);
        evaluate(root);
        printree(treeprint, noroot, didreroot, root);
        describe();
        for (j = k - 1; j < (spp); j++)
            re_move3(&treenode[bestorders[i][j] - 1], &dummy, &root, treenode);
    }
    if (progress) {
        printf("\nOutput written to file \"%s\"\n\n", outfilename);
        if (trout)
            printf("Trees also written onto file \"%s\"\n\n", outtreename);
    }
    if (ancseq)
        freegarbage(&garbage);
}  /* maketree */
Beispiel #18
0
void model_draw(const shader_t *s, GLuint utrans, GLuint uquats,
                const GLuint *texture, const uint32_t *mdl,
                int anim_id, double frame, const float *teamcolor,
                const float *color, uint16_t tex_over)
{
    /* assumes valid model data */
    uint8_t ngeo, teamcolor_end, nbone, nanim;
    const uint8_t *p, *tr, *qt;

    const chunkinfo_t *ck;
    const anim_t *anim;
    const bone_t *b;
    vec3 trans, ptrans;
    vec4 rot, prot;
    int vis, i, offset, tex;

    vec3 rtrans[maxbones];
    vec4 rotation[maxbones];

    /* parse header */
    p = (const uint8_t*)mdl;
    ngeo = p[0];
    teamcolor_end = p[1];
    nbone = p[2];
    nanim = p[3];

    anim = (const anim_t*)&p[4];
    ck = (const chunkinfo_t*)&anim[nanim];
    p = (const uint8_t*)&ck[ngeo];
    anim += anim_id;

    vis = anim->vis;
    frame = frame * anim->frames;

    /* calculate transformations for frame */
    i = 0;
    do {
        b = (const bone_t*)p;
        tr = (const uint8_t*)&b[1];
        qt = tr + nanim;
        p = qt + nanim;
        p = align4(p);

        get_trans(&trans, p, tr, anim_id, frame);
        p += b->keyframes[0] * sizeof(keyframe_t);

        get_rot(&rot, p, qt, anim_id, frame);
        p += b->keyframes[1] * sizeof(keyframe4_t);

        if(b->parent < 0) {
            ptrans = vec3(0.0, 0.0, 0.0);
            prot = vec4(0.0, 0.0, 0.0, 1.0);
        } else {
            ptrans = rtrans[b->parent];
            prot = rotation[b->parent];
        }

        rotation[i] = mul4(rot, prot);
        trans = add3(ptrans, qrot3(add3(b->pivot, trans), prot));
        rtrans[i] = add3(qrot3(neg3(b->pivot), rotation[i]), trans);
    } while (++i < nbone);

    /* load transformations */
    glUniform4fv(uquats, nbone, (float*)rotation);
    glUniform3fv(utrans, nbone, (float*)rtrans);

    //GLuint test;
    //glGenBuffers(1, &test);
    //
    //glBufferData(GL_ELEMENT_ARRAY_BUFFER, ck[ngeo - 1].index, indices, GL_STATIC_DRAW);

    /* draw visible vertices */
    i = 0;
    offset = 0;
    tex = 0xFFFF;
    glUniform4fv(s->k, 1, teamcolor);
    glUniform4fv(s->samp, 1, color);
    do {
        if(i == teamcolor_end)
            glUniform4fv(s->k, 1, transparency);

        if((vis & (1 << i))) {
            if (tex_over != 0xFFFF) {
                glBindTexture(GL_TEXTURE_2D, tex_over == 0xFFFE ? 0 : texture[tex_over]);
            } else if (ck[i].texture != tex) {
                tex = ck[i].texture;
                glBindTexture(GL_TEXTURE_2D, texture[tex]);
            }

            glDrawElements(GL_TRIANGLES, ck[i].index - offset, GL_UNSIGNED_SHORT, (void*)(size_t)offset);
        }
        offset = ck[i].index;
    } while(++i != ngeo);

    //glDeleteBuffers(1, &test);
}
Beispiel #19
0
void uiuc_gear()
{

    /*
     * Aircraft specific initializations and data goes here
     */

    static DATA percent_brake[MAX_GEAR] =	    /* percent applied braking */
    {   0.,  0.,  0., 0.,
        0.,  0.,  0., 0.,
        0.,  0.,  0., 0.,
        0.,  0.,  0., 0.
    };			    /* 0 = none, 1 = full */
    static DATA caster_angle_rad[MAX_GEAR] =	    /* steerable tires - in */
    {   0., 0., 0., 0.,
        0., 0., 0., 0.,
        0., 0., 0., 0.,
        0., 0., 0., 0.
    };                         /* radians, +CW */
    /*
     * End of aircraft specific code
     */

    /*
     * Constants & coefficients for tyres on tarmac - ref [1]
     */

    /* skid function looks like:
     *
     *           mu  ^
     *               |
     *       max_mu  |       +
     *               |      /|
     *   sliding_mu  |     / +------
     *               |    /
     *               |   /
     *               +--+------------------------>
     *               |  |    |      sideward V
     *               0 bkout skid
     *	               V     V
     */


    static int it_rolls[MAX_GEAR] =
    {   1, 1, 1, 0,
        0, 0, 0, 0,
        0, 0, 0, 0,
        0, 0, 0, 0
    };
    static DATA sliding_mu[MAX_GEAR] =
    {   0.5, 0.5, 0.5, 0.3,
        0.3, 0.3, 0.3, 0.3,
        0.3, 0.3, 0.3, 0.3,
        0.3, 0.3, 0.3, 0.3
    };
    static DATA max_brake_mu[MAX_GEAR] =
    {   0.0, 0.6, 0.6, 0.0,
        0.0, 0.0, 0.0, 0.0,
        0.0, 0.0, 0.0, 0.0,
        0.0, 0.0, 0.0, 0.0
    };
    static DATA max_mu	     = 0.8;
    static DATA bkout_v	     = 0.1;
    static DATA skid_v       = 1.0;
    /*
     * Local data variables
     */

    DATA d_wheel_cg_body_v[3];		/* wheel offset from cg,  X-Y-Z	*/
    DATA d_wheel_cg_local_v[3];		/* wheel offset from cg,  N-E-D	*/
    DATA d_wheel_rwy_local_v[3];	/* wheel offset from rwy, N-E-U */
    DATA v_wheel_cg_local_v[3];    /*wheel velocity rel to cg N-E-D*/
    // DATA v_wheel_body_v[3];		/* wheel velocity,	  X-Y-Z	*/
    DATA v_wheel_local_v[3];		/* wheel velocity,	  N-E-D	*/
    DATA f_wheel_local_v[3];		/* wheel reaction force,  N-E-D	*/
    // DATA altitude_local_v[3];       /*altitude vector in local (N-E-D) i.e. (0,0,h)*/
    // DATA altitude_body_v[3];        /*altitude vector in body (X,Y,Z)*/
    DATA temp3a[3];
    // DATA temp3b[3];
    DATA tempF[3];
    DATA tempM[3];
    DATA reaction_normal_force;		/* wheel normal (to rwy) force	*/
    DATA cos_wheel_hdg_angle, sin_wheel_hdg_angle;	/* temp storage */
    DATA v_wheel_forward, v_wheel_sideward,  abs_v_wheel_sideward;
    DATA forward_mu, sideward_mu;	/* friction coefficients	*/
    DATA beta_mu;			/* breakout friction slope	*/
    DATA forward_wheel_force, sideward_wheel_force;

    int i;				/* per wheel loop counter */

    /*
     * Execution starts here
     */

    beta_mu = max_mu/(skid_v-bkout_v);
    clear3( F_gear_v );		/* Initialize sum of forces...	*/
    clear3( M_gear_v );		/* ...and moments		*/

    /*
     * Put aircraft specific executable code here
     */

    percent_brake[1] = Brake_pct[0];
    percent_brake[2] = Brake_pct[1];

    caster_angle_rad[0] =
        (0.01 + 0.04 * (1 - V_calibrated_kts / 130)) * Rudder_pedal;


    for (i=0; i<MAX_GEAR; i++)	  /* Loop for each wheel */
    {
        // Execute only if the gear has been defined
        if (!gear_model[i])
        {
            // do nothing
            continue;
        }
        else
        {

            /*========================================*/
            /* Calculate wheel position w.r.t. runway */
            /*========================================*/

            /* printf("\thgcg: %g, theta: %g,phi: %g\n",D_cg_above_rwy,Theta*RAD_TO_DEG,Phi*RAD_TO_DEG); */

            /* First calculate wheel location w.r.t. cg in body (X-Y-Z) axes... */

            sub3( D_gear_v[i], D_cg_rp_body_v, d_wheel_cg_body_v );

            /* then converting to local (North-East-Down) axes... */

            multtrans3x3by3( T_local_to_body_m,  d_wheel_cg_body_v, d_wheel_cg_local_v );


            /* Runway axes correction - third element is Altitude, not (-)Z... */

            d_wheel_cg_local_v[2] = -d_wheel_cg_local_v[2]; /* since altitude = -Z */

            /* Add wheel offset to cg location in local axes */

            add3( d_wheel_cg_local_v, D_cg_rwy_local_v, d_wheel_rwy_local_v );

            /* remove Runway axes correction so right hand rule applies */

            d_wheel_cg_local_v[2] = -d_wheel_cg_local_v[2]; /* now Z positive down */

            /*============================*/
            /* Calculate wheel velocities */
            /*============================*/

            /* contribution due to angular rates */

            cross3( Omega_body_v, d_wheel_cg_body_v, temp3a );

            /* transform into local axes */

            multtrans3x3by3( T_local_to_body_m, temp3a,v_wheel_cg_local_v );

            /* plus contribution due to cg velocities */

            add3( v_wheel_cg_local_v, V_local_rel_ground_v, v_wheel_local_v );

            clear3(f_wheel_local_v);
            reaction_normal_force=0;

            fgSetBool("/gear/gear[0]/wow", false);
            fgSetBool("/gear/gear[1]/wow", false);
            fgSetBool("/gear/gear[2]/wow", false);
            if( HEIGHT_AGL_WHEEL < 0. )
                /*the wheel is underground -- which implies ground contact
                  so calculate reaction forces */
            {
                //set the property - weight on wheels
                //  	  if (i==0)
                //  	    {
                //  	      fgSetBool("/gear/gear[0]/wow", true);
                //  	    }
                //	  if (i==1)
                //	    {
                //	      fgSetBool("/gear/gear[1]/wow", true);
                //	    }
                //  	  if (i==2)
                //  	    {
                //  	      fgSetBool("/gear/gear[2]/wow", true);
                //  	    }

                /*===========================================*/
                /* Calculate forces & moments for this wheel */
                /*===========================================*/

                /* Add any anticipation, or frame lead/prediction, here... */

                /* no lead used at present */

                /* Calculate sideward and forward velocities of the wheel
                in the runway plane					*/

                cos_wheel_hdg_angle = cos(caster_angle_rad[i] + Psi);
                sin_wheel_hdg_angle = sin(caster_angle_rad[i] + Psi);

                v_wheel_forward  = v_wheel_local_v[0]*cos_wheel_hdg_angle
                                   + v_wheel_local_v[1]*sin_wheel_hdg_angle;
                v_wheel_sideward = v_wheel_local_v[1]*cos_wheel_hdg_angle
                                   - v_wheel_local_v[0]*sin_wheel_hdg_angle;


                /* Calculate normal load force (simple spring constant) */

                reaction_normal_force = 0.;

                reaction_normal_force = kgear[i]*d_wheel_rwy_local_v[2]
                                        - v_wheel_local_v[2]*cgear[i];
                /* printf("\treaction_normal_force: %g\n",reaction_normal_force); */

                if (reaction_normal_force > 0.) reaction_normal_force = 0.;
                /* to prevent damping component from swamping spring component */


                /* Calculate friction coefficients */

                if(it_rolls[i])
                {
                    forward_mu = (max_brake_mu[i] - muGear[i])*percent_brake[i] + muGear[i];
                    abs_v_wheel_sideward = sqrt(v_wheel_sideward*v_wheel_sideward);
                    sideward_mu = sliding_mu[i];
                    if (abs_v_wheel_sideward < skid_v)
                        sideward_mu = (abs_v_wheel_sideward - bkout_v)*beta_mu;
                    if (abs_v_wheel_sideward < bkout_v) sideward_mu = 0.;
                }
                else
                {
                    forward_mu=sliding_mu[i];
                    sideward_mu=sliding_mu[i];
                }

                /* Calculate foreward and sideward reaction forces */

                forward_wheel_force  =   forward_mu*reaction_normal_force;
                sideward_wheel_force =  sideward_mu*reaction_normal_force;
                if(v_wheel_forward < 0.) forward_wheel_force = -forward_wheel_force;
                if(v_wheel_sideward < 0.) sideward_wheel_force = -sideward_wheel_force;
                /* printf("\tFfwdgear: %g Fsidegear: %g\n",forward_wheel_force,sideward_wheel_force);
                 */
                /* Rotate into local (N-E-D) axes */

                f_wheel_local_v[0] = forward_wheel_force*cos_wheel_hdg_angle
                                     - sideward_wheel_force*sin_wheel_hdg_angle;
                f_wheel_local_v[1] = forward_wheel_force*sin_wheel_hdg_angle
                                     + sideward_wheel_force*cos_wheel_hdg_angle;
                f_wheel_local_v[2] = reaction_normal_force;

                /* Convert reaction force from local (N-E-D) axes to body (X-Y-Z) */
                mult3x3by3( T_local_to_body_m, f_wheel_local_v, tempF );

                /* Calculate moments from force and offsets in body axes */

                cross3( d_wheel_cg_body_v, tempF, tempM );

                /* Sum forces and moments across all wheels */
                if (tempF[0] != 0.0 || tempF[1] != 0.0 || tempF[2] != 0.0) {
                    fgSetBool("/gear/gear[1]/wow", true);
                }

                add3( tempF, F_gear_v, F_gear_v );
                add3( tempM, M_gear_v, M_gear_v );

            }
        }



        /* printf("\tN: %g,dZrwy: %g dZdotrwy: %g\n",reaction_normal_force,HEIGHT_AGL_WHEEL,v_wheel_cg_local_v[2]); */

        /*printf("\tFxgear: %g Fygear: %g, Fzgear: %g\n",F_X_gear,F_Y_gear,F_Z_gear);
        printf("\tMgear: %g, Lgear: %g, Ngear: %g\n\n",M_m_gear,M_l_gear,M_n_gear); */


    }
}
Beispiel #20
0
// NOTE: This should work for all triangle elments (303 - 306), but only
// if mid-edge and middle nodes are after "corner" nodes in the node list!
// Return nof intersections
//
int
MeshFaceElementTable::calcTriangleLineIntersections(int elem_index, short direction,
                                                    Point3& lstart, Point3& ldir, Point3* isec_points)
{
  // Ccw ordered nodes (if elem_dir is -1, it is from the parent2
  // and nodes are cw oriented and must me reordered
  Point3& p0 = meshNodes[nodeIds[elem_index][0]];
  Point3& p1 = meshNodes[nodeIds[elem_index][1]];
  Point3& p2 = meshNodes[nodeIds[elem_index][2]];
  Point3& normal = normals[elem_index];

  static Point3* points[3];

  points[0] = (direction >= 0)? &p0 : &p1;
  points[1] = (direction >= 0)? &p1 : &p0;
  points[2] = &p2;

#if 0
  // If element is looking into wrong direction
  //
  // NOTE: This makes picking much faster, so wew have to use it (unless some better
  // method is found), although it means that elements cannot be selected from 'inside',
  // which would be quite convenient in some cases!
  //
  if ( direction == 1 ) {
    if ( !isLess(dot3(normal, ldir), 0) ) {
      return 0;
    }

  } else if ( direction == -1 ) {
    if ( !isGreater(dot3(normal, ldir), 0) ) {
      return 0;
    }
  }
#endif

  // Plane equation for the normal and a point in the plane is;
  // (r) dot (normal) = (r0) dot (normal) = d
  // So for the form Ax + By + Cz + D = 0, we have
  // A = normal[0], B = normal[1], C = normal[2], D = -d

  double D = -1 * dot3(p0, normal);

  double numer = dot3(normal, lstart) + D;
  double denom = dot3(normal, ldir);

  double t;

  // Intersection
  if (denom != 0) {
    t = - numer / denom;

  // Line is on the plane
  } else if (numer == 0) {
    t = 0.0;

  // Line is parallel,but not in the plane
  } else {
    return 0;
  }


  //-Calc intersection point from the line equation
  Point3 tmp;
  scalarmult(t, ldir, tmp);
  Point3 isec_point;
  add3(lstart, tmp, isec_point);

  // Finally check if intersection point
  // is inside the element (triangle)
  if ( pointInsideTriangle(isec_point, points, centers[elem_index], rSquares[elem_index]) ) {

    copy3(isec_point, *isec_points);
    return 1;

  } else {
    return 0;
  }

}
Beispiel #21
0
int main()
{
	return add3(4, 5, 6);
}
Beispiel #22
0
void basic_gear()
{
char rcsid[] = "junk";
#define NUM_WHEELS 4

// char gear_strings[NUM_WHEELS][12]={"nose","right main", "left main", "tail skid"};
  /*
   * Aircraft specific initializations and data goes here
   */
   

    static int num_wheels = NUM_WHEELS;             /* number of wheels  */
    static DATA d_wheel_rp_body_v[NUM_WHEELS][3] =  /* X, Y, Z locations,full extension */
    {
        { .422,  0.,    .29 },             /*nose*/ /* in feet */
        { 0.026, 0.006, .409 },        /*right main*/
        { 0.026, -.006, .409 },        /*left main*/ 
        { -1.32, 0, .17 }            /*tail skid */
    };
    // static DATA gear_travel[NUM_WHEELS] = /*in Z-axis*/
           // { -0.5, 2.5, 2.5, 0};
    static DATA spring_constant[NUM_WHEELS] =       /* springiness, lbs/ft */
        { 2., .65, .65, 1. };
    static DATA spring_damping[NUM_WHEELS] =        /* damping, lbs/ft/sec */
        { 1.,  .3, .3, .5 };    
    static DATA percent_brake[NUM_WHEELS] =         /* percent applied braking */
        { 0.,  0.,  0., 0. };                       /* 0 = none, 1 = full */
    static DATA caster_angle_rad[NUM_WHEELS] =      /* steerable tires - in */
        { 0., 0., 0., 0};                                   /* radians, +CW */  
  /*
   * End of aircraft specific code
   */
    
  /*
   * Constants & coefficients for tyres on tarmac - ref [1]
   */
   
    /* skid function looks like:
     * 
     *           mu  ^
     *               |
     *       max_mu  |       +          
     *               |      /|          
     *   sliding_mu  |     / +------    
     *               |    /             
     *               |   /              
     *               +--+------------------------> 
     *               |  |    |      sideward V
     *               0 bkout skid
     *                 V     V
     */
  
  
    static int it_rolls[NUM_WHEELS] = { 1,1,1,0};       
        static DATA sliding_mu[NUM_WHEELS] = { 0.5, 0.5, 0.5, 0.3};     
    static DATA rolling_mu[NUM_WHEELS] = { 0.01, 0.01, 0.01, 0.0};      
    static DATA max_brake_mu[NUM_WHEELS] ={ 0.0, 0.6, 0.6, 0.0};        
    static DATA max_mu       = 0.8;     
    static DATA bkout_v      = 0.1;
    static DATA skid_v       = 1.0;
  /*
   * Local data variables
   */
   
    DATA d_wheel_cg_body_v[3];          /* wheel offset from cg,  X-Y-Z */
    DATA d_wheel_cg_local_v[3];         /* wheel offset from cg,  N-E-D */
    DATA d_wheel_rwy_local_v[3];        /* wheel offset from rwy, N-E-U */
        DATA v_wheel_cg_local_v[3];    /*wheel velocity rel to cg N-E-D*/
    // DATA v_wheel_body_v[3];          /* wheel velocity,        X-Y-Z */
    DATA v_wheel_local_v[3];            /* wheel velocity,        N-E-D */
    DATA f_wheel_local_v[3];            /* wheel reaction force,  N-E-D */
    // DATA altitude_local_v[3];       /*altitude vector in local (N-E-D) i.e. (0,0,h)*/
    // DATA altitude_body_v[3];        /*altitude vector in body (X,Y,Z)*/
    DATA temp3a[3];
    // DATA temp3b[3];
    DATA tempF[3];
    DATA tempM[3];      
    DATA reaction_normal_force;         /* wheel normal (to rwy) force  */
    DATA cos_wheel_hdg_angle, sin_wheel_hdg_angle;      /* temp storage */
    DATA v_wheel_forward, v_wheel_sideward,  abs_v_wheel_sideward;
    DATA forward_mu, sideward_mu;       /* friction coefficients        */
    DATA beta_mu;                       /* breakout friction slope      */
    DATA forward_wheel_force, sideward_wheel_force;

    int i;                              /* per wheel loop counter */
  
  /*
   * Execution starts here
   */
   
    beta_mu = max_mu/(skid_v-bkout_v);
    clear3( F_gear_v );         /* Initialize sum of forces...  */
    clear3( M_gear_v );         /* ...and moments               */
    
  /*
   * Put aircraft specific executable code here
   */
   
    percent_brake[1] = Brake_pct[0];
    percent_brake[2] = Brake_pct[1];
    
    caster_angle_rad[0] =
        (0.01 + 0.04 * (1 - V_calibrated_kts / 130)) * Rudder_pedal;
    
    
        for (i=0;i<num_wheels;i++)          /* Loop for each wheel */
    {
                /* printf("%s:\n",gear_strings[i]); */



                /*========================================*/
                /* Calculate wheel position w.r.t. runway */
                /*========================================*/

                
                /* printf("\thgcg: %g, theta: %g,phi: %g\n",D_cg_above_rwy,Theta*RAD_TO_DEG,Phi*RAD_TO_DEG); */

                
                        /* First calculate wheel location w.r.t. cg in body (X-Y-Z) axes... */

                sub3( d_wheel_rp_body_v[i], D_cg_rp_body_v, d_wheel_cg_body_v );

                /* then converting to local (North-East-Down) axes... */

                multtrans3x3by3( T_local_to_body_m,  d_wheel_cg_body_v, d_wheel_cg_local_v );
                

                /* Runway axes correction - third element is Altitude, not (-)Z... */

                d_wheel_cg_local_v[2] = -d_wheel_cg_local_v[2]; /* since altitude = -Z */

                /* Add wheel offset to cg location in local axes */

                add3( d_wheel_cg_local_v, D_cg_rwy_local_v, d_wheel_rwy_local_v );

                /* remove Runway axes correction so right hand rule applies */

                d_wheel_cg_local_v[2] = -d_wheel_cg_local_v[2]; /* now Z positive down */

                /*============================*/
                /* Calculate wheel velocities */
                /*============================*/

                /* contribution due to angular rates */

                cross3( Omega_body_v, d_wheel_cg_body_v, temp3a );

                /* transform into local axes */

                multtrans3x3by3( T_local_to_body_m, temp3a,v_wheel_cg_local_v );

                /* plus contribution due to cg velocities */

                add3( v_wheel_cg_local_v, V_local_rel_ground_v, v_wheel_local_v );

                clear3(f_wheel_local_v);
                reaction_normal_force=0;
                if( HEIGHT_AGL_WHEEL < 0. ) 
                        /*the wheel is underground -- which implies ground contact 
                          so calculate reaction forces */ 
                        {
                        /*===========================================*/
                        /* Calculate forces & moments for this wheel */
                        /*===========================================*/

                        /* Add any anticipation, or frame lead/prediction, here... */

                                /* no lead used at present */

                        /* Calculate sideward and forward velocities of the wheel 
                                in the runway plane                                     */

                        cos_wheel_hdg_angle = cos(caster_angle_rad[i] + Psi);
                        sin_wheel_hdg_angle = sin(caster_angle_rad[i] + Psi);

                        v_wheel_forward  = v_wheel_local_v[0]*cos_wheel_hdg_angle
                                         + v_wheel_local_v[1]*sin_wheel_hdg_angle;
                        v_wheel_sideward = v_wheel_local_v[1]*cos_wheel_hdg_angle
                                         - v_wheel_local_v[0]*sin_wheel_hdg_angle;
                        
                    
                /* Calculate normal load force (simple spring constant) */

                reaction_normal_force = 0.;
        
                reaction_normal_force = spring_constant[i]*d_wheel_rwy_local_v[2]
                                          - v_wheel_local_v[2]*spring_damping[i];
                        /* printf("\treaction_normal_force: %g\n",reaction_normal_force); */

                if (reaction_normal_force > 0.) reaction_normal_force = 0.;
                        /* to prevent damping component from swamping spring component */


                /* Calculate friction coefficients */

                        if(it_rolls[i])
                        {
                           forward_mu = (max_brake_mu[i] - rolling_mu[i])*percent_brake[i] + rolling_mu[i];
                           abs_v_wheel_sideward = sqrt(v_wheel_sideward*v_wheel_sideward);
                           sideward_mu = sliding_mu[i];
                           if (abs_v_wheel_sideward < skid_v) 
                           sideward_mu = (abs_v_wheel_sideward - bkout_v)*beta_mu;
                           if (abs_v_wheel_sideward < bkout_v) sideward_mu = 0.;
                        }
                        else
                        {
                                forward_mu=sliding_mu[i];
                                sideward_mu=sliding_mu[i];
                        }          

                        /* Calculate foreward and sideward reaction forces */

                        forward_wheel_force  =   forward_mu*reaction_normal_force;
                        sideward_wheel_force =  sideward_mu*reaction_normal_force;
                        if(v_wheel_forward < 0.) forward_wheel_force = -forward_wheel_force;
                        if(v_wheel_sideward < 0.) sideward_wheel_force = -sideward_wheel_force;
/*                      printf("\tFfwdgear: %g Fsidegear: %g\n",forward_wheel_force,sideward_wheel_force);
 */
                        /* Rotate into local (N-E-D) axes */

                        f_wheel_local_v[0] = forward_wheel_force*cos_wheel_hdg_angle
                                          - sideward_wheel_force*sin_wheel_hdg_angle;
                        f_wheel_local_v[1] = forward_wheel_force*sin_wheel_hdg_angle
                                          + sideward_wheel_force*cos_wheel_hdg_angle;
                        f_wheel_local_v[2] = reaction_normal_force;       

                         /* Convert reaction force from local (N-E-D) axes to body (X-Y-Z) */
                        mult3x3by3( T_local_to_body_m, f_wheel_local_v, tempF );

                        /* Calculate moments from force and offsets in body axes */

                        cross3( d_wheel_cg_body_v, tempF, tempM );

                        /* Sum forces and moments across all wheels */

                        add3( tempF, F_gear_v, F_gear_v );
                        add3( tempM, M_gear_v, M_gear_v );   


                        }


                
/*                  printf("\tN: %g,dZrwy: %g dZdotrwy: %g\n",reaction_normal_force,HEIGHT_AGL_WHEEL,v_wheel_cg_local_v[2]);  */
/*                  printf("\tFxgear: %g Fygear: %g, Fzgear: %g\n",F_X_gear,F_Y_gear,F_Z_gear); */
/*                  printf("\tMgear: %g, Lgear: %g, Ngear: %g\n\n",M_m_gear,M_l_gear,M_n_gear); */
                
                
    }
}