Solving the bezier curve equation is giving wrong value

608 Views Asked by At

enter image description here

Solving the bezier curve for $x,y=181,188$ given $p1=67,324$ and $p2=190,318$ and $p3=174,63$ and $p4=292,58$ using the below diagram for formula reduction I am using the $t$ for $x=181$ is coming to $t=1.41745...$ and the y calculated given $x=181$ and $t=1.41745...$ is $y=218$ and not even close to $188$ which is the value I am expecting close to it not so far from it.

I am only interested in real roots solutions for $y$ given $x$ and the start end and control point coordinates.

$px = 181, \qquad p1x = 67, \qquad p2x = 190, \qquad p3x = 174, \qquad p4x = 292$

$py =$ trying to solve for this

$p1y = 324, \qquad p2y = 318, \qquad p3y = 63, \qquad p4y = 58$

To supply context I am trying to figure out if the user mouse clicked the bezier curve. So I thought solving for the y given the above picture equations for the x mouse click coordinate and checking if the resulting y is close enough to the corresponding mouse click y would show the user having clicked the bezier curve.

The equations in the diagram are reduced to where a computer can calculate it atm. If the real roots of the cubic equation are incomplete please give the correct formulas for all the real roots of the cubic equation. Thanks in advance.

2

There are 2 best solutions below

8
On

From the parameters given at the bottom of the post and the cubic equation in the picture, we obtain the equation:

$$273 t^3 - 417 t^2 + 369 t - 114 = 0$$

Which has a single real solution:

$$t \approx 0.497607953114642$$

The exact form in radicals is too long to write here, I refer the OP to Wolfram Alpha, which I used.

Here's the link:

http://www.wolframalpha.com/input/?i=(292-3*174%2B3*190-67)+t%5E3%2B3(174-2*190%2B67)+t%5E2%2B3(190-67)+t%2B67-181%3D0

4
On

https://brilliant.org/wiki/cardano-method/

This answers how to solve for t in the cubic then its plug and chug