Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

language agnostic - How to find the mathematical function defining a bezier curve

Im trying to implement a bezier curve and line segment intersection test. The closest thing my searching has turned up is to take the bezier curve (lets limit it to three control points for simplicity) find the mathematical function generating that curve and place it on origo. Then, using the function for the line segment as another function and let them be equal and solve the equation.

Many sources state the above solution (unless Ive misunderstood them), my problem is I cant find the way to calculate the mathematical function that generates the bezier curve.

Oh, and please point out if Im completely off track with finding the intersection point(s).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A Bezier curve is a parametric function. A quadratic Bezier curve (i.e. three control points) can be expressed as: F(t) = A(1 - t)^2 + 2B(1 - t)t + Ct^2 where A, B and C are points and t goes from zero to one.

This will give you two equations:

x = a(1 - t)^2 + 2b(1 - t)t + ct^2

y = d(1 - t)^2 + 2e(1 - t)t + ft^2

If you add for instance the line equation (y = kx + m) to that, you'll end up with three equations and three unknowns (x, y and t).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...