diff --git a/Documentation1.md b/Documentation1.md deleted file mode 100644 index 28f94fa..0000000 --- a/Documentation1.md +++ /dev/null @@ -1,19 +0,0 @@ -# Name: - -## Examples: -Insert examples here. - -## Description: -Insert description here - -## Syntax: -Demonstrate syntax here - -##Parameters: -Name and describe parameters here - -##Returns: -What type of data does it return? - -##Other notes: -Anything else? diff --git a/Documentation2.md b/Documentation2.md deleted file mode 100644 index 28f94fa..0000000 --- a/Documentation2.md +++ /dev/null @@ -1,19 +0,0 @@ -# Name: - -## Examples: -Insert examples here. - -## Description: -Insert description here - -## Syntax: -Demonstrate syntax here - -##Parameters: -Name and describe parameters here - -##Returns: -What type of data does it return? - -##Other notes: -Anything else? diff --git a/Documentation3.md b/Documentation3.md deleted file mode 100644 index 28f94fa..0000000 --- a/Documentation3.md +++ /dev/null @@ -1,19 +0,0 @@ -# Name: - -## Examples: -Insert examples here. - -## Description: -Insert description here - -## Syntax: -Demonstrate syntax here - -##Parameters: -Name and describe parameters here - -##Returns: -What type of data does it return? - -##Other notes: -Anything else? diff --git a/FunctionsChallenge/FunctionsChallenge.pde b/FunctionsChallenge/FunctionsChallenge.pde new file mode 100644 index 0000000..18d9c8b --- /dev/null +++ b/FunctionsChallenge/FunctionsChallenge.pde @@ -0,0 +1,62 @@ +PFont fon; +float planet = 100; +float star = 1000; +float distance = 25; +void setup() +{ + fon = createFont("Trebuchet MS", 24); + size(800, 600); +} +void draw() +{ + background(200); + textFont(fon); + fill(0); + textAlign(LEFT); + text("Planet's Mass: "+planet+" kg", 25, 25); + text("Star's Mass: "+star+" kg", 25, 50); + text("Average Distance: "+distance+" m", 25, 75); + text("Orbital Period: "+orbitalPeriod(planet, star, distance)+" s", 25, 100); + text("Geometric Sequence: 10*(0.5)^n", 25, 150); + text("Sum of First 10 Terms: "+geometricSeries(10, 0.5, 10), 25, 175); + text("Sum of Infinite Series: "+geometricSeries(10, 0.5), 25, 200); + bullseye(100, 500, 100, 5); + bullseye(300, 450, 200, 5); + bullseye(600, 450, 200, 13); +} +float geometricSeries(float a, float r, int n)//first term, common ratio, number of terms +{ + float numerator = 1-pow(r,n); + float denominator = 1-r; + float answer = a*(numerator/denominator); + return answer; +} +float geometricSeries(float a, float r)//first term, common ratio(calculates to infinity) +{ + float answer = a/(1-r); + return answer; +} +float orbitalPeriod(float m1, float m2, float a)//first mass, second mass, average distance between them +{ + float numerator = 4*sq(PI)*pow(a,3); + float denominator = 6.67*pow(10,-11)*(m1+m2); + float answer = sqrt(numerator/denominator); + return answer; +} +void bullseye(float x, float y, float d, int n)//x coordinate, y coordinate, diameter, number of rings +{ + boolean red = true;//stores whether or not the next circle is red + for(int i = n; i > 0; i--)//for each ring from the outside in + { + if(red)//fill the circle red + { + fill(255, 0, 0); + } + else//or fill the circle white + { + fill(255); + } + ellipse(x, y, i*(d/n), i*(d/n));//draw the ring + red = !red;//alternate between red and white + } +} \ No newline at end of file diff --git a/bullseye.md b/bullseye.md new file mode 100644 index 0000000..16595b0 --- /dev/null +++ b/bullseye.md @@ -0,0 +1,23 @@ +# Name: +bullseye() + +## Examples: +bullseye(width / 2, height / 2, 200, 8);//draws a bullseye 200 pixels in diameter in the middle of the canvas with 8 rings which are each 25 pixels wide + +## Description: +Draws a bullseye at the specified location. You can specify the diameter and number of rings. The rings are of equal width and alternate between red and white color. + +## Syntax: +bullseye(x, y, d, n) + +##Parameters: +x float: x-coordinate of the center of the bullseye +y float: y-coordinate of the center of the bullseye +d float: maximum diameter of the bullseye +n int: the number of rings the bullseye contains + +##Returns: +void + +##Other notes: +The outermost ring will always be red. \ No newline at end of file diff --git a/geometricSeries.md b/geometricSeries.md new file mode 100644 index 0000000..d2d8c0c --- /dev/null +++ b/geometricSeries.md @@ -0,0 +1,24 @@ +#Name: +geometricSeries() + +##Examples: +float q = geometricSeries(10, 2, 3);//q now holds 70.0 +float r = geometricSeries(0.9, 0.1);//r now holds 1.0 + +##Description: +Calculates the sum of a geometric series and returns that value. Defines a series by its first term and its common ratio. Can be calculated for a defined number of terms or to infinity. + +##Syntax: +geometricSeries(a, r, n) +geometricSeries(a, r) + +##Parameters: +a float: first term of the series +r float: common ratio between each term in the series +n int: number of terms of the series to sum + +##Returns: +float + +##Other notes: +Gives an error when r is 1. Returns incorrect values when r is not greater than or equal to 0 and less than 1. \ No newline at end of file diff --git a/orbitalPeriod.md b/orbitalPeriod.md new file mode 100644 index 0000000..89a6788 --- /dev/null +++ b/orbitalPeriod.md @@ -0,0 +1,22 @@ +# Name: +orbitalPeriod() + +## Examples: +float time = orbitalPeriod(20000, 80, 2800);//time holds a value close to 804160000.0 + +## Description: +Returns the orbital period of a two-body gravitational system given both masses and the average distance between them. Uses the equation from Kepler's Third Law. This takes the masses in kilograms and the distance in meters. It returns the period in seconds. + +## Syntax: +orbitalPeriod(m1, m2, a) + +##Parameters: +m1 float: mass of the first object +m2 float: mass of the second object +a float: average distance between the two objects during orbit + +##Returns: +float + +##Other notes: +None \ No newline at end of file