0

Extra lines in pythagorean trees

Using the unmodified code from Fractals.hproj, I am seeing extra lines in the output that shouldn't be there.

This seems to happen in the pythagorean trees, but it may be happening elsewhere as well.

For example, the following code results in the attached screenshot.

myLine = ((400, 800), (260, 800))

drawPicture 2 [(green, fractalTree 0.75 13 myLine)]

I am pretty sure the rest of the code is unmodified, but here is the code for fractalTree:

-- constructs the tree as one single path
fractalTree :: Float -> Int -> Line -> Path
fractalTree factor n line = fractalTree' n line
where
fractalTree' 0 line = []
fractalTree' n line
= [p1, p4] ++ fractalTree' (n-1) (p4,p5) ++
fractalTree' (n-1) (p5,p3) ++
[p3,p2]
where
flipLine (pS, pE) = (pE, pS)
[p1,p2,p3,p4,_] = polygon 4 line
(_, p5) = rotateLine (factor * pi) $
flipLine $
scaleLine 0.5 $ (p3, p4)

Haskell for Mac v. 1.5.0

3 comments

Please sign in to leave a comment.