Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: experimental/Intersection/CubicLineSegments.cpp

Issue 867213004: remove prototype pathops code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "CubicLineSegments.h"
8 #include "QuadraticLineSegments.h"
9
10 // http://cagd.cs.byu.edu/~557/text/cagd.pdf 2.7
11 // A hodograph is the first derivative curve
12 void hodograph(const Cubic& cubic, Quadratic& hodo) {
13 hodo[0].x = 3 * (cubic[1].x - cubic[0].x);
14 hodo[0].y = 3 * (cubic[1].y - cubic[0].y);
15 hodo[1].x = 3 * (cubic[2].x - cubic[1].x);
16 hodo[1].y = 3 * (cubic[2].y - cubic[1].y);
17 hodo[2].x = 3 * (cubic[3].x - cubic[2].x);
18 hodo[2].y = 3 * (cubic[3].y - cubic[2].y);
19 }
20
21 // A 2nd hodograph is the second derivative curve
22 void secondHodograph(const Cubic& cubic, _Line& hodo2) {
23 Quadratic hodo;
24 hodograph(cubic, hodo);
25 hodograph(hodo, hodo2);
26 }
27
28 // The number of line segments required to approximate the cubic
29 // see http://cagd.cs.byu.edu/~557/text/cagd.pdf 10.6
30 double subDivisions(const Cubic& cubic) {
31 _Line hodo2;
32 secondHodograph(cubic, hodo2);
33 double maxX = SkTMax(hodo2[1].x, hodo2[1].x);
34 double maxY = SkTMax(hodo2[1].y, hodo2[1].y);
35 double dist = sqrt(maxX * maxX + maxY * maxY);
36 double segments = sqrt(dist / (8 * FLT_EPSILON));
37 return segments;
38 }
OLDNEW
« no previous file with comments | « experimental/Intersection/CubicLineSegments.h ('k') | experimental/Intersection/CubicParameterization.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698