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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I continue this post because i have a problem: understand if a point is inside or outside a Koch curve.

I can find the third point of a equilateral triangle (and i need it for build a koch curve) but i have 2 solution: now i have to decide which one is the best (the one that is outside the koch curve)!

this figure explain better:

enter image description here

the little equilateral triangle in the red circles have the wrong direction.

Some ideas?

share|cite|improve this question
The downvoter of OP's question should have posted a reason, imho. – Shaun Ault Dec 20 '11 at 13:26

(Assuming this is related to programming, as the link indicates.)

If you give each segment a consistent orientation (just a choice of ordering on the two endpoints), then you will always be able to tell 'inside' from 'outside'. For example, suppose I have a segment oriented ($a$, $b$), where $a$ and $b$ are endpoints. Then I want to introduce trisecting points $a'$ and $b'$ (so the order I have in mind is $a$, $a'$, $b'$, $b$), then I choose $c$ not on the segment so that $a'c$ has the same length as $b'c$. Of course there are two such points $c$ (hence the question, right?). Let $\mathbf{u} = \vec{ab}$ and $\mathbf{v} = \vec{ac}$. We must choose $c$ so that the acute angle between $\mathbf{u}$ and $\mathbf{v}$ is swept out from $\mathbf{u}$ to $\mathbf{v}$ in a counterclockwise direction. One way to do this is to consider $\mathbf{u}, \mathbf{v}$ as 3-dimensional vectors with 0 component in the $z$ direction. Then take the cross product $\mathbf{u} \times \mathbf{v}$. If the result has a positive $z$-component, then the choice of $c$ was correct, while if it is negative, then other choice of $c$ was incorrect -- choose the other one. Note, since both $\mathbf{u}, \mathbf{v}$ live on the $xy$-plane, their cross product will only have a $z$-component. Also note, it is essential to know the order of $a$ and $b$ for this to work. To prepare for the next iteration, orient the new segments thus: $(a, a'), (a', c), (c, b'), (b', b)$.

Hope this helps!

share|cite|improve this answer
you exactly got the problem! and your way seems smart but i've just got an idea: usinf atan2? – nkint Dec 20 '11 at 16:34
Ok, sounds good. You ought to write that as an answer and accept it =) – Shaun Ault Dec 20 '11 at 21:31

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.