My First Lung Fractal

Since I first moved to the Philippines, the air pollution has been one of the hardest features to come to grips with.

I seem to have especially sensitive lungs as I come down with lung infections 2 to 3 times a year and it lingers for several weeks meanwhile nobody around me ever seems to get sick.

But enough about that, the coronavirus has given people all sorts of reasons to pay more attention to their lungs in 2020 and 2021.

I also have a thing for fractals and lungs are one of the famous examples of fractals that make an impact on our everyday life. One study estimated a whopping 480 million alveoli in the lungs of an average adult.

At a diametre of 0.2mm across, you need 8 of them to provide 1mm^2 of oxygen:blood interface. This gives me a total surface are of 60m^2. While other internet sources yield 50 to 100 m^2; about the size of a tennis court.

To hit those kinds of numbers from a structure that bifurcates (branches or splits into 2), you need 29 levels of branching. Meanwhile, this study models branching down to 23 levels. My computer starts to seriously slow down around 12. Poor little bugger!

I recently discovered Dr Geo, a pretty cool open-source geometry drawing program with a Smalltalk interface. This is totally new territory for me but I was able to get a branching fractal to make a crude approximation of a lung structure.

Give it a shot, windows users will probably need to use Ubuntu in Windows:

| figure angle alpha beta strand centre edge |
figure := DrGeoFigure new.
angle := 30.
alpha := (figure freeValue: angle degreesToRadians) hide.
beta := (figure freeValue: (360 - angle) degreesToRadians) hide.
centre := (figure point: 0@6) hide.
edge := (figure point: 0@0) hide.

strand := [  :s1 :s2 :n | | p1 p2 p3  seg |
	p1 := (figure middleOf: s1 and: s2) hide.
	p2 := (figure rotate: s2 center: s1  angle: alpha) hide. 
	p3 := (figure rotate: s2 center: s1  angle: beta) hide. 
	seg := (figure segment: s1 to: p1) .
	n >6 ifTrue: 
		[ 
			seg large. 
		].
	n >0 ifTrue:
		[ 
			strand
				value: p1
				value: p2
				value: n - 1.
			strand
				value: p1
				value: p3
				value: n - 1.
		].
	n=0 ifTrue:
		[ 
			figure segment: p1 to: p2. 
			figure segment: p1 to: p3.
		 ].
].

strand
	value: centre
	value: edge
	value: 10.

Comments (If you are using an extension like https://privacybadger.org, this may be disabled)