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/Functions.pde b/FunctionsChallenge/Functions.pde new file mode 100644 index 0000000..2b8caa9 --- /dev/null +++ b/FunctionsChallenge/Functions.pde @@ -0,0 +1,36 @@ +float findPermutation(float data, float places) { + //change the value of places to use it in the denominator + float denominator = data-places; + //set i equal to the denominator value minus one so that every time it goes through the for loop it multiplies by 1 less which simulates the factorial function + for (float i=denominator-1; i>=1; i--) { + denominator*=i; + } + //use the factorial method again for the numerator + for (float i=data-1; i>=1; i--) { + data=data*i; + } + //divide the two factorials found + float result= data/denominator; + //return the result + return result; +} + +float findAcceleration(float vi, float vf, float t) { + //use the acceleration equation to find acceleration + float acceleration = (vf-vi)/t; + //return the value + return acceleration; +} +void addAcceleration() { + //add acceleration to the object + for (int i=0; i= width) { + vx[i] = -abs(vx[i]); //if the ball hits the right wall, assign x velocity the negative version of itself + } else if (x[i] - d[i]/2 <= 0) { + vx[i] = abs(vx[i]); //if the ball hits the left wall, assign x velocity the positive version of itself + } + if (y[i] + d[i]/2 >= height) { + vy[i] = -abs(vy[i]); + y[i] = height - d[i]/2; + } else if (y[i] - d[i]/2 <= 0) { + vy[i] = abs(vy[i]); + } + } + //initialize variables + vf=findPermutation(random(0, 1), random(0, 1)); + a=findAcceleration(0, vf, 10); + //add acceleration to objects + addAcceleration(); +} \ No newline at end of file diff --git a/addAcceleration.md b/addAcceleration.md new file mode 100644 index 0000000..392328c --- /dev/null +++ b/addAcceleration.md @@ -0,0 +1,26 @@ +# Name: addAcceleration + +## Examples: +Increase or decrease the speed that the objects move. + +## Description: +Add acceleration to the objects by increasing or decreasing the velocity in each frame. + +## Syntax: +void addAcceleration() { + for (int i=0; i=1; i--) { + denominator*=i; + } + //use the factorial method again for the numerator + for (float i=data-1; i>=1; i--) { + data=data*i; + } + float result= data/denominator; //divide the two factorials found + return result; //return the result +} + +##Parameters: +The data parameter tells how many objects can be used to fill the requirement. In the example, this would be the 5 children. +The places parameter tells how many spaces can be filled by the objects. In the example, this would be the 3 places or 1st, 2nd, and 3rd place. +If you are using this function to return a random value you can put something like random(0,1) for the parameters in the loop so that you get a random value. + +##Returns: +This function returns the number of ways the data can be put in the places. +If you are using it to get a random number you will get a random value in return. + +##Other notes: +In my code, I used this functions to return a random value each time it went through the loop.