We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Parabolas (Read 838 times)
Parabolas
Dec 3rd, 2009, 9:54am
 
Hey,
      I was wondering if somebody could help me with this. I want the mouse location to be the vertex of my parabola and one of the x intercepts to be in the bottom left hand corner of the screen.

THX,
     The Lonckinator
Re: Parabolas
Reply #1 - Dec 3rd, 2009, 10:48am
 
Impossible, 2 points define an infinite number of parabolas.
You need one more constraint.
Re: Parabolas
Reply #2 - Dec 3rd, 2009, 4:13pm
 
it is possible... try this code

//only executes the animation once so not really animation
// create variable by by using float and then name and thin under use the name with what it should =
float targetx;
float targety;

void setup() {
  size (400, 400);
  smooth();
frameRate(30);
targetx = random(200, 375);
 targety = random(200, 375);
}

//
void draw(){

{  background (0);
stroke(0);

 fill(255, 0, 0);
 ellipse(targetx, targety, 50, 50);

fill(255);
ellipse(targetx , targety, 35, 35);

fill(255, 0, 0);
ellipse(targetx, targety, 20, 20);

fill(255);
ellipse(targetx , targety, 5, 5);

float x = 0; //our first point will be at x=0
float y = height;


beginShape();
while(y <= height) {
 float a = (height - mouseY) / (mouseX * mouseX + 0.01);
 y = a * (x - mouseX) * (x - mouseX) + mouseY;
 vertex(x, y);
 x += 0.1;
}
endShape();
}
 }
void mousePressed(){

 targetx = random(200, 375);
 targety = random(200, 375);
 
}
Re: Parabolas
Reply #3 - Dec 3rd, 2009, 6:30pm
 
Hello, class. As I said in the other thread, please refrain from posting to the processing forum for the time being. We need to review public forum etiquette before you begin posting again.

Thank you.
Mr. P
Page Index Toggle Pages: 1