aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-27 13:45:24 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-27 13:45:24 +0000
commitf47c217cc8de3be1f960156bfb76899a8e4bcccf (patch)
tree9ef741fbc2e282db39a03c46ea5fa4e2af0e5868 /experimental
parent11fa4a7095a2691eea3530dfbd7f676b41d3e7a9 (diff)
overzealously deleted files
git-svn-id: http://skia.googlecode.com/svn/trunk@3502 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental')
-rw-r--r--experimental/Intersection/CubicParameterization_TestUtility.cpp53
-rw-r--r--experimental/Intersection/QuadraticParameterization_TestUtility.cpp17
2 files changed, 70 insertions, 0 deletions
diff --git a/experimental/Intersection/CubicParameterization_TestUtility.cpp b/experimental/Intersection/CubicParameterization_TestUtility.cpp
new file mode 100644
index 0000000000..356ca88f85
--- /dev/null
+++ b/experimental/Intersection/CubicParameterization_TestUtility.cpp
@@ -0,0 +1,53 @@
+// included by CubicParameterization.cpp
+// accesses internal functions to validate parameterized coefficients
+
+#include "Parameterization_Test.h"
+
+static void parameter_coeffs(const Cubic& cubic, double coeffs[coeff_count]) {
+#if USE_SYVESTER
+ double ax, bx, cx, dx;
+ if (try_alt)
+ alt_set_abcd(&cubic[0].x, ax, bx, cx, dx);
+ else
+ set_abcd(&cubic[0].x, ax, bx, cx, dx);
+ double ay, by, cy, dy;
+ if (try_alt)
+ alt_set_abcd(&cubic[0].y, ay, by, cy, dy);
+ else
+ set_abcd(&cubic[0].y, ay, by, cy, dy);
+ calc_ABCD(ax, ay, coeffs);
+ if (!try_alt) calc_bc(dx, bx, cx);
+ if (!try_alt) calc_bc(dy, by, cy);
+#else
+ double ax = cubic[0].x;
+ double bx = cubic[1].x;
+ double cx = cubic[2].x;
+ double dx = cubic[3].x;
+ double ay = cubic[0].y;
+ double by = cubic[1].y;
+ double cy = cubic[2].y;
+ double dy = cubic[3].y;
+ calc_ABCD(ax, bx, cx, dx, ay, by, cy, dy, coeffs);
+#endif
+ for (int index = xx_coeff; index < coeff_count; ++index) {
+ int procIndex = index - xx_coeff;
+ coeffs[index] = (*calc_proc[procIndex])(ax, bx, cx, dx, ay, by, cy, dy);
+ }
+}
+
+bool point_on_parameterized_curve(const Cubic& cubic, const _Point& point) {
+ double coeffs[coeff_count];
+ parameter_coeffs(cubic, coeffs);
+ double xxx = coeffs[xxx_coeff] * point.x * point.x * point.x;
+ double xxy = coeffs[xxy_coeff] * point.x * point.x * point.y;
+ double xyy = coeffs[xyy_coeff] * point.x * point.y * point.y;
+ double yyy = coeffs[yyy_coeff] * point.y * point.y * point.y;
+ double xx = coeffs[ xx_coeff] * point.x * point.x;
+ double xy = coeffs[ xy_coeff] * point.x * point.y;
+ double yy = coeffs[ yy_coeff] * point.y * point.y;
+ double x = coeffs[ x_coeff] * point.x;
+ double y = coeffs[ y_coeff] * point.y;
+ double c = coeffs[ c_coeff];
+ double sum = xxx + xxy + xyy + yyy + xx + xy + yy + x + y + c;
+ return approximately_zero(sum);
+}
diff --git a/experimental/Intersection/QuadraticParameterization_TestUtility.cpp b/experimental/Intersection/QuadraticParameterization_TestUtility.cpp
new file mode 100644
index 0000000000..08a562bb8d
--- /dev/null
+++ b/experimental/Intersection/QuadraticParameterization_TestUtility.cpp
@@ -0,0 +1,17 @@
+// included by QuadraticParameterization.cpp
+// accesses internal functions to validate parameterized coefficients
+
+#include "Parameterization_Test.h"
+
+bool point_on_parameterized_curve(const Quadratic& quad, const _Point& point) {
+ double coeffs[coeff_count];
+ implicit_coefficients(quad, coeffs);
+ double xx = coeffs[ xx_coeff] * point.x * point.x;
+ double xy = coeffs[ xy_coeff] * point.x * point.y;
+ double yy = coeffs[ yy_coeff] * point.y * point.y;
+ double x = coeffs[ x_coeff] * point.x;
+ double y = coeffs[ y_coeff] * point.y;
+ double c = coeffs[ c_coeff];
+ double sum = xx + xy + yy + x + y + c;
+ return approximately_zero(sum);
+}