Twisty Triangles

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
mtnviewmark
Site Admin
Posts: 81
Joined: Wed May 04, 2005 12:46 pm
Location: Mountain View, CA
Contact:

Twisty Triangles

Post by mtnviewmark »

Image

Code: Select all

startshape TRIPLES

rule TRIPLES {
	LINES { r 0 }
	LINES { r 120 }
	LINES { r -120 }
}	

rule LINES {
	UTRIANGLE { y 0.5 }
	LINES { r 20 b 0.15 y 0.75 x -0.4330125  s 0.754877 }
	LINER { r -60 b 0.15 y 0.75 x 0.4330125  s 0.754877 }
 }
rule LINER { LINER15 { } }
rule LINER { LINER12 { } }
rule LINER { LINER9 { } }
rule LINER { LINER6 { } }
rule LINER15 {
	UTRIANGLE { y 0.5 }
	LINER { r -15 b 0.02
		y 0.75 x 0.4330125  s 0.754877 }
 }
rule LINER12 {
	UTRIANGLE { y 0.5 }
	LINER { r -12 b 0.02
		y 0.75 x 0.4330125  s 0.754877 }
 }
rule LINER9 {
	UTRIANGLE { y 0.5 }
	LINER { r -9 b 0.02
		y 0.75 x 0.4330125  s 0.754877 }
 }
rule LINER6 {
	UTRIANGLE { y 0.5 }
	LINER { r -6 b 0.02
		y 0.75 x 0.4330125  s 0.754877 }
 }

// 0.754877 is the solution to
// x^2 + x^3 = 1
// this allows double backed
// triangles to exactly line up!


rule TESTU {
	TESTU_background { }
	UTRIANGLE { }
	UTRIANGLE { y 0.5 x -0.866025 b 0.5 r 60 }
	UTRIANGLE { y 0.5 x +0.866025 b 0.5 r 60 }
}
rule TESTU_background {
	CIRCLE {  b 0.5 }
	CIRCLE  { y -1 }
	CIRCLE { y -0.5 x -0.866025 }
	CIRCLE { y -0.5 x 0.866025 }
	CIRCLE { y 0.5 x -0.866025 }
	CIRCLE { y 0.5 x 0.866025 }
	CIRCLE  { y 1 }
}

rule UTRIANGLE {
	TRIANGLE { r 42.5 s 0.525 }
}
rule TRIANGLE{ 
	ARM { r 0 }
	ARM { r 120 }
	ARM { r -120 }
} 

rule ARM {
	CIRCLE { }
	ARM { y 0.1 s 0.9 r 2 }
}
This one is especially fun to watch being drawn!

Two useful techniques demonstrated here:

First: The TESTU rule that I used to hand tweak all the parameters of the UTRIANGLE (U = unit).

Second: In the figure, the UTRIANGLES are always drawn with { y 0.5 }. This way the UTRIANGLE is drawn with the point on the "current spot". This makes it easy to move to one of the just drawn points, rotate a bit, scale (which are applied after the x & y move) and recurse.
I'm the "m" in "mtree.cfdg"

Post Reply