Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path.compare() fails with intermediate point added #1223

Closed
iconexperience opened this issue Dec 22, 2016 · 4 comments
Closed

Path.compare() fails with intermediate point added #1223

iconexperience opened this issue Dec 22, 2016 · 4 comments
Assignees

Comments

@iconexperience
Copy link
Contributor

Here is a simple example where Path.compare() works only in one direction, but not the other:

var p1 = new paper.Path({segments: [[100, 100], [150, 100], [200, 100], [200, 200], [100, 200]], closed: true});
var p2 = new paper.Path({segments: [[100, 100], [200, 100], [200, 200], [100, 200]], closed: true});
console.log(p1.compare(p2)); // true
console.log(p2.compare(p1)); // false

The paths look like this.

p1:
image

p2:
image

@iconexperience
Copy link
Contributor Author

Wow, Curve.getOverlaps() returns the overlaps in the wrong order:

var v1 = [0, 0, 0, 0, 100, 0, 100, 0];
var v2 = [50, 0, 50, 0, 100, 0, 100, 0];
var overlaps = Curve.getOverlaps(v1, v2);
console.log(overlaps); // [ [ 1, 1 ], [ 0.5, 0 ] ]

@lehni lehni self-assigned this Dec 29, 2016
@lehni
Copy link
Member

lehni commented Dec 30, 2016

Interesting! I just found the same to be a problem. Will changing the overlap sequence have any other impacts?

@lehni
Copy link
Member

lehni commented Dec 31, 2016

I think I've managed to fix this in 8845391, but I found another failing scenario:

var circle = new Path.Circle({
    center: [100, 100],
    radius: 100,
    fullySelected: true
});

var circle2 = circle.clone();
circle2.divideAt(50);
circle2.divideAt(100);

console.log(circle.compare(circle2)); // false
console.log(circle2.compare(circle)); // true

Note: The example needs the latest develop version for Path#divideAt()

@lehni lehni closed this as completed in c21e19b Dec 31, 2016
@lehni
Copy link
Member

lehni commented Dec 31, 2016

c21e19b is the correct fix, and also made the code more readable. This should explain the change:

        // Iterate through all end points:
        // First p1 of curve 1 & 2, then p2 of curve 1 & 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants