Currently, I am faced with the challenge of dealing with a bezier curve intersecting with a line in the top left corner.
https://i.sstatic.net/QrgJP.png
After identifying the points at which the line and curve intersect, my goal is to determine the tangent of the bezier curve at those specific points. My existing function can find the tangent at a given point t on the curve but operates with values between 0 and 1 rather than coordinates. See below:
let bezierCurveTangent = function(start: Point, end: Point, controlPoint: Point, t: number): Point {
let x = 2 * (1 - t) * (controlPoint.x - start.x) + 2 * t * (end.x - controlPoint.x);
let y = 2 * (1 - t) * (controlPoint.y - start.y) + 2 * t * (end.y - controlPoint.y);
return { x, y };
}
The question now remains, how can I calculate the tangent for a point using x and y coordinates instead of a value for t?
The equation for a point on a bezier curve follows this structure:
https://i.sstatic.net/Aol5x.png
Is it feasible to rearrange this equation to solve for t and then input that value into the function mentioned above?
It seems there should be a more efficient method to tackle this issue without the need for constant conversions between t values and various points.