Skip to content
64 changes: 64 additions & 0 deletions Code
Original file line number Diff line number Diff line change
@@ -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);
}
}
18 changes: 11 additions & 7 deletions Documentation1.md
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 15 additions & 7 deletions Documentation2.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 5 additions & 7 deletions Documentation3.md
Original file line number Diff line number Diff line change
@@ -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?