I have to create a program, that when I put the mouse on any point of the curve, it draws its tangent line, and writes to me in a corner the value of the slope of this line. The drawing have to include the cartesian axis. The equation and the parameterization are:
BOW CURVE: (x^4)+(y^3)-((x^2)*y)=0
PARAMETERIZATION: x=t-t^3 and y=t^2-t^4
The code I have right now is this:
float a=300;
float angle=((-4*pow(mouseX,2)+2*mouseX*mouseY)/((3*pow(mouseY,2)-pow(mouseX,2))));
float w=300;
void setup(){
size(750,750);
}
void draw(){
background(255);
//AXIS(height,width);
translate(width/2,height/2);
for(float t=0; t<2*PI; t=t+0.001){
stroke(255,128,0);
strokeWeight(1.25);
point(a*(t-pow(t,3)),-a*(pow(t,2)-pow(t,4)));
point(-a*(t-pow(t,3)),-a*(pow(t,2)-pow(t,4)));
}
{
angle=atan(((-4*pow(mouseX,2)+2*mouseX*mouseY)/((3*pow(mouseY,2)-pow(mouseX,2)))));
pushMatrix();
translate(mouseX-width/2,mouseY-height/2);
rotate(((-4*pow(mouseX,2)+2*mouseX*mouseY)/((3*pow(mouseY,2)-pow(mouseX,2)))));
line(-w,0,w,0);
popMatrix();
}
}
There is something wrong with the code, if anyone could help me please.
The implicit derivative of the curve is this: