/* * Calc angles (in degrees) from HKL, A0, and OMTX, according to constraint. * If constraint == PHI_CONST, this routine uses angles[PHI_INDEX] as supplied. */ int HKL_to_angles(double hkl[3], double a0[3][3], double omtx[3][3], double angles_arg[4], int constraint) { double hklp[3], tmp[3]; double ry[3][3], rz[3][3]; double R; double angles[4]; double xx; int i, err=0; errno = 0; for (i=0; i<4; i++) angles[i] = angles_arg[i]*D2R; multArrayVector(a0, hkl, hklp); if (orientDebug) printVector(hklp, "HKL_to_angles:A0 X HKL"); multArrayVector(omtx, hklp, hklp); if (orientDebug) printVector(hklp, "HKL_to_angles:OMTX X A0 X HKL"); /* length of HKL vector */ R = sqrt(hklp[H_INDEX]*hklp[H_INDEX]+hklp[K_INDEX]*hklp[K_INDEX]+hklp[L_INDEX]*hklp[L_INDEX]); angles[TTH_INDEX] = 2 * asin(R); switch (constraint) { case MIN_CHI_PHIm90: angles[PHI_INDEX] = atan(-hklp[H_INDEX]*hklp[K_INDEX] / (hklp[L_INDEX]*hklp[L_INDEX] + hklp[K_INDEX]*hklp[K_INDEX])); /* fall through */ case PHI_CONST: if (orientDebug) printf("HKL_to_angles:PHI = %f\n", angles_arg[PHI_INDEX]); xx = checkSmall(hklp[L_INDEX]); if (orientDebug) printf("HKL_to_angles:arg of atan = %f\n", -(hklp[H_INDEX]*cos(angles[PHI_INDEX]) + hklp[K_INDEX]*sin(angles[PHI_INDEX])) / xx); angles[CHI_INDEX] = M_PI/2 + atan(-(hklp[H_INDEX]*cos(angles[PHI_INDEX]) + hklp[K_INDEX]*sin(angles[PHI_INDEX])) / xx); calc_rotY(angles[CHI_INDEX], ry); calc_rotZ(angles[PHI_INDEX], rz); multArrayVector(rz, hklp, tmp); multArrayVector(ry, tmp, tmp); if (orientDebug) printVector(tmp, "HKL_to_angles:Ry X Rz X OMTX X A0 X HKL"); angles[TH_INDEX] = atan2(tmp[K_INDEX], tmp[H_INDEX]) + angles[TTH_INDEX]/2; break; case OMEGA_ZERO: default: angles[TH_INDEX] = angles[TTH_INDEX]/2; xx = checkSmall(sqrt(hklp[H_INDEX]*hklp[H_INDEX]+hklp[K_INDEX]*hklp[K_INDEX])); angles[CHI_INDEX] = atan(hklp[L_INDEX]/xx); xx = checkSmall(hklp[H_INDEX]); angles[PHI_INDEX] = atan2(hklp[K_INDEX], xx); /* i.e., atan(K/H) in [-PI, PI] */ break; } for (i=0; i<4; i++) { angles_arg[i] = angles[i]/D2R; if (isnan(angles_arg[i])) err = 1; } if (orientDebug) print4Vector(angles_arg, "HKL_to_angles:angles (degrees)"); return (errno || err); }
bool HandleCoincidence(SkTArray<SkOpContour*, true>* contourList, int total) { #if DEBUG_SHOW_WINDING SkOpContour::debugShowWindingValues(contourList); #endif CoincidenceCheck(contourList, total); #if DEBUG_SHOW_WINDING SkOpContour::debugShowWindingValues(contourList); #endif fixOtherTIndex(contourList); checkEnds(contourList); // check if connecting curve intersected at the same end bool hasM = checkMultiples(contourList); // check if intersections agree on t and point values SkTDArray<SkOpSegment::AlignedSpan> aligned; if (hasM) { alignMultiples(contourList, &aligned); // align pairs of identical points alignCoincidence(contourList, aligned); } checkDuplicates(contourList); // check if spans have the same number on the other end checkTiny(contourList); // if pair have the same end points, mark them as parallel checkSmall(contourList); // a pair of curves with a small span may turn into coincident lines joinCoincidence(contourList); // join curves that connect to a coincident pair sortSegments(contourList); if (!calcAngles(contourList)) { return false; } sortAngles(contourList); #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY DebugShowActiveSpans(*contourList); #endif return true; }
bool isPrime(const bigInt& a) { if (!checkSmall(a)) return false; if (!miller_rabin(a, 2)) return false; return lucas_selfridge(a); }