使用一块树莓派主板测量圆周率
圆周率
![](/data/attachment/album/202304/13/120203upp4tb199bbhpp59.jpg)



> 
> 用你的树莓派制作一个接近完美的圆。
> 
> 
> 


世界各地将 3 月 14 日定为圆周率日。许多人通过在房子周围找到的物体测量圆周率来庆祝圆周率日。我想用我的树莓派 3B 为今年的圆周率日做一些类似的事情。继续阅读以了解我如何使用我的树莓派测量圆周率。


你需要什么：


* 树莓派单板机
* 方格纸
* 带毫米和厘米测量值的标尺
* 笔


### 1、画一个圆


圆周率是圆的周长与其直径的比值。要计算圆周率，我们需要测量一个完美绘制的圆的周长和直径。幸运的是，树莓派主板上的安装孔足够大，可以使用铅笔或钢笔。我通过一个树莓派板安装孔插入了一根图钉，小心地将针放在一张方格纸上两条线的交点上。


握住别针，我将一支笔插入对面的安装孔中，并通过将笔绕着别针移动来画一个圆圈。树莓派主板底面的焊点会卡在纸上，但小心点还是可以画好圆圈的。


![Use the Raspberry Pi as a compass to draw a circle.](/data/attachment/album/202304/13/120233ia00o0ucqr070occ.jpg)


### 2、把圆分成段


通过画一条穿过圆心的垂直线将圆分成两半，通过画一条穿过圆心的水平线将圆再次分成四分之一。当我画圆的时候，我把图钉正好放在图画纸上两条线的交点上，这样就很容易找到垂直和水平的中心线。你可以通过在对角线上画一条线来创造一个 “八分” 片。


![Each small wedge is 1/8 of a circle.](/data/attachment/album/202304/13/120240u33bwrz38qfzb0q3.jpg)


进一步的划分是与尺子的练习。我用尺子找到“四分之一楔形”和“八分之一楔形”任意两个交点的中点，做成一个 1/16 的楔形。你可以使用相同的方法制作越来越小的 1/32 和 1/64 圆的切片。通过非常小心，我还能够在圆的 1/128 处测量出一个非常窄的楔形：


![If you are careful, you can keep dividing to find 1/128 of a circle.](/data/attachment/album/202304/13/120248e2u6lvjh0v1mfcmk.jpg)


### 3、估算周长


我最小的楔形是一个圆的 1/128。如此小的切片，楔形的外弧非常小，我们可以用一条直线来近似它。这实际上不是圆周长的 1/128，但它足够接近，我们可以将其用作一个很好的估计。


![Use the mm measurement on your ruler to measure the outer arc of the 1/128 segment.](/data/attachment/album/202304/13/120255a400rflle8irhz0w.jpg)


使用我的尺子上的毫米测量值，我测量了我的 1/128 楔形的外弧为 3.8 毫米。这样，我可以估计圆的周长为 3.8 毫米乘以 128，即 486.4 毫米。要转换为厘米，除以十：**48.64cm**。


### 4、计算圆周率


圆周率的值是圆的周长与其直径的比值。我们在步骤 3 中估算了周长。测量直径是使用尺子测量圆周的简单练习。我的圆是 **15.4cm**。


现在我们知道了周长和直径，我们可以将圆周率计算为 48.64 除以 15.4，即 **3.158**。这与 pi 的实际值 3.141 相差不远。


测量圆周率是一项有趣的数学练习！各个年龄段的数学爱好者都可以使用方格纸、笔和尺子等简单工具自行测量圆周率。以一种有趣的新方式使用你的树莓派来绘制圆并独立测量圆周率。这是一个估计值，因为我们将圆上的 1/128 弧近似为一条直线，但这使我们无需太多努力就足够接近了。


（LCTT 校注：这真是对树莓派的“合理”应用，摔！）


*（题图：MJ: Circumference in high resolution, very detailed）*




---


via: <https://opensource.com/article/23/3/measure-pi-raspberry-pi>


作者：[Jim Hall](https://opensource.com/users/jim-hall) 选题：[lkxed](https://github.com/lkxed/) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
March 14th is celebrated around the world as Pi Day. Many people celebrate Pi Day by measuring pi with objects found around the house. I wanted to do something similar for this year's Pi Day using my Raspberry Pi 3B. Read on to learn how I measured pi using my Raspberry Pi.

What you'll need:

- Raspberry Pi single-board computer
- Graph paper
- Ruler with mm and cm measurements
- Pen

## 1. Draw a circle

Pi is the ratio of the circumference of a circle to its diameter. To calculate pi, we need to measure both the circumference and diameter of a perfectly drawn circle. Fortunately, the Raspberry Pi motherboard has mounting holes that are big enough to fit a pencil or pen. I stuck a pin through one Pi board mounting hole, careful to land the pin on the intersection of two lines on a piece of graph paper.

Holding the pin still, I inserted a pen in the opposite mounting hole and drew a circle by moving the pen around the pin. The solder points on the underside of the Raspberry Pi motherboard can catch on the paper, but you can draw a good circle if you are careful.

![Use the Raspberry Pi as a compass to draw a circle.](https://opensource.com/sites/default/files/2023-03/10000000000003E8000003E8BE7DE71919BB0C82.jpg)

(Jim Hall, CC BY-SA 4.0)

## 2. Divide the circle into segments

Divide the circle in half by drawing a vertical line through the center of the circle and again into quarters by drawing a horizontal line through the circle. When I drew my circle, I placed the pin exactly on the intersection of two lines on the graph paper, which makes finding the vertical and horizontal center lines easy to find. You can create an "eighth" slice by drawing a line across the diagonal.

![Each small wedge is 1/8 of a circle.](https://opensource.com/sites/default/files/2023-03/100000010000028A0000028A0625B218857F031C.webp)

(Jim Hall, CC BY-SA 4.0)

Further divisions are an exercise with the ruler. I used the ruler to find the midpoint of any two intersections of the "quarter-wedge" and the "one-eighth wedge" to make a 1/16 wedge. You can use the same method to make smaller and smaller slices that are 1/32 and 1/64 of a circle. By being very careful, I was also able to measure a very narrow wedge at 1/128 of a circle:

![If you are careful, you can keep dividing to find 1/128 of a circle.](https://opensource.com/sites/default/files/2023-03/100000000000079E00000514506C8EE5131D886A.webp)

(Jim Hall, CC BY-SA 4.0)

## 3. Estimate the circumference

My smallest wedge is 1/128 of a circle. With such a small slice, the outer arc of the wedge is so small that we can approximate it with a straight line. This will not actually be 1/128 of the circle's circumference, but it will be close enough that we can use it as a good estimate.

![Use the mm measurement on your ruler to measure the outer arc of the 1/128 segment.](https://opensource.com/sites/default/files/2023-03/10000000000003E8000003E881402FB71F1945FF.jpg)

(Jim Hall, CC BY-SA 4.0)


Using the mm measurement on my ruler, I measured the outer arc of my 1/128 wedge at 3.8mm. With that, I can estimate the circumference of my circle as 3.8mm times 128, or 486.4mm. To convert to centimeters, divide by ten: **48.64cm**.

## 4. Calculate pi

The value of pi is the ratio of the circumference of a circle to its diameter. We estimated the circumference in step 3. Measuring the diameter is a simple exercise of using the ruler to measure across the circle. My circle is **15.4cm**.

Now that we know the circumference and diameter, we can calculate pi as 48.64 divided by 15.4, which is **3.158**. That's not too far off from the actual value of pi, at 3.141.

Measuring pi is a fun math exercise! Math fans of all ages can use simple tools such as graph paper, pen, and ruler to measure pi on their own. Use your Raspberry Pi in a fun, new way to draw a circle and measure pi independently. This is an estimate since we are approximating a 1/128 arc on a circle as a straight line, but this gets us close enough without too much effort.

## Comments are closed.