Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a number of closed curves (contours) which I want split into groups of mutually intersecting curves. The contours are made of straight lines and bezier curves. How could I do that? Thanks!

share|improve this question
How much is "a number"? If there aren't that many, you could probably brute-force check by taking two contours at a time... –  J. M. Apr 17 '11 at 9:12
Yep, there are a little number of contours. I would do exactly that. However, I really wonder how would I check for intersections? And I should also clarify, because I didn't say it right the first time, that I'm interested in checking not the curves, but the closed regions they encircle. Could you suggest something? Sorry if I'm asking for an obvious thing, I'm slow with math. :-) –  Albus Dumbledore Apr 17 '11 at 9:38
Could you tell us why you need this? Knowing the background is helpful for choosing the level of the answer. –  Sam Nead Apr 17 '11 at 16:47

1 Answer 1

up vote 2 down vote accepted

Hopefully the package that allows you to draw Bezier curves also allows you to a) draw arbitrary lines and b) compute the number of intersections between a line and a Bezier curve. With those to things given: Suppose that $\alpha$ and $\beta$ are contours. From your comment I assume that $\alpha$ and $\beta$ do not self-intersect, nor do they intersect each other. Let $B$ be the region (a disk) bounded by $\beta$. So there are two cases to ponder. Either $\alpha$ is contained in $B$ or it isn't. So:

Suppose that $p$ is a point in the plane. Let $L_p$ be the vertical ray based at $p$. Now suppose that $q$ is a point on $\alpha$. Using the primitives of your program or otherwise, compute $N_q = |L_q \cap \beta|$, the number of intersections between $L_q$ and $\beta$. In general, $\alpha$ is contained in $B$ if and only if $N_q$ is odd.

There is a subtle point here: the ray $L_q$ needs to meet $\beta$ transversely for this to work. That is, $L_q$ must not be tangent to any point of $\beta$. One hack to get around this: compute the parity of $N_q$ for several random points $q \in \alpha$ and accept the "generic" answer.

By the way, Google finds a nice introduction to Bezier curves on-line - http://processingjs.nihongoresources.com/bezierinfo/

share|improve this answer
Just perfect! Thanks for the bother! –  Albus Dumbledore Apr 17 '11 at 17:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.