Koch snowflakes

This is a discussion on Koch snowflakes within the Programming Languages forums in category; If I generate a Koch snowflake of an order higher than 1, then it conflicts with my recursive algorithm because: i) A Koch Snowflake of order 1 involves generating three triangles from the sides of the initial triangle. ii) All Koch Snowflakes of order >= 2 involves the creation of only two triangles. The third is not needed because the third side becomes non-existent. How can I rectify this? I initially thought: keep it general in the sense that I should not treat the order = 1 case as special. In this way, I can check for an order >= ...

Go Back   Application Development Forum > Programming Languages

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-06-2008, 09:50 PM
conrad
Guest
 
Default Koch snowflakes

If I generate a Koch snowflake of
an order higher than 1, then it conflicts
with my recursive algorithm because:
i) A Koch Snowflake of order 1 involves
generating three triangles from the sides
of the initial triangle.
ii) All Koch Snowflakes of order >= 2
involves the creation of only two
triangles. The third is not needed
because the third side becomes
non-existent.

How can I rectify this?
I initially thought: keep it general
in the sense that I should not
treat the order = 1 case as special.
In this way, I can check for an
order >= 2 Koch Snowflake by
determining which point generated ends
up within the area of the polygon.

I'm only posting this because I'm
curious if there is a different approach
that someone would have taken.

--
conrad
Reply With Quote
  #2  
Old 09-06-2008, 11:13 PM
Gene
Guest
 
Default Re: Koch snowflakes

On Sep 6, 9:50*pm, conrad <con...@lawyer.com> wrote:
> If I generate a Koch snowflake of
> an order higher than 1, then it conflicts
> with my recursive algorithm because:
> i) A Koch Snowflake of order 1 involves
> generating three triangles from the sides
> of the initial triangle.
> ii) All Koch Snowflakes of order >= 2
> involves the creation of only two
> triangles. *The third is not needed
> because the third side becomes
> non-existent.
>
> How can I rectify this?
> I initially thought: keep it general
> in the sense that I should not
> treat the order = 1 case as special.
> In this way, I can check for an
> order >= 2 Koch Snowflake by
> determining which point generated ends
> up within the area of the polygon.
>
> I'm only posting this because I'm
> curious if there is a different approach
> that someone would have taken.


I'm not sure what you're saying. Here's an alogorithm to return a
list of all the star vertices:

function koch (k)
let s = sqrt(3)/2
if k = 1 return [ [0, 1], [-s -1/2], [s, -1/2], [0, 1] ]
rtn = [];
for each adjacent pair [a, b] in koch(k - 1)
let v = b - a
c = a + 1/3 * v
d = a + 2/3 * v
e = s * perp(d - c)
append [ a, c, e, d, b ] onto rtn
return rtn


Note that

perp([x, y]) = [-y, x]
Reply With Quote
  #3  
Old 09-07-2008, 04:23 AM
CBFalconer
Guest
 
Default Re: Koch snowflakes

conrad wrote:
>
> If I generate a Koch snowflake of an order higher than 1, then it
> conflicts with my recursive algorithm because:
> i) A Koch Snowflake of order 1 involves generating three
> triangles from the sides of the initial triangle.
> ii) All Koch Snowflakes of order >= 2 involves the creation of
> only two triangles. The third is not needed because the
> third side becomes non-existent.
>
> How can I rectify this? I initially thought: keep it general in
> the sense that I should not treat the order = 1 case as special.
> In this way, I can check for an order >= 2 Koch Snowflake by
> determining which point generated ends up within the area of the
> polygon.
>
> I'm only posting this because I'm curious if there is a different
> approach that someone would have taken.


What is a Koch snowflake? What is a Koch snowflake order? What is
your recursive algorithm?

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Reply With Quote
  #4  
Old 09-07-2008, 04:50 AM
jellybean stonerfish
Guest
 
Default Re: Koch snowflakes

On Sun, 07 Sep 2008 04:23:54 -0400, CBFalconer wrote:


>
> What is a Koch snowflake?

Stop pretending your stupid.

> What is a Koch snowflake order?

Stop pretending your stupid.

> What is your recursive algorithm?


Good guestion.

Reply With Quote
  #5  
Old 09-07-2008, 06:40 AM
Martin Eisenberg
Guest
 
Default Re: Koch snowflakes

conrad wrote:

> If I generate a Koch snowflake of
> an order higher than 1, then it conflicts
> with my recursive algorithm because:
> i) A Koch Snowflake of order 1 involves
> generating three triangles from the sides
> of the initial triangle.
> ii) All Koch Snowflakes of order >= 2
> involves the creation of only two
> triangles. The third is not needed
> because the third side becomes
> non-existent.
>
> How can I rectify this?


If I understand well:
Don't *count* the edges, just *walk* them.


Martin

--
Quidquid latine scriptum est, altum videtur.
Reply With Quote
  #6  
Old 09-07-2008, 07:11 AM
Willem
Guest
 
Default Re: Koch snowflakes

conrad wrote:
) If I generate a Koch snowflake of
) an order higher than 1, then it conflicts
) with my recursive algorithm because:
) i) A Koch Snowflake of order 1 involves
) generating three triangles from the sides
) of the initial triangle.
) ii) All Koch Snowflakes of order >= 2
) involves the creation of only two
) triangles. The third is not needed
) because the third side becomes
) non-existent.

Doesn't a Koch Snowflake work by changing each
edge of the current shape into four edges ?
They just happen to be at 60-degree angles,
and you just happen to start with a triangle.

How are you using triangles to do it ?
As I see it, that would miss out a lot of sides.



SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Reply With Quote
  #7  
Old 09-07-2008, 08:27 AM
Richard Heathfield
Guest
 
Default Re: Koch snowflakes

CBFalconer said:

<snip>

> What is a Koch snowflake?


Is this a joke?

> What is a Koch snowflake order?


An equilateral triangle is a Koch snowflake of order 0.

To obtain a Koch snowflake S of order N, given a Koch snowflake K of order
(N - 1):

for each straight line segment on K (as it existed before any mods):
(a) identify C, the central third (33.3etc%) of the line segment
(b) consider C to be the base of an equilateral triangle "pointing"
away from the centre of the figure
(c) complete the equilateral triangle by drawing two new line segments
(d) remove C from the figure
endfor

> What is your recursive algorithm?


The Web contains many examples.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Reply With Quote
  #8  
Old 09-07-2008, 08:48 AM
conrad
Guest
 
Default Re: Koch snowflakes

On Sep 7, 6:11*am, Willem <wil...@stack.nl> wrote:
> conrad wrote:
>
> ) If I generate a Koch snowflake of
> ) an order higher than 1, then it conflicts
> ) with my recursive algorithm because:
> ) i) A Koch Snowflake of order 1 involves
> ) generating three triangles from the sides
> ) of the initial triangle.
> ) ii) All Koch Snowflakes of order >= 2
> ) involves the creation of only two
> ) triangles. *The third is not needed
> ) because the third side becomes
> ) non-existent.
>
> Doesn't a Koch Snowflake work by changing each
> edge of the current shape into four edges ?
> They just happen to be at 60-degree angles,
> and you just happen to start with a triangle.
>
> How are you using triangles to do it ?
> As I see it, that would miss out a lot of sides.
>
> SaSW, Willem
> --
> Disclaimer: I am in no way responsible for any of the statements
> * * * * * * made in the above text. For all I know I might be
> * * * * * * drugged or something..
> * * * * * * No I'm not paranoid. You all think I'm paranoid, don't you !
> #EOT


Yeah, I only realized this after I had started to write the algorithm
for it.
The book that I was doing the problem from did not have a complete
explanation of a Koch Snowflake and so I filled in some gaps
with my own ideas. However, after having found a complete explanation
I understand the problem.

And understanding the problem is half the battle.

--
conrad
Reply With Quote
  #9  
Old 09-07-2008, 06:23 PM
CBFalconer
Guest
 
Default Re: Koch snowflakes

Richard Heathfield wrote:
> CBFalconer said:
>
> <snip>
>
>> What is a Koch snowflake?

>
> Is this a joke?


No. I never heard of such.

>
>> What is a Koch snowflake order?

>
> An equilateral triangle is a Koch snowflake of order 0.


Is it the only one?

>
> To obtain a Koch snowflake S of order N, given a Koch snowflake K of order
> (N - 1):
>
> for each straight line segment on K (as it existed before any mods):
> (a) identify C, the central third (33.3etc%) of the line segment
> (b) consider C to be the base of an equilateral triangle "pointing"
> away from the centre of the figure
> (c) complete the equilateral triangle by drawing two new line segments
> (d) remove C from the figure
> endfor
>
>> What is your recursive algorithm?

>
> The Web contains many examples.


Thanks. Two seconds work with a triangle and piece of paper gives
me the idea. What are they used for?

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Reply With Quote
  #10  
Old 09-08-2008, 01:42 AM
Richard Heathfield
Guest
 
Default Re: Koch snowflakes

CBFalconer said:

> Richard Heathfield wrote:
>> CBFalconer said:
>>
>> <snip>
>>
>>> What is a Koch snowflake?

>>
>> Is this a joke?

>
> No. I never heard of such.


Sierpinksi carpet? Menger sponge? Mandelbrot set? Julia set?

>>> What is a Koch snowflake order?

>>
>> An equilateral triangle is a Koch snowflake of order 0.

>
> Is it the only one?


Yes. Nevertheless, you could use some other figure to get a pseudoKoch
snowflake. For example, Eric Haines has produced a "sphereflake".

<snip>

> What are they used for?


What are Mandelbrot sets used for?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:56 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.