Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselationhelpers.cpp

    r856098 rb998c3  
    226226  Vector helper;
    227227  double radius, alpha;
    228 
    229   helper.CopyVector(&NewSphereCenter);
     228  Vector RelativeOldSphereCenter;
     229  Vector RelativeNewSphereCenter;
     230
     231  RelativeOldSphereCenter.CopyVector(&OldSphereCenter);
     232  RelativeOldSphereCenter.SubtractVector(&CircleCenter);
     233  RelativeNewSphereCenter.CopyVector(&NewSphereCenter);
     234  RelativeNewSphereCenter.SubtractVector(&CircleCenter);
     235  helper.CopyVector(&RelativeNewSphereCenter);
    230236  // test whether new center is on the parameter circle's plane
    231237  if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
     
    233239    helper.ProjectOntoPlane(&CirclePlaneNormal);
    234240  }
    235   radius = helper.ScalarProduct(&helper);
     241  radius = helper.NormSquared();
    236242  // test whether the new center vector has length of CircleRadius
    237243  if (fabs(radius - CircleRadius) > HULLEPSILON)
    238244    eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;
    239   alpha = helper.Angle(&OldSphereCenter);
     245  alpha = helper.Angle(&RelativeOldSphereCenter);
    240246  // make the angle unique by checking the halfplanes/search direction
    241247  if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
    242248    alpha = 2.*M_PI - alpha;
    243   //Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << OldSphereCenter << " and resulting angle is " << alpha << "." << endl;
    244   radius = helper.Distance(&OldSphereCenter);
     249  Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl;
     250  radius = helper.Distance(&RelativeOldSphereCenter);
    245251  helper.ProjectOntoPlane(&NormalVector);
    246252  // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
    247253  if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
    248     //Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;
     254    Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;
    249255    return alpha;
    250256  } else {
    251     //Log() << Verbose(1) << "INFO: NewSphereCenter " << helper << " is too close to OldSphereCenter" << OldSphereCenter << "." << endl;
     257    Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl;
    252258    return 2.*M_PI;
    253259  }
Note: See TracChangeset for help on using the changeset viewer.