J
J
Jerryracoon2021-07-17 22:25:47
Mathematics
Jerryracoon, 2021-07-17 22:25:47

Is it possible to express the value of the parameter t from the equation of a square Bezier curve?

I have the coordinates of three points with which a curve is built. I need to find the coordinates of the points of the curve for all integer x (i.e., for each integer X that is included in the given interval, I need to find the value of y).
I want for each integer value of X to find the value of the parameter t, and then substitute it into the equation for y. Can it be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2021-07-17
@Jerryracoon

Can.
For three points, the Bezier curve is described as:
P = (1−t)^2*P1 + 2(1−t)*t*P2 + t^2*P3
For X coordinates, the equation becomes:
X = (1−t) ^2*X1 + 2(1−t)*t*X2 + t^2*X3.
X is this coordinate on the Bezier curve and X1, X2, X3 are the X coordinates of the anchor points.
It is obvious that X will move in the area min(X1,X2,X3) to max(X1,X2,X3), but not the fact that each X will give a point (or two points at once) on the Bezier curve.
It turns out that X1,X2,X3 - you set it yourself, and X is sorted out based on the condition above.
It remains to figure out how to find t.
Let's rewrite the equation so that the known coordinates become constants of the quadratic equation.
X = X1 - 2*X1 + X1*t^2 + 2*X2*t - 2* X2 * t^2 + t^2*X3
X = (X1 - 2*X2 + X3) * t^2 + 2 * ( X2 - X1) * t +
X1
X1) * t + X1 - X = 0
Coefficient, which is:
a = X1 - 2*X2 + X3
b = 2 * (X2 - X1)
c = X1 - X
You solve it, you get 2 solutions.
If there is a solution with t in the interval from 0 to 1, then the point is defined on the Bezier curve (there may be both solutions included in the segment 0.1 - these are two different points!).
Knowing t, you can find the Y coordinate:
Y = (1−t)^2*Y1 + 2(1−t)*t*Y2 + t^2*
Y3 number (the discriminant turned out to be negative), then there is no point on the Bezier curve at the given X coordinate.
PS: Most likely you will find Y close to integer values ​​with some error, you can round to the nearest integer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question