From 4a0f63489f56f88b29ff5c8d3257c290b93a6235 Mon Sep 17 00:00:00 2001 From: akodali Date: Tue, 8 Dec 2015 13:39:27 -0500 Subject: [PATCH 01/17] add file to folder --- sketch_151208a/sketch_151208a.pde | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sketch_151208a/sketch_151208a.pde diff --git a/sketch_151208a/sketch_151208a.pde b/sketch_151208a/sketch_151208a.pde new file mode 100644 index 0000000..e69de29 From a2c238759721e0717a0731d77223d2cd6d4d8991 Mon Sep 17 00:00:00 2001 From: akodali Date: Tue, 8 Dec 2015 14:03:29 -0500 Subject: [PATCH 02/17] fix file names --- .../FunctionsChallenge.pde | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sketch_151208a/sketch_151208a.pde => FunctionsChallenge/FunctionsChallenge.pde (100%) diff --git a/sketch_151208a/sketch_151208a.pde b/FunctionsChallenge/FunctionsChallenge.pde similarity index 100% rename from sketch_151208a/sketch_151208a.pde rename to FunctionsChallenge/FunctionsChallenge.pde From df2aa181589fbe9570577154c98ecb920a78a8b0 Mon Sep 17 00:00:00 2001 From: akodali Date: Tue, 8 Dec 2015 14:03:52 -0500 Subject: [PATCH 03/17] started code still has errors and doesn't run --- FunctionsChallenge/FunctionsChallenge.pde | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/FunctionsChallenge/FunctionsChallenge.pde b/FunctionsChallenge/FunctionsChallenge.pde index e69de29..9b11443 100644 --- a/FunctionsChallenge/FunctionsChallenge.pde +++ b/FunctionsChallenge/FunctionsChallenge.pde @@ -0,0 +1,19 @@ +void setup() { +} + +void draw() { + findPermutation(3,8); +} + +int fact(int n) { + for (int i=n-1; i>=1; i--) { + n=n*i; + } + int factorial = + return +} + +int findPermutation(int places, int data) { + int result= factorial(places)/factorial(places-data); + return result; +} \ No newline at end of file From 1b06917406e015b4c95f5027cecf89c8a17cdb42 Mon Sep 17 00:00:00 2001 From: akodali Date: Tue, 8 Dec 2015 14:17:55 -0500 Subject: [PATCH 04/17] finished first function find permutation --- FunctionsChallenge/FunctionsChallenge.pde | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/FunctionsChallenge/FunctionsChallenge.pde b/FunctionsChallenge/FunctionsChallenge.pde index 9b11443..c3b7c8d 100644 --- a/FunctionsChallenge/FunctionsChallenge.pde +++ b/FunctionsChallenge/FunctionsChallenge.pde @@ -2,18 +2,17 @@ void setup() { } void draw() { - findPermutation(3,8); + println(findPermutation(8, 3)); } -int fact(int n) { - for (int i=n-1; i>=1; i--) { - n=n*i; +float findPermutation(float data, float places) { + places=data-places; + for (float i=places-1; i>=1; i--) { + places=places*i; } - int factorial = - return -} - -int findPermutation(int places, int data) { - int result= factorial(places)/factorial(places-data); + for (float i=data-1; i>=1; i--) { + data=data*i; + } + float result= data/places; return result; } \ No newline at end of file From 06f3782aa1f92e8fe3930025aeab1afb09d1d4df Mon Sep 17 00:00:00 2001 From: akodali Date: Tue, 8 Dec 2015 14:51:10 -0500 Subject: [PATCH 05/17] added second function need to fix third function --- FunctionsChallenge/FunctionsChallenge.pde | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/FunctionsChallenge/FunctionsChallenge.pde b/FunctionsChallenge/FunctionsChallenge.pde index c3b7c8d..92c645f 100644 --- a/FunctionsChallenge/FunctionsChallenge.pde +++ b/FunctionsChallenge/FunctionsChallenge.pde @@ -1,11 +1,21 @@ +float vf, a; +float x=width/2, y=height/2, d=50, vx=1, vy=1; void setup() { + size(500,500); } void draw() { - println(findPermutation(8, 3)); + background(255); + vf=findPermutation(random(0, 1), random(0, 1)); + a = findAcceleration(0, vf, .5); + fill(0); + ellipse(x, y, d, d); + x*=vx; + y*=vy; + vx*=a; } -float findPermutation(float data, float places) { + float findPermutation(float data, float places) { places=data-places; for (float i=places-1; i>=1; i--) { places=places*i; @@ -15,4 +25,12 @@ float findPermutation(float data, float places) { } float result= data/places; return result; +} + +float findAcceleration(float vi, float vf, float t) { + float acceleration = (vf-vi)/t; + return acceleration; +} + +void changeAcceleration() { } \ No newline at end of file From a236ea458c09178b5c3ccb5e6df60aa35d093f6a Mon Sep 17 00:00:00 2001 From: akodali Date: Thu, 10 Dec 2015 14:40:58 -0500 Subject: [PATCH 06/17] added arrays and third function --- FunctionsChallenge/FunctionsChallenge.pde | 57 ++++++++++++++++++----- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/FunctionsChallenge/FunctionsChallenge.pde b/FunctionsChallenge/FunctionsChallenge.pde index 92c645f..5ae133c 100644 --- a/FunctionsChallenge/FunctionsChallenge.pde +++ b/FunctionsChallenge/FunctionsChallenge.pde @@ -1,21 +1,50 @@ float vf, a; -float x=width/2, y=height/2, d=50, vx=1, vy=1; +int count=10; +//declare arrays +float []x= new float[count]; +float []y= new float[count]; +float []d= new float[count]; +float []vx= new float[count]; +float []vy= new float[count]; + void setup() { - size(500,500); + size(500, 500); + 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]); + } + } vf=findPermutation(random(0, 1), random(0, 1)); - a = findAcceleration(0, vf, .5); - fill(0); - ellipse(x, y, d, d); - x*=vx; - y*=vy; - vx*=a; + a=findAcceleration(0, vf, 10); + addAcceleration(); } - float findPermutation(float data, float places) { +float findPermutation(float data, float places) { places=data-places; for (float i=places-1; i>=1; i--) { places=places*i; @@ -31,6 +60,12 @@ float findAcceleration(float vi, float vf, float t) { float acceleration = (vf-vi)/t; return acceleration; } - -void changeAcceleration() { +void addAcceleration() { + for (int i=0; i Date: Thu, 10 Dec 2015 14:41:55 -0500 Subject: [PATCH 07/17] added a separate tab for functions --- FunctionsChallenge/Functions.pde | 25 ++++++++++++++++++++++ FunctionsChallenge/FunctionsChallenge.pde | 26 ----------------------- 2 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 FunctionsChallenge/Functions.pde diff --git a/FunctionsChallenge/Functions.pde b/FunctionsChallenge/Functions.pde new file mode 100644 index 0000000..3189888 --- /dev/null +++ b/FunctionsChallenge/Functions.pde @@ -0,0 +1,25 @@ +float findPermutation(float data, float places) { + places=data-places; + for (float i=places-1; i>=1; i--) { + places=places*i; + } + for (float i=data-1; i>=1; i--) { + data=data*i; + } + float result= data/places; + return result; +} + +float findAcceleration(float vi, float vf, float t) { + float acceleration = (vf-vi)/t; + return acceleration; +} +void addAcceleration() { + for (int i=0; i=1; i--) { - places=places*i; - } - for (float i=data-1; i>=1; i--) { - data=data*i; - } - float result= data/places; - return result; -} - -float findAcceleration(float vi, float vf, float t) { - float acceleration = (vf-vi)/t; - return acceleration; -} -void addAcceleration() { - for (int i=0; i Date: Sat, 12 Dec 2015 16:59:22 -0500 Subject: [PATCH 08/17] Update and rename Documentation1.md to findPermutation.md --- Documentation1.md | 19 ------------------- findPermutation.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 19 deletions(-) delete mode 100644 Documentation1.md create mode 100644 findPermutation.md 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/findPermutation.md b/findPermutation.md new file mode 100644 index 0000000..97c670a --- /dev/null +++ b/findPermutation.md @@ -0,0 +1,34 @@ +# Name: Ankita Kodali + +## Examples: +If there were 5 children running in a race, determine how many ways these children could win first, second, and third place. Using the permutation formula will give the answer quicker than trying to list every possibility. + +## Description: +To find the number of ways that certain amount of data can be ordered in a certain amount of places, this function uses the permutation formula. The permutation formla is the factorial of the amount of data divided by the factorial of the data minus the number of places. + +## Syntax: +float findPermutation(float data, float places) { + float places=data-places; //change the value of places to use it in the denominator + //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=places-1; i>=1; i--) { + places=places*i; + } + //use the factorial method again for the numerator + for (float i=data-1; i>=1; i--) { + data=data*i; + } + float result= data/places; //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. From d0327ad41fa1c3c044c205c5dd176d202be18b7f Mon Sep 17 00:00:00 2001 From: Ankita Date: Sat, 12 Dec 2015 16:59:42 -0500 Subject: [PATCH 09/17] Update findPermutation.md --- findPermutation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/findPermutation.md b/findPermutation.md index 97c670a..c58598d 100644 --- a/findPermutation.md +++ b/findPermutation.md @@ -1,4 +1,4 @@ -# Name: Ankita Kodali +# Ankita Kodali ## Examples: If there were 5 children running in a race, determine how many ways these children could win first, second, and third place. Using the permutation formula will give the answer quicker than trying to list every possibility. From 8825ef26315ba93e9b3c29a1309d45aa21c9a1ca Mon Sep 17 00:00:00 2001 From: Ankita Date: Sat, 12 Dec 2015 17:00:17 -0500 Subject: [PATCH 10/17] Update findPermutation.md --- findPermutation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/findPermutation.md b/findPermutation.md index c58598d..4b031c0 100644 --- a/findPermutation.md +++ b/findPermutation.md @@ -1,4 +1,4 @@ -# Ankita Kodali +# Name: findPermutation ## Examples: If there were 5 children running in a race, determine how many ways these children could win first, second, and third place. Using the permutation formula will give the answer quicker than trying to list every possibility. From 819913095862851ba89d6f719cba298faa4200ff Mon Sep 17 00:00:00 2001 From: Ankita Date: Sat, 12 Dec 2015 17:14:13 -0500 Subject: [PATCH 11/17] Update findPermutation.md --- findPermutation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/findPermutation.md b/findPermutation.md index 4b031c0..7e7ed91 100644 --- a/findPermutation.md +++ b/findPermutation.md @@ -8,16 +8,16 @@ To find the number of ways that certain amount of data can be ordered in a certa ## Syntax: float findPermutation(float data, float places) { - float places=data-places; //change the value of places to use it in the denominator + float denominator = data-places; //change the value of places to use it in the denominator //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=places-1; i>=1; i--) { - places=places*i; + 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; } - float result= data/places; //divide the two factorials found + float result= data/denominator; //divide the two factorials found return result; //return the result } From b1b79d25daeb891a99cfe854415a2f7578d2f889 Mon Sep 17 00:00:00 2001 From: Ankita Date: Sat, 12 Dec 2015 17:15:42 -0500 Subject: [PATCH 12/17] Update and rename Documentation2.md to findAcceleration.md --- Documentation2.md | 19 ------------------- findAcceleration.md | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 19 deletions(-) delete mode 100644 Documentation2.md create mode 100644 findAcceleration.md 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/findAcceleration.md b/findAcceleration.md new file mode 100644 index 0000000..2bd6e01 --- /dev/null +++ b/findAcceleration.md @@ -0,0 +1,25 @@ +# Name: findAcceleration + +## Examples: +In 2 seconds, the ball goes from 3m/s to 5 m/s, determine its acceleration. + +## Description: +If you know the initial and final velocity of an object over a certain amount of time, you can find the acceleration. +All you have to do is divide the change in velocity by the time. + +## Syntax: +float findAcceleration(float vi, float vf, float t) { + float acceleration = (vf-vi)/t; + return acceleration; +} + +##Parameters: +vi is the initial velocity which, in the example, is 3. +vf is the final velocity which, in the example, is 5. +t is the amount of time which, in the example, is 2. + +##Returns: +This function returns a number that represents the acceleration of the object. + +##Other notes: +You can add this value to the velocity that is there to give the object acceleration. From bdd8acd0a4812da96823a853b6d63154d183d6ae Mon Sep 17 00:00:00 2001 From: Ankita Date: Sun, 13 Dec 2015 19:53:39 -0500 Subject: [PATCH 13/17] Update Functions.pde --- FunctionsChallenge/Functions.pde | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/FunctionsChallenge/Functions.pde b/FunctionsChallenge/Functions.pde index 3189888..a5612f2 100644 --- a/FunctionsChallenge/Functions.pde +++ b/FunctionsChallenge/Functions.pde @@ -1,13 +1,15 @@ -float findPermutation(float data, float places) { - places=data-places; - for (float i=places-1; i>=1; i--) { - places=places*i; +float findPermutation(float data, float places) { + float denominator = data-places; //change the value of places to use it in the denominator + //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; } - float result= data/places; - return result; + float result= data/denominator; //divide the two factorials found + return result; //return the result } float findAcceleration(float vi, float vf, float t) { @@ -22,4 +24,4 @@ void addAcceleration() { vy[i]=1; } } -} \ No newline at end of file +} From d30337fdd930445ca91608f61361f8d851f006f4 Mon Sep 17 00:00:00 2001 From: akodali Date: Mon, 14 Dec 2015 13:58:49 -0500 Subject: [PATCH 14/17] added color to circles --- FunctionsChallenge/FunctionsChallenge.pde | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/FunctionsChallenge/FunctionsChallenge.pde b/FunctionsChallenge/FunctionsChallenge.pde index b73e29c..d85a211 100644 --- a/FunctionsChallenge/FunctionsChallenge.pde +++ b/FunctionsChallenge/FunctionsChallenge.pde @@ -1,11 +1,14 @@ float vf, a; -int count=10; +int count=25; //declare arrays float []x= new float[count]; float []y= new float[count]; float []d= new float[count]; float []vx= new float[count]; float []vy= new float[count]; +float []r= new float[count]; +float []g= new float[count]; +float []b= new float[count]; void setup() { size(500, 500); @@ -15,6 +18,9 @@ void setup() { d[i] = random(80); vx[i] = random(-5, 5); vy[i] = random(-5, 5); + r[i] = random(255); + g[i] = random(255); + b[i] = random(255); } } @@ -22,7 +28,8 @@ void draw() { background(255); for (int i=0; i Date: Wed, 16 Dec 2015 13:59:37 -0500 Subject: [PATCH 15/17] add information --- Documentation3.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Documentation3.md b/Documentation3.md index 28f94fa..392328c 100644 --- a/Documentation3.md +++ b/Documentation3.md @@ -1,19 +1,26 @@ -# Name: +# Name: addAcceleration ## Examples: -Insert examples here. +Increase or decrease the speed that the objects move. ## Description: -Insert description here +Add acceleration to the objects by increasing or decreasing the velocity in each frame. ## Syntax: -Demonstrate syntax here +void addAcceleration() { + for (int i=0; i Date: Wed, 16 Dec 2015 13:59:58 -0500 Subject: [PATCH 16/17] change name --- Documentation3.md => addAcceleration.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Documentation3.md => addAcceleration.md (100%) diff --git a/Documentation3.md b/addAcceleration.md similarity index 100% rename from Documentation3.md rename to addAcceleration.md From 6df7dad75cbf43e806a6278d8ad534a4bfd9852e Mon Sep 17 00:00:00 2001 From: akodali Date: Wed, 16 Dec 2015 14:08:14 -0500 Subject: [PATCH 17/17] finished commenting code --- FunctionsChallenge/Functions.pde | 21 +++++++++++++++------ FunctionsChallenge/FunctionsChallenge.pde | 7 +++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/FunctionsChallenge/Functions.pde b/FunctionsChallenge/Functions.pde index a5612f2..2b8caa9 100644 --- a/FunctionsChallenge/Functions.pde +++ b/FunctionsChallenge/Functions.pde @@ -1,27 +1,36 @@ float findPermutation(float data, float places) { - float denominator = data-places; //change the value of places to use it in the denominator + //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 + //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 + //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