Calculate tangent line by mouse / mouse coordinate

6

I want to calculate the tangent line to the points X and Y found by the mouse, limiting itself to the drawn circle ... I only managed to develop until the middle of the program. Can someone save me ??

I'm developing the program in processing for academic purposes.

Follow my code so far:

void setup() {
    size(300, 300);
}

void draw() 
{
    int x = 0;  
    float nX = mouseX, nY = pow(mouseX,2)/300;

    noStroke();
    fill(255);
    rect(0,0,300,300); 

    fill(255,0,0);
    ellipse(nX,nY,10,10);
    text("  "+nX+" "+"/"+nY,nX,nY-5);

    fill(255,0,0);
    stroke(3);
    line(nX, 0, nX, 300);
    line(0, nY, 300, nY);

    while (x < 300) {
        fill(0);
        ellipse(x, x*x/300, 2, 2);
        x = x + 1;
    }

}
    
asked by anonymous 13.05.2015 / 20:25

1 answer

2

To calculate the tangent line, we need to calculate the derivative, which will give us the angular coefficient of the line:

05.09.2015 / 00:55