Hi everyone!!!
I’m new at coding and I have a problem, I would like to draw a program where there is a bicorn curve and every time the mouse is on the curve, it can be generated a tangent line, so on infinite points, but for now I just have the static drawing but I don’t know how to generate a tangent line on the curve as the mouse move…
Say you have your mouseX as input. Your mouseX = 50. What is a solution for a for a point on your bicorn that also has x = 50?
If you can solve for a, then you know r (constant) and x (the mouse) – so now you can solve for y on your bicorn. Now you know a point on your bicorn that is x-aligned with the mouse.
…and create a mouseCurvePoint function to draw a circle.
void mouseCurvePoint(float x) {
// solve 'a' here given x, r
// solve 'y' here given x, r, a
println(x, a);
ellipse(x, y, 10, 10); // mark your solution point
}
Now that you have a point, you need to solve for the slope at that point in order to know the slope of your tangent line. You can then create a line segment of that slope that passes through your point using the slope-intercept form of a line – and you have your tangent!