From c682590538a27d73489bc91c098e000fdfb07ccf Mon Sep 17 00:00:00 2001 From: "caryclark@google.com" Date: Fri, 3 Feb 2012 22:07:47 +0000 Subject: save work in progress git-svn-id: http://skia.googlecode.com/svn/trunk@3141 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/Intersection/DataTypes.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'experimental/Intersection/DataTypes.cpp') 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; +} -- cgit v1.2.3