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 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|improve this question
5  
The downvoter of OP's question should have posted a reason, imho. –  Shaun Ault Dec 20 '11 at 13:26
add comment

1 Answer 1

(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|improve this answer
    
you exactly got the problem! and your way seems smart but i've just got an idea: usinf atan2? en.wikipedia.org/wiki/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
add comment

Your Answer

 
discard

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.