Giter VIP home page Giter VIP logo

Comments (3)

wobsta avatar wobsta commented on August 21, 2024

PyX behaves very well defined given the fact, that circles are closed paths, but still have a begin and end point. It is the point to the right, but you may rotate it, like to the top like so path.circle(sin(v), cos(v), 1.7).transformed(trafo.rotate(90, sin(v), cos(v))). The intersect return values are ordered along the first path. Quoting from the split example of the gallery (https://nbviewer.jupyter.org/urls/sf.net/p/pyx/gallery/split/attachment/split.ipynb):

The first segment returned by the split method ends at the first splitting point, the second segment goes from the first splitting point to the second splitting point (and maybe this path element will thus have a different orientation than the original path). Finally, for an open path the last item in the list of returned segments will go from the last splitting point to the end of the path. However, for a closed path this last path item is prepended to the first segment returned by the split method. Thus for a closed path the first segment will always go from the last to the first splitting point.

Your code should probably return the shorter of the two paths created from the split method ...

from pyx.

Volker-Weissmann avatar Volker-Weissmann commented on August 21, 2024

Returning the shorter of two paths might we correct in this case, but is wrong in other cases.

IMHO, there should be a documented way how to get the intersecting area of two closed paths, e.g. for a venn diagram.

from pyx.

wobsta avatar wobsta commented on August 21, 2024

I am not quite sure whether it is the right format to discuss on a close issue, but I don't mind. In addition I am not familiar with venn diagrams.

Regarding the area of two intersecting closed paths, there clearly are several solutions:

from pyx import *

c = canvas.canvas()

def intersect(y, p1, p2):
    c1 = path.circle(0, y, 4)
    c2 = path.circle(3, y, 2)
    c.stroke(c1)
    c.stroke(c2)
    (int1), (int2) = c1.intersect(c2)
    c1segs = c1.split(int1)
    c2segs = c2.split(int2)
    c.fill(c1segs[p1] << c2segs[p2].reversed(), [color.rgb.red])

intersect(0, 0, 0)
intersect(-10, 1, 0)
intersect(-20, 0, 1)
intersect(-30, 1, 1)

c.writePDFfile()

intersects.pdf

from pyx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.