Created
January 3, 2019 20:50
-
-
Save memish/47df772a934da6e4f8671dd911c63563 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x = 1; | |
int y = 0; | |
int x2 = 0; | |
int len = 100; | |
int y2 = 100; | |
boolean part1 = true; | |
void setup(){ | |
size(400,300); | |
frameRate(10); | |
// quad(2,4,7,2,19); | |
} | |
void draw(){ | |
parab(); | |
} | |
void quad (float a, float b, float c, float xmin, float xmax){ | |
float y; | |
for(float x=xmin; x<xmax; x=x+0.25){ | |
y = (a*x*x) + (b*x) + c; | |
float x2 = -x; | |
point(x+300, y); | |
point(x2+300, y); | |
} | |
} | |
// general quadratic function: y = ax^2 + bx + c | |
float quadraticY (float a, float b, float c, float x){ | |
return (a*x*x + b*x + c); | |
} | |
public void parab(){ | |
if(part1==true){ | |
if(y<len){ | |
line(x,y,x2,y2); | |
x2 +=2; | |
y += 2; | |
}else{ | |
part1=false; | |
} | |
}else{ | |
if (y2>10){ | |
line(x,y,x2,y2); | |
x +=2; | |
y2 -= 2; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment