diff --git a/Code b/Code new file mode 100644 index 0000000..d5a0853 --- /dev/null +++ b/Code @@ -0,0 +1,64 @@ +int diam; +PVector loc; +PVector vel; + +void setup() +{ + size(400,400); + diam = 15; + loc = new PVector (mouseX, mouseY); + vel = new PVector (5,5); +} + +void draw() +{ + println(whenXDoesYouWrong(1,9,-10)); + println(springInMyStep(807.7,0.13,'w')); + println(springInMyStep(8.32,600,'x')); + println(springInMyStep(10,3.56,'k')); + followMrMouse(); +} + +float[] whenXDoesYouWrong(float a, float b, float c) +{ + float[]x = new float[2]; + x[0] = -b + (sqrt(sq(b) - 4*a*c))/2*a; + x[1] = -b - (sqrt(sq(b) - 4*a*c))/2*a; + return x; +} + +float springInMyStep (float a, float b, char isolate) +{ + float result = 0; + if(isolate == 'w') + { + result = 0.5*a*sq(b); + } + if(isolate == 'x') + { + result = sqrt((2*b)/a); + } + if(isolate == 'k') + { + result = (2*b)/sq(a); + } + return result; +} + +void followMrMouse() +{ + ellipse(loc.x,loc.y, diam, diam); + loc.add(vel); + if (loc.x > mouseX+20) + { + vel.x = -abs(vel.x); + } else if (loc.x < mouseX-20) { + vel.x = abs(vel.x); + } + if (loc.y > mouseY+20) + { + vel.y = -abs(vel.y); + } else if (loc.y < mouseY-20) { + vel.y = abs(vel.y); +} +} diff --git a/Documentation1.md b/Documentation1.md index 28f94fa..a2a268b 100644 --- a/Documentation1.md +++ b/Documentation1.md @@ -1,19 +1,23 @@ -# Name: +# Name: whenXDoesYouWrong ## Examples: -Insert examples here. +whenXDoesYouWrong(1,9,-10) ## Description: -Insert description here +Solves for the negative and positive values of x in the equation x = -b + (sqrt(sq(b) - 4*a*c))/2*a given the values a, b, and c. ## Syntax: -Demonstrate syntax here +whenXDoesYouWrong(value1, value2, value3) ##Parameters: -Name and describe parameters here +value1 float: the a value in the quadratic formula + +value2 float: the b value in the quadratic formula + +value3 float: the c value in the quadratic formula ##Returns: -What type of data does it return? +Returns float for positive and negative values of x. ##Other notes: -Anything else? +The name is a result of my dislike of the quadratic formula. diff --git a/Documentation2.md b/Documentation2.md index 28f94fa..bd564ae 100644 --- a/Documentation2.md +++ b/Documentation2.md @@ -1,19 +1,27 @@ -# Name: +# Name: springInMyStep ## Examples: -Insert examples here. +springInMyStep(807.7,0.13,'w') + +springInMyStep(8.32,600,'x') + +springInMyStep(10,3.56,'k') ## Description: -Insert description here +Solves for the indicated variable (w, k, or x) using variations of the physics equation for work done to a spring: w = 0.5*k*sq(x). ## Syntax: -Demonstrate syntax here +springInMyStep (value1, value2, character) ##Parameters: -Name and describe parameters here +value1 float: first numerical value + +value2 float: second numerical value + +character float: the letter corresponding to what variable is being solved for ##Returns: -What type of data does it return? +Returns float for isolated variable. ##Other notes: -Anything else? +value1 and value2 can represent any one of the three variables because they stand for the known values, not w, k, or x individually. diff --git a/Documentation3.md b/Documentation3.md index 28f94fa..9f3d326 100644 --- a/Documentation3.md +++ b/Documentation3.md @@ -1,19 +1,17 @@ -# Name: +# Name: followMrMouse() ## Examples: -Insert examples here. +followMrMouse(); ## Description: -Insert description here +Creates an ellipse that follows the mouse in a zigzag pattern. ## Syntax: -Demonstrate syntax here +followMrMouse() ##Parameters: -Name and describe parameters here + ##Returns: -What type of data does it return? ##Other notes: -Anything else?