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
1.1k views
in Technique[技术] by (71.8m points)

math - Transform 2d spline function f(t) into f(x)

So I've got a special case set of cubic splines, whose 2d control points will always result in a curve that will never cross itself in the x axis. That is, the curves look like they could be a simple polynomial function such that y=f(x). I want to efficiently create an array of y coordinates along the spline that correspond to evenly-spaced x coordinates running the length of the spline segment.

I want to efficiently find the y coordinates along the spline where, for instance, x=0.0, x=0.1, x=0.2, etc., or approached another way, effectively transform the fx,y(t) style function into an f(x) function.

I'm currently using a 4x4 constant matrix and four 2d control points to describe the spline, using matrix constants for either Hermite or Catmull-Rom splines, and plugging them into a cubic function of t going from 0 to 1.

Given the matrix and the control points, what's the best way to obtain these y values over the x axis?

EDIT: I should add that an approximation good enough to draw is sufficient.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Often people will use a root finding technique (like Newton's Method) if an numerical approximation is good enough.


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

...