Program: 58327
Project: 58327
Buggy source:
public float calculateCorrectDiskRotation(PoincareNode currentNode){
  if (currentNode != null) {
    if (currentNode.iComparableValue != 1) {
      float[] currentPosition=new float[2];
      currentPosition=currentNode.getPosition().clone();
      float[] parentPosition;
      parentPosition=currentNode.getParent().getPosition().clone();
      float[] relativePosition=new float[2];
      relativePosition[0]=-currentPosition[0];
      relativePosition[1]=-currentPosition[1];
      currentPosition[0]=0;
      currentPosition[1]=0;
      ComplexNumber moebiusTransformation=new ComplexNumber();
      ComplexNumber complexParentPosition=new ComplexNumber();
      moebiusTransformation.setValue((double)relativePosition[0],(double)relativePosition[1]);
      complexParentPosition.setValue((double)parentPosition[0],(double)parentPosition[1]);
      complexParentPosition=this.moebiusTransformation(complexParentPosition,moebiusTransformation);
      relativePosition[0]=(float)complexParentPosition.getRealPart();
      relativePosition[1]=(float)complexParentPosition.getImaginaryPart();
      float[] eV=getEV(relativePosition);
      float angle=(float)Math.atan2(eV[1],eV[0]);
      if (Math.abs(-angle + Math.PI) < Math.PI) {
        return -angle + (float)Math.PI;
      }
 else {
        return -angle - (float)Math.PI;
      }
    }
 else {
      float[] currentPosition=new float[2];
      currentPosition=currentNode.getPosition().clone();
      float[] childPosition;
      if (currentNode.getNrLeaves() != 0) {
        childPosition=currentNode.getChildren().get(0).getPosition();
        float[] relativePosition=new float[2];
        relativePosition[0]=-currentPosition[0];
        relativePosition[1]=-currentPosition[1];
        currentPosition[0]=0;
        currentPosition[1]=0;
        ComplexNumber moebiusTransformation=new ComplexNumber();
        ComplexNumber complexParentPosition=new ComplexNumber();
        moebiusTransformation.setValue((double)relativePosition[0],(double)relativePosition[1]);
        complexParentPosition.setValue((double)childPosition[0],(double)childPosition[1]);
        complexParentPosition=this.moebiusTransformation(complexParentPosition,moebiusTransformation);
        relativePosition[0]=(float)complexParentPosition.getRealPart();
        relativePosition[1]=(float)complexParentPosition.getImaginaryPart();
        float[] eV=getEV(relativePosition);
        float angle=(float)Math.atan2(eV[1],eV[0]);
        float angleOffset=((float)Math.PI / (float)currentNode.getChildren().size()) / 2;
        angle=angle + angleOffset + (float)Math.PI / 2;
        if (Math.abs(-angle + Math.PI) < Math.PI) {
          return -angle + (float)Math.PI;
        }
 else {
          return -angle - (float)Math.PI;
        }
      }
    }
  }
 else {
  }
  return 0;
}

Fixed version (ground truth):
public float calculateCorrectDiskRotation(PoincareNode currentNode){
  if (currentNode != null) {
    if (currentNode.iComparableValue != 1) {
      calculateRootNodeAngleSwitch=true;
      float[] currentPosition=new float[2];
      currentPosition=currentNode.getPosition().clone();
      float[] parentPosition;
      parentPosition=currentNode.getParent().getPosition().clone();
      float[] relativePosition=new float[2];
      relativePosition[0]=-currentPosition[0];
      relativePosition[1]=-currentPosition[1];
      currentPosition[0]=0;
      currentPosition[1]=0;
      ComplexNumber moebiusTransformation=new ComplexNumber();
      ComplexNumber complexParentPosition=new ComplexNumber();
      moebiusTransformation.setValue((double)relativePosition[0],(double)relativePosition[1]);
      complexParentPosition.setValue((double)parentPosition[0],(double)parentPosition[1]);
      complexParentPosition=this.moebiusTransformation(complexParentPosition,moebiusTransformation);
      relativePosition[0]=(float)complexParentPosition.getRealPart();
      relativePosition[1]=(float)complexParentPosition.getImaginaryPart();
      float[] eV=getEV(relativePosition);
      float angle=(float)Math.atan2(eV[1],eV[0]);
      if (Math.abs(-angle + Math.PI) < Math.PI) {
        return -angle + (float)Math.PI;
      }
 else {
        return -angle - (float)Math.PI;
      }
    }
 else {
      float[] currentPosition=new float[2];
      currentPosition=currentNode.getPosition().clone();
      float[] childPosition;
      if (this.calculateRootNodeAngleSwitch == true) {
        if (currentNode.getChildren() != null) {
          childPosition=currentNode.getChildren().get(0).getPosition();
          float[] relativePosition=new float[2];
          relativePosition[0]=-currentPosition[0];
          relativePosition[1]=-currentPosition[1];
          currentPosition[0]=0;
          currentPosition[1]=0;
          ComplexNumber moebiusTransformation=new ComplexNumber();
          ComplexNumber complexParentPosition=new ComplexNumber();
          moebiusTransformation.setValue((double)relativePosition[0],(double)relativePosition[1]);
          complexParentPosition.setValue((double)childPosition[0],(double)childPosition[1]);
          complexParentPosition=this.moebiusTransformation(complexParentPosition,moebiusTransformation);
          relativePosition[0]=(float)complexParentPosition.getRealPart();
          relativePosition[1]=(float)complexParentPosition.getImaginaryPart();
          float[] eV=getEV(relativePosition);
          float angle=(float)Math.atan2(eV[1],eV[0]);
          float angleOffset=((float)Math.PI / (float)currentNode.getChildren().size()) / 2;
          angle=angle + angleOffset + (float)Math.PI / 2;
          if (Math.abs(-angle + Math.PI) < Math.PI) {
            return -angle + (float)Math.PI;
          }
 else {
            return -angle - (float)Math.PI;
          }
        }
      }
    }
  }
  return 0;
}