How to calculate the length, and other info, programatically of a cubic Bézier curve?
-
I have a cubic Bézier curve, and I need to programatically calculate some information about it. In particular: - The length; - The x,y position of a point on the Bézier curve given the percentage from the start of it (i.e., 0.0 would be at the start, 0.5 would be the exact centre of the curve, 1.0 at the end); - The gradient of the curve at a given point, again between 0 and 1; - Not so important, but also the maximum gradient of the curve would be useful. I've tried integrating a Bézier curve before, but I was unable to; I hear that might not be possible, and so a recursive function to calculate the length might be the only way. As for the other points, I'm not sure. Thanks!
-
Answer:
First cut at this problem: You can get approximations to all of these by sampling. Generate 1000 points on your curve for instance. The length is the sum of the 999 distances. The (x,y) position could be from a lookup table combined with interpolation techniques. Same thing with the gradient. You could refine the approximations by doing finer sampling, generating more intermediate points, once you know the rough region you want to sample.
nerdcms at Yahoo! Answers Visit the source
Other answers
First cut at this problem: You can get approximations to all of these by sampling. Generate 1000 points on your curve for instance. The length is the sum of the 999 distances. The (x,y) position could be from a lookup table combined with interpolation techniques. Same thing with the gradient. You could refine the approximations by doing finer sampling, generating more intermediate points, once you know the rough region you want to sample.
Randy P
Related Q & A:
- How to calculate max/min scales on a scatter plot?Best solution by Cross Validated
- How To Calculate Approximate Expectation Of Function Of A Binomial Random Variable?Best solution by Mathematics
- How To Calculate The Value Of PI With A Program?Best solution by social.msdn.microsoft.com
- How to programatically select a item in list using c#?Best solution by Software Quality Assurance & Testing
- How can I change my yahoo 360 info?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.