Commit Graph

34 Commits (b37e74f5f37960f4623476d904384d19e4d2c1b1)

Author SHA1 Message Date
Sebastian Kuzminsky b37e74f5f3 Update Path.area to work with Arc segments (#65)
* add some tests of Path.area()

These tests currently fail because area() doesn't deal with Arc segments.
Fix in the following commit.

* make Path.area() approximate arcs

Fixes #37.

* Path.area(): fixup tabs/spaces for python3

* added asin to imports

* added asin to imports

* minor improvements to style, performance, and docstring
2018-11-04 21:40:56 -08:00
Sebastian Kuzminsky 2feb3c92b5 Arc line intersect, 3rd try (#64)
* add Line.point_to_t() and tests

These tests don't print anything while they run, and they use use the
assert() helpers from the unittest module.

* add Arc.point_to_t() and tests

These tests don't print anything while they run, and they use use the
assert() helpers from the unittest module.

* add a bunch of failing arc/line intersection tests

This commit contains a bunch of failing arc/line intersections that I
and other people have run into.

These tests don't print anything while they run, and they use use the
assert() helpers from the unittest module where possible.

All these tests are fixed in the following commit.

* better implementation of Arc.intersect(Line)

Fixes mathandy/svgpathtools#35.

This commit fixes all the arc/line intersection test cases added in the
previous commit.

This implementation provides special handling in Arc.intersect() when
`self` is a non-rotated Arc and `other_seg` is a Line.  In this case
it uses the straight-forward closed-form solution to identify the
intersection points.

Rotated Arcs and Arcs intersecting with non-Line objects still use
the pre-existing intersection code, that part is totally untouched by
this commit.
2018-11-04 20:55:17 -08:00
Andy Port 165372562e
Revert "Arc line intersect, take 2 (#60)" (#63)
This reverts commit 2da39e4c02.
2018-08-22 00:27:55 -07:00
Sebastian Kuzminsky 2da39e4c02 Arc line intersect, take 2 (#60)
* add Line.point_to_t() and tests

* add Arc.point_to_t() and tests

* add a bunch of failing arc/line intersection tests

This commit contains a bunch of failing arc/line intersections that I
and other people have run into.

All these tests are fixed in the following commit.

* better implementation of Arc.intersect(Line)

Fixes mathandy/svgpathtools#35.

This commit fixes all the arc/line intersection test cases added in the
previous commit.

This implementation provides special handling in Arc.intersect() when
`self` is a non-rotated Arc and `other_seg` is a Line.  In this case
it uses the straight-forward closed-form solution to identify the
intersection points.

Rotated Arcs and Arcs intersecting with non-Line objects still use
the pre-existing intersection code, that part is totally untouched by
this commit.
2018-08-22 00:19:05 -07:00
Andy Port 7ebc56a831 aesthetic cleanup 2018-08-21 20:54:02 -07:00
Andy Port 40a515ee63 removed all np.matrix uses (deprecation) 2018-08-21 20:05:59 -07:00
Michael X. Grey 360d6b224c Flattening SVG groups and handling transforms (#55)
* Some progress (and added CONTRIBUTING.md)

* fixed documentation line-width to be PEP 8 compliant

* fixed documentation line-width to be PEP 8 compliant

* style changes

* made some design changes

* Make the Document class available when importing the library

* Add a method to parse transform strings

* Iterate on the implementation of the Document class

* Tweaks to transform parsing implementation

* Implementing a depth-first flattening of groups

* Finish implementation of flatten_paths

* Beginning to write tests for groups

* Refactoring flatten_paths() into flatten_all_paths()

* Clean up implementation of document classes

* Debugging xml namespace behavior -- needs improvement

* Improve the way the svg namespace is handled

* Print out some paths to see that they're sane

* Fix multiplication of numpy matrices -- need to use .dot() instead of operator*

* Create a unit test for parsing SVG groups

* Return a reference to an element instead of a copied dictionary of attributes

* Add a test for <path> elements that contain a 'transform' attribute

* minor docstring improvements

* got rid of svg2path changes (reverted to master)

* updated to match master

* Remove accidental paranthesis

* Remove unnecessary import

* Use a default width and height of 0, as dictated by SVG specs, in case width or height is missing

* Expose the CONVERSIONS and CONVERT_ONLY_PATHS constants

* Fix the use of some numpy operations

* Remove untested functions

* Fix add_group() and write tests for adding groups and paths

* Update documentation of document module

* Add tests for parsing transforms

* Update the module name for svg_to_paths

* Improve Python3 compatibility

* Try to improve compatibility

* More tweaks for compatibility
2018-08-21 18:00:29 -07:00
Andy ccc9ee6ae1 added clipping to work around floating point error in Arc._parameterize() 2018-07-24 15:07:02 -07:00
Andy b47345da91 added clipping to work around floating point error in Arc._parameterize() 2018-07-24 14:57:54 -07:00
Andy fd521748fa fixed scaled (before cleanup) 2018-07-06 22:59:28 -04:00
Andy 850055fa57 fixed bez2poly function 2018-06-10 14:38:08 -07:00
Andy a2ea4a0e80 fixed path curvature 2018-06-10 14:33:17 -07:00
Andy fd95b5609f partially fixed scale fcn and improved tests 2018-06-08 22:13:18 -07:00
Andy Port 72d7467896
implemented (almost) full SVG scale transform functionality 2018-05-30 19:07:58 -07:00
Orion Elenzil ee656c7de0 refactor `scale()` and `scaled()` to `scale_uniform()` and `scaled_uniform()` 2018-05-30 10:54:56 -07:00
Andy Port 0827206953
style changes 2018-05-22 19:59:03 -07:00
Orion Elenzil d21a66aff0 add scale() for curves, and scaled() for paths 2018-05-22 12:45:04 -07:00
Andy Port 71b4403375
fix typo `joins_smoothl_with` 2018-04-13 14:34:28 -07:00
Andy Port a50c522f86
use np.close to check to check for vanishing denom
Just to offer users some amount of control over the tolerance.
2018-02-27 22:38:01 -08:00
Sebastian Kuzminsky 89d9acf06e Line.intersect(Line): fix a "miss some intersections" bug
Negative numbers are allowed in the denominator, what we really want to
avoid is near-zero denominators.
2018-01-20 20:46:54 -07:00
Sebastian Kuzminsky fc34d2c4cf deal with float rounding error in Line.intersect(Line)
This commit fixes #41.

In the test case added in the previous commit, two non-intersecting lines
are very nearly collinear, but float rounding errors lead to incorrect
intersections reported.

This commit makes Line.intersect() treat denominators below 1e-9 as 0,
to make it more accepting of float rounding.
2018-01-06 23:15:43 -07:00
Anders Granskogen Bjørnstad ec63d0c312 Arc: Handle round-off issue with acos()
math.acos raises outside of valid range [-1, 1]. Handle round-off errors
gracefully by using `round()` here too.
2017-11-10 13:44:24 +01:00
Andy a094f92b3a added polyline and polygon functions (points --> Path of Line objects) 2017-04-26 01:54:44 -07:00
Andy 60d67923b6 fix issue#15 Path.cropped() bug, and more
-also fixed <path>.cropped(1, 0) bug (now raises AssertionError)
-also now Path.cropped() raises AssertionError if given negative values
2017-03-30 01:38:27 -07:00
Andy 1655b77d15 removed builtins imports 2017-02-28 23:34:29 -08:00
Andy 8815ddcd52 futurized for Python 3 compatibility
and some other minor changes of no effect
2017-02-28 23:04:37 -08:00
Andy a154796576 changes related to arcs and intersections
-fixed quadratic/Arc intersections
-changed assertion that an arc's radii are positive to non-zero
-improved Arc.intersect() docstring to further explain partial
implementation
2017-02-20 22:10:16 -08:00
Andy a81af16d89 improved Arc docstring and added positive radii assertion to Arc 2017-02-20 20:11:54 -08:00
Andy c219d1e671 improved Arc class docstring 2017-02-20 19:46:16 -08:00
Andy 058b23585f fixed bug (issue #9) where line.intersect(curve) results are reversed 2017-02-20 19:21:07 -08:00
remi-pr 3575fec9af Fixed the rotated method of all objects
The rotated method of all objects was not using the origin argument but always self.point(0.5) even though it is all correctly handled in the rotate function they are all calling
2016-10-28 15:11:31 +02:00
Andy 6be04c6750 Fix python 3 incompatibility with Path.intersect() method 2016-10-16 00:20:52 -07:00
Andy a6719c56c5 fixed __init__.py 2016-07-23 17:15:22 -07:00
Andy 9b3d6fe5e3 initial commit 2016-07-05 21:51:11 -07:00