Commit graph

4554 commits

Author SHA1 Message Date
Jürg Lehni
b3d45b6624 Some code clean-up in addCurveIntersections() 2015-10-05 19:32:13 +02:00
Jürg Lehni
c8132584b9 Pass on original curves to addLocation(), to correctly determine p1 and p2.
This fixes one glitch in @iconexperience's test suite.
2015-10-05 19:31:38 +02:00
Jürg Lehni
fcdf916863 Some tweaks to debugging code.
Leave open path artifacts clearly visible for now, so they can be more easily detected.
2015-10-05 17:42:01 +02:00
Jürg Lehni
1f03b00f99 Remove handling of converged fat-line, as it causes issues.
Example 23 in #784 was caused by this, and the code's removal has not produced any new issues, while it solved 6 issues in @iconexperience's test suite.

Closes #795
2015-10-05 17:20:56 +02:00
Jürg Lehni
93cacffd06 Improve comments describing isValid() calls. 2015-10-05 10:56:29 +02:00
Jürg Lehni
7494f880f8 Revert previous commit, due to wrong assumption. 2015-10-05 10:44:34 +02:00
Jürg Lehni
90b4cf7292 No need to check for overlap when determining value for unadjusted
Since setting only changes behavior if there actually is an overlap.
2015-10-05 05:52:35 +02:00
Jürg Lehni
05bc6afdbb Always give intersection segment priority over current segment if valid.
Fixes example 22 in #784, doesn't seem to introduce new issues, unlike last time I tried this approach.
2015-10-05 05:34:22 +02:00
Jürg Lehni
bd4874d73e Improve debug logging of windings. 2015-10-05 04:57:12 +02:00
Jürg Lehni
ba76ed8671 Consider the winding contribution at the intersection of the next segment as well.
Fixes both example 20 and example 21 in #784
2015-10-05 04:24:04 +02:00
Jürg Lehni
d2c762997f Address improvements mentioned by @hkrish in #794 2015-10-04 18:36:18 +02:00
Jürg Lehni
5601e21996 Make sure the two locations are actually part of the same path before comparing index / parameter values. 2015-10-04 10:14:04 +02:00
Jürg Lehni
035a3a1b8c Remove unnecessary _visited check. 2015-10-04 02:27:56 +02:00
Jürg Lehni
ebc956353f Move code to adjust segments after split to CurveLocation. 2015-10-04 02:25:33 +02:00
Jürg Lehni
be2f98d91a Optimize various isCollinear() and isOrthogonal() methods. 2015-10-03 17:42:52 -04:00
Jürg Lehni
8073183010 Use getIntersections() with right filter instead of getCrossings() for boolean operations. 2015-10-03 17:17:12 -04:00
Jürg Lehni
79cb216684 Define CurveLocation#isOverlap() and improve documentation of various related methods. 2015-10-03 17:15:45 -04:00
Jürg Lehni
5af8515d1a Commit some useful debug code, deactivated for now. 2015-10-03 16:18:00 -04:00
Jürg Lehni
86b1b74869 Prevent detection of tiny overlaps and streamline addOverlap() code. 2015-10-03 12:55:32 -05:00
Jürg Lehni
2bed611648 Improve Curve#getPart() to directly handle reversed curves and write docs for it. 2015-10-03 12:55:05 -05:00
Jürg Lehni
6fb4b7e3c4 Change the way overlaps are detected in lines.
We don't really care weather they are actually fully collinear, we only really care about the distances from the beginnings- and end-points of one line from the other, since that proximity will affect results elsewhere.
2015-10-03 11:46:50 -05:00
Jürg Lehni
5d7a596026 Fix wrong upper bounds check in Line.intersect()
1 as a solution was accidentally excluded.
2015-10-03 11:44:43 -05:00
Jürg Lehni
61fc75ace3 Some code clean-up. 2015-10-03 10:40:33 -05:00
Jürg Lehni
50c7473337 Improve CurveLocation#add() and #equals() to better merge locations.
Before, very close locations over curve boundaries where not merged.
2015-10-03 10:40:13 -05:00
Jürg Lehni
2167e458ae Since we're using sorting now, we can add all start- / end-point intersections before finding the ones within the curves. 2015-10-03 10:38:45 -05:00
Jürg Lehni
7496a7c9e2 Try linked up intersections first before switching to the other intersecetion. 2015-10-02 19:00:32 -05:00
Jürg Lehni
632eb25f19 Bring back code removed in 11611c8fe2 again.
But add a _visited check, to get best of both approaches.
2015-10-02 18:57:45 -05:00
Jürg Lehni
00f1d5089f Clean up Numerical code a bit. 2015-10-02 18:56:41 -05:00
Jürg Lehni
f6f9d963eb Shorten Numerical.solveQuadratic() a bit. 2015-10-02 15:46:15 -05:00
sapics
c6de2f7f23 Fix to minimize floating point noise 2015-10-02 15:39:51 -05:00
Jürg Lehni
11611c8fe2 Remove isValid() check for current segment before attempting the switch.
This properly fixes example 14 in #784.
2015-10-02 01:06:36 -05:00
Jürg Lehni
7f7d35a38a Clean-up epsilon definitions. 2015-10-02 01:05:45 -05:00
Jürg Lehni
8dfa721e5a Adjust debug rendering. 2015-10-01 21:12:15 -05:00
Jürg Lehni
a808aaf0fa Remove unnecessary check for other === start. 2015-10-01 21:11:51 -05:00
Jürg Lehni
de57a7fbc8 Simplify tracePaths() code. 2015-10-01 21:09:30 -05:00
Jürg Lehni
c0bb6890bd Switch back to CURVETIME_EPSILON now that overlap edge-case appears to be handled. 2015-10-01 20:47:56 -05:00
Jürg Lehni
4b4ccbac09 Make GEOMETRIC_EPSILON so that overlap edge-cases are correctly matched.
Relates to #784
2015-10-01 20:45:08 -05:00
Jürg Lehni
9b883e5fb6 Introduce new TRIGONOMETRIC_EPSILON with higher precision than GEOMETRIC_EPSILON. 2015-10-01 20:44:27 -05:00
Jürg Lehni
f5012a78e9 Reformat nested ternary operators again.
This got messed up in a recent refactoring.
2015-10-01 20:24:47 -05:00
Jürg Lehni
8aca088bf6 Clean-up splitPath() code a bit. 2015-10-01 09:41:57 -05:00
Jürg Lehni
72f9705615 Fix overeager refactoring in c77165be3a 2015-10-01 08:49:26 -05:00
Jürg Lehni
fee3a90329 Fixed leaked globals. 2015-10-01 07:05:00 -05:00
Jürg Lehni
b8c6eb46ad Fix weirdness of Curve#divide() modifying the wrong Curve object. 2015-10-01 06:52:08 -05:00
Jürg Lehni
c77165be3a Fix issue in Curve#divide() that lead to intersection segments being linked up wrongly.
Relates to #784
2015-10-01 06:21:17 -05:00
Jürg Lehni
53dd726057 Rename ignoreStraight argument to _setHandles 2015-10-01 05:55:22 -05:00
Jürg Lehni
0ca5a106de Improve Line.intersect() comments. 2015-10-01 04:50:41 -05:00
Jürg Lehni
75a004187e Improve Line.intersect() to more reliably find interesctions at the beginnings / ends.
Relates to #784
2015-10-01 04:38:48 -05:00
Jürg Lehni
53ff973f06 Perform the faster check first. 2015-10-01 03:38:35 -05:00
Jürg Lehni
5f706a4a5d Use lower tolerance in bezier clipping code.
This really should be Numerical.CURVETIME_EPSILON, but I get better results using Numerical.GEOMETRIC_EPSILON. Perhaps Numerical.CURVETIME_EPSILON / 2 is the right value to use though.
2015-09-30 14:19:40 -05:00
Jürg Lehni
d385d25a51 Include comment regarding CurveLocation#equals() modification. 2015-09-30 13:48:28 -05:00
Jürg Lehni
9bcf369e6a Ony split potentially self-intersecting curves if there are actual canditates. 2015-09-30 13:44:51 -05:00
Jürg Lehni
45040abc53 More clean-ups for #773
- Use local variables instead of array lookups for values used repeatetly, and merge with pre-existing variables.
- Add some more comments and reference to long explaining post in issue.
2015-09-30 13:40:01 -05:00
Jürg Lehni
1231153553 Start cleaning up code from #773
- Use Line object isntead of static methods
- Do not rely on Math.sign() as it's not supported on all browsers
- Wrap lines at 80 char width.
2015-09-30 13:07:55 -05:00
Jürg Lehni
2a7d1c5728 Improve CurveLocation#equals()
Relates to #784, described in https://github.com/paperjs/paper.js/issues/784#issuecomment-143161586
2015-09-30 12:47:02 -05:00
Jürg Lehni
4e9bac1ca5 Fix code brokean in commit a869add90d 2015-09-30 12:39:59 -05:00
Jürg Lehni
07874034e9 Merge pull request #793 from iconexperience/Fix-for-#773
Fix for #773
2015-09-30 11:51:37 -05:00
Jan
ec70fa1806 Fix for #773
Indroduced more reliable method for finding self intersection on curves.
2015-09-30 12:19:09 +02:00
Jürg Lehni
a869add90d Rename variables in Line.intersect() 2015-09-26 12:09:44 -05:00
Jürg Lehni
317b809fee Only calculate non-parametric bezier curve if values are actually used. 2015-09-26 11:46:54 -05:00
Jürg Lehni
ea3cc63e2e Reformat code a bit. 2015-09-26 07:41:03 -04:00
Jan
3fa810a557 Bugfix for #791 and performance improvement
Prevent infinite loop for degenerate curve. Additionally only calculate sy if necessary and save one call to `Curve.solveCubic`
2015-09-26 07:36:12 -04:00
Jürg Lehni
fd927cbe22 Properly solve issues with self-intersecting special case.
(e.g. shapes resembling the infinity sign)
2015-09-24 12:49:39 -04:00
Jürg Lehni
fc0b5a8858 Give the intersection that brings us back to the beginning alwasy the priority. 2015-09-24 07:47:39 -04:00
Jürg Lehni
c79166a46f Mark last segment as visited when done. 2015-09-23 14:31:12 -04:00
Jürg Lehni
cf5bf38c3b Minor simplification. 2015-09-23 13:33:35 -04:00
Jürg Lehni
515d4ff93d Make Line.isCollinear() / Point#isCollinear() more reliable. 2015-09-23 13:26:29 -04:00
Jürg Lehni
cc7e60e51a Revert db1ecdddd5 and fix issue properly this time.
Hopefully?
2015-09-23 12:44:00 -04:00
Jürg Lehni
20f950ac65 Implement #isFirst() / #isLast() tests on Segment and Curve. 2015-09-23 12:26:44 -04:00
Jürg Lehni
db1ecdddd5 Fix filtering of locations at ends of curves in addCurveLineIntersections()
Only occured when the line / curve had to be flipped.
2015-09-21 16:56:08 -04:00
Jürg Lehni
6a29f200e3 Always use getIntersection(), even on the first segment.
Now that it works well.
2015-09-21 12:44:53 -04:00
Jürg Lehni
51c34444db Some more debugging code clean-up. 2015-09-21 12:18:57 -04:00
Jürg Lehni
84bcc537e1 Simplify addCurveLineIntersections() and exclude end points. 2015-09-21 12:13:53 -04:00
Jürg Lehni
0f61ce896a Some code clean-up. 2015-09-21 10:54:33 -04:00
Jürg Lehni
ce95043e99 Lower geometric epsilon.
Differences slightly above 1e-8 where observed.
2015-09-21 10:54:17 -04:00
Jürg Lehni
812ac63e60 Compare points instead of curve time paramters for better precision and reliability. 2015-09-21 10:53:53 -04:00
Jürg Lehni
e36319b71a Give PathItem#getIntersections() a way to filter found intersections right away.
And use it in #getCrossings()
2015-09-21 10:41:59 -04:00
Jürg Lehni
f6f42fe09b Improve handling of overlap ambiguity in getIntersection()
Two passes are needed, first strict, then non-strict, to prevent 'better' next candiates over 'worse' ones.
2015-09-21 09:44:17 -04:00
Jürg Lehni
19a17b2918 Prevent infinite loops through circular references of multiple intersections. 2015-09-21 09:43:19 -04:00
Jürg Lehni
40570b3e59 Furher improve boolean debug logging and drawing. 2015-09-21 09:42:47 -04:00
Jürg Lehni
1ad95c9020 Improve CurveLocation.add() to always merge duplicates.
We nee to check neighbors of the found location too.
2015-09-21 07:06:41 -04:00
Jürg Lehni
f47af12b0d Shorten code statement. 2015-09-20 23:22:41 +02:00
Jürg Lehni
1302df0cb8 Fix variable leackage. 2015-09-20 23:22:31 +02:00
Jürg Lehni
b68be09c87 Fix all accidental non-breaking spaces. 2015-09-20 22:39:28 +02:00
Jürg Lehni
530b8b7bc8 Handle adjusted overlap winding contribution and operator calls through new isValid() function. 2015-09-20 15:50:26 +02:00
Jürg Lehni
738cc4c214 Yet another improvement in multiple interseections boolean code.
This appears to be the one. The only remaining failing cases seem to be linked to getting the same intersection twice now!

Relates to #787
2015-09-20 15:29:54 +02:00
Jürg Lehni
946157f1b1 Add note about usage of _originalWinding. 2015-09-20 14:19:14 +02:00
Jürg Lehni
20ed1e007c More fixes in handling of multiple intersection locations. 2015-09-20 14:17:23 +02:00
Jürg Lehni
5db9703aff No more need to check for crossings since every intersection is now either an overlap or a crossing. 2015-09-20 14:16:47 +02:00
Jürg Lehni
53862233e5 Improve debug logging of new multiple intersections code. 2015-09-19 22:47:57 +02:00
Jürg Lehni
4df65c1809 Various improvements to code that handles multiple intersections in same location.
Relates to #787
2015-09-19 19:07:44 +02:00
Jürg Lehni
1d6f552212 Prevent endless loop through circular references. 2015-09-19 13:42:48 +02:00
Jürg Lehni
2c8634793c First attempt at implementing handling of multiple intersections in the same location.
Relates to #787, works pretty well already for many situations.
2015-09-19 13:21:29 +02:00
Jürg Lehni
081de1d12a 'exclude' operation needs overlap handling too. 2015-09-18 22:29:29 +02:00
Jürg Lehni
a95ba12bc3 isCrossing() needs parameter checks on both curves. 2015-09-18 22:26:09 +02:00
Jürg Lehni
b5af47a7b1 Implement a better approach to calculate Path#clockwise...
...merging code with Path#area.

Closes #788
2015-09-18 21:41:54 +02:00
Jürg Lehni
8cf562c57b Revert "Remove special handling of winding contribution on overlaps"
This reverts commit c6a38589e9.
The special handling seems to be still necessary in some edge cases, e.g. in BooleanOperations.html
2015-09-18 21:10:58 +02:00
Jürg Lehni
10eafccd1a Implement 0.75 * handle scaling in curve bounds checks. 2015-09-18 21:09:57 +02:00
Jürg Lehni
17dc5eb51a Allow gettings of unstyled bounds on curves without paths. 2015-09-18 20:15:18 +02:00
Jürg Lehni
c6a38589e9 Remove special handling of winding contribution on overlaps
Looks like the new code handles this correclty now!
2015-09-18 18:06:15 +02:00
Jürg Lehni
23443dc8f4 Clean up boolean code. 2015-09-18 17:51:57 +02:00
Jürg Lehni
66b01973f0 Simplify exclusion handling for new boolean code. 2015-09-18 17:51:43 +02:00
Jürg Lehni
87687d816b Implement PathItem#resolveCrossings() based on the new #getCrossings() method. 2015-09-18 17:51:03 +02:00
Jürg Lehni
c70f8cb3cc Simplify overlap calculations by keeping the original winding value. 2015-09-18 17:46:46 +02:00
Jürg Lehni
59a23fdd3f Improve debug logging. 2015-09-18 17:33:42 +02:00
Jürg Lehni
73a9989261 Fix CurveLocation#isCrossing() for locations in the middle of curves. 2015-09-18 17:32:19 +02:00
Jürg Lehni
ae93652b56 Clean up getIntersection() methods.
Now that they filter the results on the fly.
2015-09-18 17:31:23 +02:00
Jürg Lehni
85311cfb29 Improve Path#getArea() and #isClockwise() 2015-09-18 17:27:29 +02:00
Jürg Lehni
17356637ac Clean up new CurveLocation code. 2015-09-17 10:18:45 +02:00
Jürg Lehni
9c812335e5 Curve._filterIntersections() is now without a job. 2015-09-17 09:39:22 +02:00
Jürg Lehni
1508b8fc75 Improve debug logging. 2015-09-17 01:15:41 +02:00
Jürg Lehni
2750c34090 Improve the way intersections are sorted and merged.
Use a binary search to determine insertion index and compare with neighbours to eliminate doubles.
2015-09-17 01:03:13 +02:00
Jürg Lehni
30f1441c26 Various boolean code clean-ups. 2015-09-16 18:34:35 +02:00
Jürg Lehni
d0332f843f Renamed Curve#reverse() and Segment#reverse() to #reversed()
Since they don't modify the object. Also introduce new Segment#reverse(), which does.
2015-09-16 18:16:48 +02:00
Jürg Lehni
857e27e3a8 Fix accidental variable leackage. 2015-09-16 18:15:26 +02:00
Jürg Lehni
7061bc0e0a Simplify CurveLocation.sort() code
Relates to #787
2015-09-16 10:52:51 +02:00
Jürg Lehni
0980ad3fe9 Fix remaining issues with curve location sorting.
Relates to #787
2015-09-16 10:44:41 +02:00
Jürg Lehni
f8bd7a2005 Improve debug logging and drawing.
And add more descriptive comments to tracePath().
2015-09-16 09:52:41 +02:00
Jürg Lehni
197aa4b4cf No need to wrap angles as they're always -PI < a < PI. 2015-09-16 02:56:24 +02:00
Jürg Lehni
2026e5571e Some code cleanup and comments in isCrossing(). 2015-09-16 02:54:25 +02:00
Jürg Lehni
e548391276 Use the zero-epsilon when checking beginnings and ends of curves for overlaps.
Relates to #786 and #777
2015-09-16 02:33:56 +02:00
Jürg Lehni
1e5c1bafaf Increase geometric epsilon to better match collinear lines.
Needs more testing, but seems to perform well.

Relates to #786
2015-09-16 02:31:37 +02:00
Jürg Lehni
8f9549dd12 Fix non-breaking spaces. 2015-09-16 02:29:17 +02:00
Jürg Lehni
ad276ba46a More improvements in tracePaths()
- Use new isCrossing() check
- Correctly switch crossings in exclusion
2015-09-15 19:39:35 +02:00
Jürg Lehni
60a725b527 Implement correct CurveLocation#isCrossing() check.
And improve curve caching. Still needs work.
2015-09-15 19:38:28 +02:00
Jürg Lehni
3ce7d88347 Second attempt at simplifying boolean code.
This time without endless loops.
2015-09-15 16:31:05 +02:00
Jürg Lehni
089738478c Bring back boolean exclusion handling to reverted code. 2015-09-15 15:03:12 +02:00
Jürg Lehni
7b3f8598f4 Make sure all results of boolean operations are styled and inserted in the sample way. 2015-09-15 14:11:27 +02:00
Jürg Lehni
e4b4037721 Revert "Improve handling of exclude() operations."
This reverts commit e85586d0fe.
2015-09-15 13:01:52 +02:00
Jürg Lehni
5e327f7a48 Revert "Substantial simplifications in boolean code."
This reverts commit a665175a89.
2015-09-14 15:23:46 +02:00
Jürg Lehni
7aef20ae6b Compare intersection points instead of curve time when deciding to merge.
Use same precision indepenent of curve length.
2015-09-14 15:18:44 +02:00
Jürg Lehni
fec479167c Improve debug logging and drawing. 2015-09-14 15:16:52 +02:00
Jürg Lehni
a665175a89 Substantial simplifications in boolean code.
These were probably made possible thanks to increased precision elsewhere in the lib.
2015-09-14 01:20:03 +02:00
Jürg Lehni
e85586d0fe Improve handling of exclude() operations.
Determine wether to switch to other intersection or not based on tangents.

Closes #781 again.
2015-09-14 00:51:46 +02:00
Jürg Lehni
b532c9cce2 Handle boolean exclusion as a special case.
Switching each time an intersection is encountered.

Closes #781
2015-09-13 22:12:04 +02:00
Jürg Lehni
fbb0f3f37d Remove left-over debugging code. 2015-09-13 21:50:35 +02:00
Jürg Lehni
b231e9b2a8 Accept CompoundPath items as children of CompoundPath items.
Just add their children and remove the parent.

Closes #541
2015-09-13 16:06:24 +02:00
Jürg Lehni
e2d2c836e5 Some boolean code clean-up. 2015-09-13 14:19:56 +02:00
Jürg Lehni
ea2ff5ec28 Increase precision in Curve.getParameterOf()
Usually only requires 0-1 more iteration.
2015-09-13 13:45:20 +02:00
Jürg Lehni
f029d5f9da Write docs for the new EPSILON values. 2015-09-13 13:41:53 +02:00
Jürg Lehni
d84a84c67f Change the way winding contributions are propagated
The new approach preserves segment sequence.

Relates to #777
2015-09-13 13:06:01 +02:00
Jürg Lehni
19c9a0e722 Use the correct points on curve2 when checking intersections at beginnings and ends. 2015-09-13 11:52:17 +02:00
Jürg Lehni
d62caf6faa Introduce CURVETIME_EPSILON, to be used when handling curve time parameters.
Relates to #777
2015-09-12 22:55:58 +02:00
Jürg Lehni
4f04dae20f Use the correct GEOMETRIC_EPSILON when matching beginnings and ends of curve in Curve.getParameterOf()
Relates to #777
2015-09-12 22:26:16 +02:00
Jürg Lehni
8047f90ccf Switch to using GEOMETRIC_EPSILON in getWinding() code. 2015-09-12 22:20:31 +02:00
Jürg Lehni
ef45a5f62c Clean up tMin / tMax uses. 2015-09-12 22:14:04 +02:00
Jürg Lehni
a0730756c1 Use correct term for curve parameter renormalization. 2015-09-12 22:13:18 +02:00
Jürg Lehni
085cdd74a2 Use GEOMETRIC_EPSILON when comparing curve start / end points.
Relates to #777
2015-09-12 21:56:53 +02:00
Jürg Lehni
2fb203ddd1 Adjust notes since we now support boolean operations on self-intersecting Paths items 2015-09-12 11:58:17 +02:00
Jürg Lehni
3da921a0b0 Improve CompoundPath#reduce() to properly reduce suppaths.
Relates to #779
2015-09-12 11:43:41 +02:00
Jürg Lehni
fb5f8c0115 Introduce GEOMETRIC_EPSILON, for isOrthogonal(), isCollinear() and overlap checks.
Relates to #777
2015-09-12 10:35:47 +02:00