From 8ca3514a464ad689dde16b3e6424828b7090f628 Mon Sep 17 00:00:00 2001
From: Trevor Hartman
<100978684+thartmanoftheredwoods@users.noreply.github.com>
Date: Fri, 25 Aug 2023 14:57:03 -0700
Subject: [PATCH 1/2] Update README.md
Fixed Images
---
.idea/misc.xml | 2 +-
README.md | 8 ++++++--
src/ArchimedesPiMethod.java | 14 +++++++++++---
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/.idea/misc.xml b/.idea/misc.xml
index d15472f..045943f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 9513c6f..d34df80 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,8 @@ Today we know that ratio to be PI, or **Math.PI** in JAVA, but HOW?

* With this observation, and a little more geometry, we can create an algorithm to calculate the perimeter of larger and larger **inscribed** polygons.
* Remember, the more sides, (n represents the number of sides in the polygon), the more accurate our perimeter estimation is, so let's do the math...
-
+
+
* From the image above, you can see the **octagon** is divided into **isosceles triangles**, the bottom of which (labeled **s**) is the length we need to know.
* If we draw a line from the circle center perpendicular to the base of the triangle **s**, we divide **s** in half, so it becomes ${1 \over 2}s$ as depicted.
* From the picture, we can simplify our lives by assuming $h = 1$, and that the circle is a **Unit circle**.
@@ -21,7 +22,10 @@ Today we know that ratio to be PI, or **Math.PI** in JAVA, but HOW?
* WELL, we can calculate B, so let's start there. Remember, a Circle is **360°** and we are equally dividing that by **n** sides ($n = 8$ in the example).
* So... $B = {360° \over 8}$ or $45°$ and $A = {1 \over 2} * B$ so $A = 22.5°$ in our example.
* Now we can calculate ${1 \over 2}s$ if we recall $sin(A) = {{1 \over 2}s \over h}$ as shown in the below diagram of the triangle.
- 
+
+
+
+* ...continued...
* Solving for *s* we see $s = 2 * h * sin(A)$
* And since we agreed $h = 1$, that simplifies to $s = 2 * sin(A)$
* Now we have *s*, so to get the **polygon perimeter**, we just multiply by the number of sides to get it.
diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java
index 0b6e780..732e4b4 100644
--- a/src/ArchimedesPiMethod.java
+++ b/src/ArchimedesPiMethod.java
@@ -1,7 +1,15 @@
import java.util.Scanner;
-
+/* Chris Shortt's homework Java Assignment-002 */
public class ArchimedesPiMethod {
- public static void main(String[] args) {
-
+ public static void main(String[] args){
+ System.out.println("please type the number of sides");
+ Scanner sc = new Scanner(System.in);
+ int n = sc.nextInt();
+ double b = 360.0 / n;
+ double a = b / 2;
+ double s = 2 * Math.sin(Math.toRadians(a));
+ double p = n * s;
+ double pi = p / 2;
+ System.out.printf("Our PI estimate is: %f", pi );
}
}
From 01365023c601c0d262754d9c8d44e13359d82b97 Mon Sep 17 00:00:00 2001
From: cshor
Date: Sun, 24 Sep 2023 10:13:56 -0700
Subject: [PATCH 2/2] end of lecture
Fixed Images
---
src/ArchimedesPiMethod.java | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/ArchimedesPiMethod.java b/src/ArchimedesPiMethod.java
index 732e4b4..0b4eea6 100644
--- a/src/ArchimedesPiMethod.java
+++ b/src/ArchimedesPiMethod.java
@@ -1,15 +1,22 @@
import java.util.Scanner;
/* Chris Shortt's homework Java Assignment-002 */
public class ArchimedesPiMethod {
- public static void main(String[] args){
- System.out.println("please type the number of sides");
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- double b = 360.0 / n;
- double a = b / 2;
- double s = 2 * Math.sin(Math.toRadians(a));
- double p = n * s;
- double pi = p / 2;
- System.out.printf("Our PI estimate is: %f", pi );
+ public static void main(String[] args) {
+ while (true) {
+ System.out.println("please type the number of sides");
+ Scanner sc = new Scanner(System.in);
+ int n = sc.nextInt();
+ if (n < 1){
+ break;
+ }
+ double b = 360.0 / n;
+ double a = b / 2;
+ double s = 2 * Math.sin(Math.toRadians(a));
+ double p = n * s;
+ double pi = p / 2;
+ System.out.printf("Our PI estimate is: %.10f %n", pi);
+ System.out.println(pi);
+
+ }
}
-}
+}
\ No newline at end of file