Program: 70872
Project: 70872
Buggy source:
private void drawColoredArrow(GL2 gl,int nslices,double rad,float arrowRad,float arrowHeight,float[] coords0,byte[] color0,float[] coords1,byte[] color1,boolean hsv,boolean capped){
  utmp.set(coords1[0] - coords0[0],coords1[1] - coords0[1],coords1[2] - coords0[2]);
  Xtmp.p.set(coords0[0],coords0[1],coords0[2]);
  Xtmp.R.setZDirection(utmp);
  gl.glPushMatrix();
  GL2Viewer.mulTransform(gl,Xtmp);
  byte[] colorM=new byte[4];
  double h2=utmp.norm();
  double h=h2 - arrowHeight;
  double t=(float)(h / h2);
  interpColor4ub(color0,t,color1,colorM,hsv);
  if (nslices + 1 != cosBuff.length) {
    cosBuff=new double[nslices + 1];
    sinBuff=new double[nslices + 1];
    cosBuff[0]=1;
    sinBuff[0]=0;
    cosBuff[nslices]=1;
    sinBuff[nslices]=0;
    for (int i=1; i < nslices; i++) {
      double ang=i / (double)nslices * 2 * Math.PI;
      cosBuff[i]=Math.cos(ang);
      sinBuff[i]=Math.sin(ang);
    }
  }
  gl.glBegin(GL2.GL_QUAD_STRIP);
  double c1, s1;
  for (int i=0; i <= nslices; i++) {
    c1=cosBuff[i];
    s1=sinBuff[i];
    gl.glNormal3d(c1,s1,0);
    gl.glColor4ubv(colorM,0);
    gl.glVertex3d(rad * c1,rad * s1,h);
    gl.glColor4ubv(color0,0);
    gl.glVertex3d(rad * c1,rad * s1,0);
  }
  gl.glEnd();
  gl.glBegin(GL2.GL_QUAD_STRIP);
  for (int i=0; i <= nslices; i++) {
    c1=cosBuff[i];
    s1=sinBuff[i];
    gl.glNormal3d(c1,s1,1);
    gl.glColor4ubv(color1,0);
    gl.glVertex3d(0,0,h2);
    gl.glColor4ubv(colorM,0);
    gl.glVertex3d(rad * c1,rad * s1,h);
  }
  gl.glEnd();
  if (capped) {
    gl.glColor4ubv(color0,0);
    gl.glBegin(GL2.GL_POLYGON);
    gl.glNormal3d(0,0,-1);
    for (int i=0; i < nslices; i++) {
      gl.glVertex3d(rad * cosBuff[i],rad * sinBuff[i],0);
    }
    gl.glEnd();
    gl.glColor4ubv(colorM,0);
    gl.glBegin(GL2.GL_QUAD_STRIP);
    gl.glNormal3d(0,0,-1);
    for (int i=0; i < nslices; i++) {
      gl.glVertex3d(rad * cosBuff[i],rad * sinBuff[i],h);
      gl.glVertex3d(arrowRad * cosBuff[i],arrowRad * sinBuff[i],h);
    }
    gl.glEnd();
  }
  gl.glPopMatrix();
}

Fixed version (ground truth):
private void drawColoredArrow(GL2 gl,int nslices,double rad,float arrowRad,float arrowHeight,float[] coords0,byte[] color0,float[] coords1,byte[] color1,boolean hsv,boolean capped){
  utmp.set(coords1[0] - coords0[0],coords1[1] - coords0[1],coords1[2] - coords0[2]);
  Xtmp.p.set(coords0[0],coords0[1],coords0[2]);
  Xtmp.R.setZDirection(utmp);
  gl.glPushMatrix();
  GL2Viewer.mulTransform(gl,Xtmp);
  byte[] colorM=new byte[4];
  double h2=utmp.norm();
  double h=h2 - arrowHeight;
  double t=(float)(h / h2);
  interpColor4ub(color0,t,color1,colorM,hsv);
  if (nslices + 1 != cosBuff.length) {
    cosBuff=new double[nslices + 1];
    sinBuff=new double[nslices + 1];
    cosBuff[0]=1;
    sinBuff[0]=0;
    cosBuff[nslices]=1;
    sinBuff[nslices]=0;
    for (int i=1; i < nslices; i++) {
      double ang=i / (double)nslices * 2 * Math.PI;
      cosBuff[i]=Math.cos(ang);
      sinBuff[i]=Math.sin(ang);
    }
  }
  gl.glBegin(GL2.GL_QUAD_STRIP);
  double c1, s1;
  for (int i=0; i <= nslices; i++) {
    c1=cosBuff[i];
    s1=sinBuff[i];
    gl.glNormal3d(c1,s1,0);
    setVertexColor(gl,colorM,hsv);
    gl.glVertex3d(rad * c1,rad * s1,h);
    setVertexColor(gl,color0,hsv);
    gl.glVertex3d(rad * c1,rad * s1,0);
  }
  gl.glEnd();
  gl.glBegin(GL2.GL_QUAD_STRIP);
  for (int i=0; i <= nslices; i++) {
    c1=cosBuff[i];
    s1=sinBuff[i];
    gl.glNormal3d(c1,s1,1);
    setVertexColor(gl,color1,hsv);
    gl.glVertex3d(0,0,h2);
    setVertexColor(gl,colorM,hsv);
    gl.glVertex3d(arrowRad * c1,arrowRad * s1,h);
  }
  gl.glEnd();
  if (capped) {
    setVertexColor(gl,color0,hsv);
    gl.glBegin(GL2.GL_POLYGON);
    gl.glNormal3d(0,0,-1);
    for (int i=0; i < nslices; i++) {
      gl.glVertex3d(-rad * cosBuff[i],rad * sinBuff[i],0);
    }
    gl.glEnd();
    setVertexColor(gl,colorM,hsv);
    gl.glBegin(GL2.GL_QUAD_STRIP);
    gl.glNormal3d(0,0,-1);
    for (int i=0; i <= nslices; i++) {
      gl.glVertex3d(arrowRad * cosBuff[i],arrowRad * sinBuff[i],h);
      gl.glVertex3d(rad * cosBuff[i],rad * sinBuff[i],h);
    }
    gl.glEnd();
  }
  gl.glPopMatrix();
}