6
I want to calculate the tangent line to the points X and Y found by the mouse, being limited to the circle drawn... I was only able to develop until halfway through the program. Someone can save me??
I am 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;
}
}
Um... for me it was not very clear what you want to do. What is the effect you want? The program will draw a circle at the first mouse click, and then will draw the tangent to the circle at a new point under the circle in which the user clicks, is that it? You can include in the question an illustration of the final result?
– Luiz Vieira
can show us with a drawing the final result you expect?
– h3nr1ke