

This gives us the first 10 digits after the decimal point of pi. Return parse.(Int, collect(string(BigFloat(pi))))

Let's get the digits of pi first: max_digits = 10ĭigits = setprecision(BigFloat, Int(ceil(log2(10) * max_digits+10))) do I'm using quadratic bezier curves for that. Therefore we can't draw straight lines from one segment to another. I think it's visually appealing the have the circle in the middle where we can add the \(\pi\) (or \(\tau\)) symbol later. Remember that the array is 1 index based in Julia. I used the scheme rainbow starting with the 7th color :D You might want to experience with other color schemes as here the colors are not that easy to distinguish but I still somehow like it. That looks much better! Let's get some nice colors from Colorschemes.jl. This is because an arc continues the current path. We will fix that next :) I also rearranged the order of label and arc2r and put a move in there as otherwise some lines are drawn from the label to the arc. I've used randomhue to get a random color. We define the following function to get the \(\theta\) and the corresponding point in an easier way: function get_coord(val, radius) c1, p1, p2: c1 is the center of the circle and p1 and p2 are the points on the circle between which the segment should be shown. Here we could increase the radius or use offset in the label command.įor the first problem, we need the arc2r function which takes three arguments + action. Additionally, an offset would be great to not be directly on the cycle or too close to it. :N is \(-\frac\) and add the current angle of rotation to it. The label command takes three values: the text, rotation and position where the rotation can be written as :N, :E, :S, :W for north, east, south, west or as an angle (in radians). We actually don't need the circle, we need arcs (segments) for each digit Remember that y is increasing when going down. As I only translate by y I don't need the first term. When rotating the canvas by \(\theta\) and then translating by x,y. I've decided for this as I needed that way for later anyway. It can be actually done this way in Luxor using rotate and translate. Then we basically have to rotate our canvas and move by the radius in the top direction to draw the label. I add 0.1π because I want to move to the middle of each segment. The 2π*0.1*i will start at the north position and then for the next i it will move by \(36\degree\). Might not be ideally written (besides that I might wanna use \(\tau\) :D). The first part should be quite straightforward. Let's draw the outer circle first and add the digits: radius = begin A radius must be given as the second parameter. In Luxor the origin is in the middle of the canvas. The O is the letter O not the number O :) It represents the origin and is a short form for Point(0, 0). Same is true when setting the line width with setline or setting font size or other general settings.ĭrawing commands like circle normally take some parameters and end with an action parameter like :stroke or :fill. It sets the color for the next drawing commands until you change the color. Sethue sets a color and takes either a string as shown above or a color from the Colors package for example. Let's go through the commands really quick: begin I know you're curious how the end result should look like: Getting started using LuxorĬalling vis() then creates start.png which looks like: Important: It shouldn't have a mathematical interpretation it's just a small visualization project ) First we need to be comfortable with Luxor.jl. Each time we move a bit clockwise in the segment such that 1->4 creates different curves (depending on the current position we are at). The digits of our irrational number are visualized by curves inside that circle such that 3.1415 (I start with 14) is a curve from the 1 segment to the 4 segment and then back to 1 to 5 and so on. It consists of a circle (which of course fits to \(\pi\) and \(\tau\)) and is split into 10 segments, one for each digit. It shows visualizations by Martin Krzywinski. I wanted to recreate a visualization I've seen on Numberphile.
