aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/DataTypes.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-03 22:07:47 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-03 22:07:47 +0000
commitc682590538a27d73489bc91c098e000fdfb07ccf (patch)
tree90b03195e3a74cf47f4fa3a385e99575c46da37b /experimental/Intersection/DataTypes.cpp
parent2c23708e4478a83dcded2e9d5672bc57ee016919 (diff)
save work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@3141 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/DataTypes.cpp')
-rw-r--r--experimental/Intersection/DataTypes.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/experimental/Intersection/DataTypes.cpp b/experimental/Intersection/DataTypes.cpp
index 4cb22754ea..8f46e8e1cd 100644
--- a/experimental/Intersection/DataTypes.cpp
+++ b/experimental/Intersection/DataTypes.cpp
@@ -72,3 +72,30 @@ void x_at(const _Point& p1, const _Point& p2, double top, double bottom,
setMinMax(x, p1.y, p2.y, bottomFlags, minX, maxX);
}
}
+
+void xy_at_t(const Cubic& cubic, double t, double& x, double& y) {
+ double one_t = 1 - t;
+ double one_t2 = one_t * one_t;
+ double a = one_t2 * one_t;
+ double b = 3 * one_t2 * t;
+ double t2 = t * t;
+ double c = 3 * one_t * t2;
+ double d = t2 * t;
+ x = a * cubic[0].x + b * cubic[1].x + c * cubic[2].x + d * cubic[3].x;
+ y = a * cubic[0].y + b * cubic[1].y + c * cubic[2].y + d * cubic[3].y;
+}
+
+void xy_at_t(const _Line& line, double t, double& x, double& y) {
+ double one_t = 1 - t;
+ x = one_t * line[0].x + t * line[1].x;
+ y = one_t * line[0].y + t * line[1].y;
+}
+
+void xy_at_t(const Quadratic& quad, double t, double& x, double& y) {
+ double one_t = 1 - t;
+ double a = one_t * one_t;
+ double b = 2 * one_t * t;
+ double c = t * t;
+ x = a * quad[0].x + b * quad[1].x + c * quad[2].x;
+ y = a * quad[0].y + b * quad[1].y + c * quad[2].y;
+}