Lines Matching refs:cubic

22 static int coincident_line(const Cubic& cubic, Cubic& reduction) {
23 reduction[0] = reduction[1] = cubic[0];
27 static int vertical_line(const Cubic& cubic, ReduceOrder_Styles reduceStyle, Cubic& reduction) {
29 reduction[0] = cubic[0];
30 reduction[1] = cubic[3];
36 int roots = findExtrema(cubic[0].y, cubic[1].y, cubic[2].y, cubic[3].y, tValues);
38 double yExtrema = interp_cubic_coords(&cubic[0].y, tValues[index]);
50 static int horizontal_line(const Cubic& cubic, ReduceOrder_Styles reduceStyle, Cubic& reduction) {
52 reduction[0] = cubic[0];
53 reduction[1] = cubic[3];
59 int roots = findExtrema(cubic[0].x, cubic[1].x, cubic[2].x, cubic[3].x, tValues);
61 double xExtrema = interp_cubic_coords(&cubic[0].x, tValues[index]);
74 static int check_quadratic(const Cubic& cubic, Cubic& reduction) {
75 double dx10 = cubic[1].x - cubic[0].x;
76 double dx23 = cubic[2].x - cubic[3].x;
77 double midX = cubic[0].x + dx10 * 3 / 2;
78 if (!AlmostEqualUlps(midX - cubic[3].x, dx23 * 3 / 2)) {
81 double dy10 = cubic[1].y - cubic[0].y;
82 double dy23 = cubic[2].y - cubic[3].y;
83 double midY = cubic[0].y + dy10 * 3 / 2;
84 if (!AlmostEqualUlps(midY - cubic[3].y, dy23 * 3 / 2)) {
87 reduction[0] = cubic[0];
90 reduction[2] = cubic[3];
94 static int check_linear(const Cubic& cubic, ReduceOrder_Styles reduceStyle,
98 while (cubic[startIndex].approximatelyEqual(cubic[endIndex])) {
105 if (!isLinear(cubic, startIndex, endIndex)) {
109 reduction[0] = cubic[0];
110 reduction[1] = cubic[3];
116 bool useX = cubic[maxX].x - cubic[minX].x >= cubic[maxY].y - cubic[minY].y;
118 sameSide1 = sign(cubic[0].x - cubic[1].x) + sign(cubic[3].x - cubic[1].x);
119 sameSide2 = sign(cubic[0].x - cubic[2].x) + sign(cubic[3].x - cubic[2].x);
121 sameSide1 = sign(cubic[0].y - cubic[1].y) + sign(cubic[3].y - cubic[1].y);
122 sameSide2 = sign(cubic[0].y - cubic[2].y) + sign(cubic[3].y - cubic[2].y);
130 roots = findExtrema(cubic[0].x, cubic[1].x, cubic[2].x, cubic[3].x, tValues);
132 roots = findExtrema(cubic[0].y, cubic[1].y, cubic[2].y, cubic[3].y, tValues);
136 extrema.x = interp_cubic_coords(&cubic[0].x, tValues[index]);
137 extrema.y = interp_cubic_coords(&cubic[0].y, tValues[index]);
141 if (extrema.x < cubic[0].x ^ extrema.x < cubic[3].x) {
144 replace = (extrema.x < cubic[0].x | extrema.x < cubic[3].x)
145 ^ (cubic[0].x < cubic[3].x);
147 if (extrema.y < cubic[0].y ^ extrema.y < cubic[3].y) {
150 replace = (extrema.y < cubic[0].y | extrema.y < cubic[3].y)
151 ^ (cubic[0].y < cubic[3].y);
158 bool isLinear(const Cubic& cubic, int startIndex, int endIndex) {
160 lineParameters.cubicEndPoints(cubic, startIndex, endIndex);
163 double distance = lineParameters.controlPtDistance(cubic, 1);
167 distance = lineParameters.controlPtDistance(cubic, 2);
172 http://objectmix.com/graphics/132906-fast-precision-driven-cubic-quadratic-piecewise-degree-reduction-algos-2-a.html
174 Given points c1, c2, c3 and c4 of a cubic Bezier, the points of the
194 // note that three points in a line doesn't simplify a cubic
197 int reduceOrder(const Cubic& cubic, Cubic& reduction, ReduceOrder_Quadratics allowQuadratics,
204 if (cubic[minX].x > cubic[index].x) {
207 if (cubic[minY].y > cubic[index].y) {
210 if (cubic[maxX].x < cubic[index].x) {
213 if (cubic[maxY].y < cubic[index].y) {
218 double cx = cubic[index].x;
219 double cy = cubic[index].y;
221 SkTMax(fabs(cubic[minX].x), fabs(cubic[minY].y))));
228 if (approximately_equal_half(cx * inv, cubic[minX].x * inv)) {
231 if (approximately_equal_half(cy * inv, cubic[minY].y * inv)) {
237 return coincident_line(cubic, reduction);
239 return vertical_line(cubic, reduceStyle, reduction);
242 return horizontal_line(cubic, reduceStyle, reduction);
244 int result = check_linear(cubic, reduceStyle, minX, maxX, minY, maxY, reduction);
249 && (result = check_quadratic(cubic, reduction))) {
252 memcpy(reduction, cubic, sizeof(Cubic));