2362N/A * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A // Do not add horizontal lines 0N/A // Do not add horizontal lines 0N/A // Do not add horizontal lines 0N/A * Calculates the number of times the given path 0N/A * crosses the ray extending to the right from (px,py). 0N/A * If the point lies on a part of the path, 0N/A * then no crossings are counted for that intersection. 0N/A * +1 is added for each crossing where the Y coordinate is increasing 0N/A * -1 is added for each crossing where the Y coordinate is decreasing 0N/A * The return value is the sum of all crossings for every segment in 0N/A * The path must start with a SEG_MOVETO, otherwise an exception is 0N/A * The caller must check p[xy] for NaN values. 0N/A * The caller may also reject infinite p[xy] values as well. 0N/A "in path definition");
0N/A * Calculates the number of times the line from (x0,y0) to (x1,y1) 0N/A * crosses the ray extending to the right from (px,py). 0N/A * If the point lies on the line, then no crossings are recorded. 0N/A * +1 is returned for a crossing where the Y coordinate is increasing 0N/A * -1 is returned for a crossing where the Y coordinate is decreasing 0N/A // assert(y0 != y1); 0N/A * Calculates the number of times the quad from (x0,y0) to (x1,y1) 0N/A * crosses the ray extending to the right from (px,py). 0N/A * If the point lies on a part of the curve, 0N/A * then no crossings are counted for that intersection. 0N/A * the level parameter should be 0 at the top-level call and will count 0N/A * up for each recursion level to prevent infinite recursion 0N/A * +1 is added for each crossing where the Y coordinate is increasing 0N/A * -1 is added for each crossing where the Y coordinate is decreasing 0N/A // Note y0 could equal y1... 0N/A // py outside of y01 range, and/or y0==y1 0N/A // double precision only has 52 bits of mantissa 0N/A // [xy]c are NaN if any of [xy]0c or [xy]c1 are NaN 0N/A // [xy]0c or [xy]c1 are NaN if any of [xy][0c1] are NaN 0N/A // These values are also NaN if opposing infinities are added 0N/A * Calculates the number of times the cubic from (x0,y0) to (x1,y1) 0N/A * crosses the ray extending to the right from (px,py). 0N/A * If the point lies on a part of the curve, 0N/A * then no crossings are counted for that intersection. 0N/A * the level parameter should be 0 at the top-level call and will count 0N/A * up for each recursion level to prevent infinite recursion 0N/A * +1 is added for each crossing where the Y coordinate is increasing 0N/A * -1 is added for each crossing where the Y coordinate is decreasing 0N/A // Note y0 could equal yc0... 0N/A // py outside of y01 range, and/or y0==yc0 0N/A // double precision only has 52 bits of mantissa 0N/A // [xy]mid are NaN if any of [xy]c0m or [xy]mc1 are NaN 0N/A // [xy]c0m or [xy]mc1 are NaN if any of [xy][c][01] are NaN 0N/A // These values are also NaN if opposing infinities are added 0N/A * The rectangle intersection test counts the number of times 0N/A * that the path crosses through the shadow that the rectangle 0N/A * projects to the right towards (x => +INFINITY). 0N/A * During processing of the path it actually counts every time 0N/A * the path crosses either or both of the top and bottom edges 0N/A * of that shadow. If the path enters from the top, the count 0N/A * is incremented. If it then exits back through the top, the 0N/A * same way it came in, the count is decremented and there is 0N/A * no impact on the winding count. If, instead, the path exits 0N/A * out the bottom, then the count is incremented again and a 0N/A * full pass through the shadow is indicated by the winding count 0N/A * having been incremented by 2. 0N/A * Thus, the winding count that it accumulates is actually double 0N/A * the real winding count. Since the path is continuous, the 0N/A * final answer should be a multiple of 2, otherwise there is a 0N/A * logic error somewhere. 0N/A * If the path ever has a direct hit on the rectangle, then a 0N/A * special value is returned. This special value terminates 0N/A * all ongoing accumulation on up through the call chain and 0N/A * ends up getting returned to the calling function which can 0N/A * then produce an answer directly. For intersection tests, 0N/A * the answer is always "true" if the path intersects the 0N/A * rectangle. For containment tests, the answer is always 0N/A * "false" if the path intersects the rectangle. Thus, no 0N/A * further processing is ever needed if an intersection occurs. 0N/A * Accumulate the number of times the path crosses the shadow 0N/A * extending to the right of the rectangle. See the comment 0N/A * for the RECT_INTERSECTS constant for more complete details. 0N/A * The return value is the sum of all crossings for both the 0N/A * top and bottom of the shadow for every segment in the path, 0N/A * or the special value RECT_INTERSECTS if the path ever enters 0N/A * the interior of the rectangle. 0N/A * The path must start with a SEG_MOVETO, otherwise an exception is 0N/A * The caller must check r[xy]{min,max} for NaN values. 0N/A "in path definition");
0N/A // Count should always be a multiple of 2 here. 0N/A // assert((crossings & 1) != 0); 0N/A // Count should always be a multiple of 2 here. 0N/A // assert((crossings & 1) != 0); 0N/A // Count should always be a multiple of 2 here. 0N/A // assert((crossings & 1) != 0); 0N/A * Accumulate the number of times the line crosses the shadow 0N/A * extending to the right of the rectangle. See the comment 0N/A * for the RECT_INTERSECTS constant for more complete details. 0N/A // Line is entirely to the right of the rect 0N/A // and the vertical ranges of the two overlap by a non-empty amount 0N/A // Thus, this line segment is partially in the "right-shadow" 0N/A // Path may have done a complete crossing 0N/A // Or path may have entered or exited the right-shadow 0N/A // y-increasing line segment... 0N/A // We know that y0 < rymax and y1 > rymin 0N/A // y-decreasing line segment... 0N/A // We know that y1 < rymax and y0 > rymin 0N/A // Both x and y ranges overlap by a non-empty amount 0N/A // First do trivial INTERSECTS rejection of the cases 0N/A // where one of the endpoints is inside the rectangle. 0N/A // Otherwise calculate the y intercepts and see where 0N/A // they fall with respect to the rectangle 0N/A // y-increasing line segment... 0N/A // We know that y0 < rymax and y1 > rymin 0N/A // y-decreasing line segment... 0N/A // We know that y1 < rymax and y0 > rymin 0N/A * Accumulate the number of times the quad crosses the shadow 0N/A * extending to the right of the rectangle. See the comment 0N/A * for the RECT_INTERSECTS constant for more complete details. 0N/A // Quad is entirely to the right of the rect 0N/A // and the vertical range of the 3 Y coordinates of the quad 0N/A // overlaps the vertical range of the rect by a non-empty amount 0N/A // We now judge the crossings solely based on the line segment 0N/A // connecting the endpoints of the quad. 0N/A // Note that we may have 0, 1, or 2 crossings as the control 0N/A // point may be causing the Y range intersection while the 0N/A // two endpoints are entirely above or below. 0N/A // y-increasing line segment... 0N/A // y-decreasing line segment... 0N/A // The intersection of ranges is more complicated 0N/A // First do trivial INTERSECTS rejection of the cases 0N/A // where one of the endpoints is inside the rectangle. 0N/A // Otherwise, subdivide and look for one of the cases above. 0N/A // double precision only has 52 bits of mantissa 0N/A // [xy]c are NaN if any of [xy]0c or [xy]c1 are NaN 0N/A // [xy]0c or [xy]c1 are NaN if any of [xy][0c1] are NaN 0N/A // These values are also NaN if opposing infinities are added 0N/A * Accumulate the number of times the cubic crosses the shadow 0N/A * extending to the right of the rectangle. See the comment 0N/A * for the RECT_INTERSECTS constant for more complete details. 0N/A // Cubic is entirely to the right of the rect 0N/A // and the vertical range of the 4 Y coordinates of the cubic 0N/A // overlaps the vertical range of the rect by a non-empty amount 0N/A // We now judge the crossings solely based on the line segment 0N/A // connecting the endpoints of the cubic. 0N/A // Note that we may have 0, 1, or 2 crossings as the control 0N/A // points may be causing the Y range intersection while the 0N/A // two endpoints are entirely above or below. 0N/A // y-increasing line segment... 0N/A // y-decreasing line segment... 0N/A // The intersection of ranges is more complicated 0N/A // First do trivial INTERSECTS rejection of the cases 0N/A // where one of the endpoints is inside the rectangle. 0N/A // Otherwise, subdivide and look for one of the cases above. 0N/A // double precision only has 52 bits of mantissa 0N/A // [xy]mid are NaN if any of [xy]c0m or [xy]mc1 are NaN 0N/A // [xy]c0m or [xy]mc1 are NaN if any of [xy][c][01] are NaN 0N/A // These values are also NaN if opposing infinities are added 0N/A //return Math.rint(v*10)/10; 0N/A public static double prev(
double v) {
0N/A public static double next(
double v) {
0N/A System.out.println(this+".compareTo("+that+")"); 0N/A System.out.println("target range = "+yrange[0]+"=>"+yrange[1]); 0N/A // Parameter s for thi(s) curve and t for tha(t) curve 0N/A // [st]0 = parameters for top of current section of interest 0N/A // [st]1 = parameters for bottom of valid range 0N/A // [st]h = parameters for hypothesis point 0N/A // [d][xy]s = valuations of thi(s) curve at sh 0N/A // [d][xy]t = valuations of tha(t) curve at th 0N/A //System.out.println("s1 problem!"); 0N/A //System.out.println("t1 problem!"); 0N/A //double ymin = y1 * 1E-14; 0N/A System.out.println("s range = "+s0+" to "+s1); 0N/A System.out.println("t range = "+t0+" to "+t1); 0N/A System.out.println("sh = "+sh); 0N/A System.out.println("th = "+th); 0N/A System.out.println("final this["+s0+", "+sh+", "+s1+"]"); 0N/A System.out.println("final y["+ys0+", "+ysh+"]"); 0N/A System.out.println("final that["+t0+", "+th+", "+t1+"]"); 0N/A System.out.println("final y["+yt0+", "+yth+"]"); 0N/A System.out.println("final order = "+orderof(this.XforY(ymid), 0N/A System.out.println("final range = "+yrange[0]+"=>"+yrange[1]); 0N/A System.out.println("final sx = "+this.XforY(ymid)); 0N/A System.out.println("final tx = "+that.XforY(ymid)); 0N/A System.out.println("final order = "+orderof(this.XforY(ymid), 0N/A public static final double TMIN =
1E-3;
0N/A pad = pad+pad+pad+pad+pad; 0N/A System.out.println("----------------------------------------------"); 0N/A System.out.println(pad.substring(0, slevel)+ys0); 0N/A System.out.println(pad.substring(0, slevel)+ys1); 0N/A System.out.println(pad.substring(0, slevel)+(s1-s0)); 0N/A System.out.println("-------"); 0N/A System.out.println(pad.substring(0, tlevel)+yt0); 0N/A System.out.println(pad.substring(0, tlevel)+yt1); 0N/A System.out.println(pad.substring(0, tlevel)+(t1-t0)); 0N/A // Bounding boxes intersect - back off the larger of 0N/A // the two subcurves by half until they stop intersecting 0N/A // (or until they get small enough to switch to a more 0N/A // intensive algorithm). 0N/A // No more subdivisions 0N/A if (s >=
0 && s <=
1 && t >=
0 && t <=
1) {
0N/A if (s <
0 || s >
1 || t <
0 || t >
1) {
0N/A //System.out.println("Testing lines!");