work in progress
in the middle of switching to sortless version
git-svn-id: http://skia.googlecode.com/svn/trunk@3768 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/Extrema.cpp b/experimental/Intersection/Extrema.cpp
index 0b85060..386f092 100644
--- a/experimental/Intersection/Extrema.cpp
+++ b/experimental/Intersection/Extrema.cpp
@@ -1,20 +1,18 @@
#include "DataTypes.h"
#include "Extrema.h"
-static int valid_unit_divide(double numer, double denom, double* ratio)
+static int validUnitDivide(double numer, double denom, double* ratio)
{
- if (numer < 0)
- {
+ if (numer < 0) {
numer = -numer;
denom = -denom;
}
-
if (denom == 0 || numer == 0 || numer >= denom)
return 0;
-
double r = numer / denom;
- if (r == 0) // catch underflow if numer <<<< denom
+ if (r == 0) { // catch underflow if numer <<<< denom
return 0;
+ }
*ratio = r;
return 1;
}
@@ -25,10 +23,10 @@
x1 = Q / A
x2 = C / Q
*/
-static int SkFindUnitQuadRoots(double A, double B, double C, double roots[2])
+static int findUnitQuadRoots(double A, double B, double C, double roots[2])
{
if (A == 0)
- return valid_unit_divide(-C, B, roots);
+ return validUnitDivide(-C, B, roots);
double* r = roots;
@@ -39,8 +37,8 @@
R = sqrt(R);
double Q = (B < 0) ? -(B-R)/2 : -(B+R)/2;
- r += valid_unit_divide(Q, A, r);
- r += valid_unit_divide(C, Q, r);
+ r += validUnitDivide(Q, A, r);
+ r += validUnitDivide(C, Q, r);
if (r - roots == 2 && approximately_equal(roots[0], roots[1])) { // nearly-equal?
r -= 1; // skip the double root
}
@@ -51,16 +49,16 @@
A = 3(-a + 3(b - c) + d)
B = 6(a - 2b + c)
C = 3(b - a)
- Solve for t, keeping only those that fit betwee 0 < t < 1
+ Solve for t, keeping only those that fit between 0 < t < 1
*/
-int SkFindCubicExtrema(double a, double b, double c, double d, double tValues[2])
+int findExtrema(double a, double b, double c, double d, double tValues[2])
{
// we divide A,B,C by 3 to simplify
double A = d - a + 3*(b - c);
double B = 2*(a - b - b + c);
double C = b - a;
- return SkFindUnitQuadRoots(A, B, C, tValues);
+ return findUnitQuadRoots(A, B, C, tValues);
}
/** Quad'(t) = At + B, where
@@ -68,10 +66,10 @@
B = 2(b - a)
Solve for t, only if it fits between 0 < t < 1
*/
-int SkFindQuadExtrema(double a, double b, double c, double tValue[1])
+int findExtrema(double a, double b, double c, double tValue[1])
{
/* At + B == 0
t = -B / A
*/
- return valid_unit_divide(a - b, a - b - b + c, tValue);
+ return validUnitDivide(a - b, a - b - b + c, tValue);
}