简体   繁体   中英

Divide polynomial into equally lengths in OpenCV

I have the equation of a third order polynomial and two points lying on that polygon.I also can calculate the length of the polygon between these points with the opencv arcLength function.

How do I get these equally distributed points, which divide the polygon into N parts with the same length?

问题可视化

Let's see if this can help. In what follows:

 f = polynomial
 f' = derivative of f
 N = Number of subdivisions
 D = length of each subdivisions
 a = x coordinate of f for the first end of the curve.
 M = max of f' in the interval [a, b] where the curve is to be drawn.
 k = an integer such that an error of M/k would be negligible

Algorithm

  • For every 1 <= j <= N - 1 , find n(j) such that the following sum(j) approaches jD by less than M/k :

     sum(j) = sum from i=1 to n(j) of sqrt(1 + f'(a + (i-1)/k)^2)/k

Idea of the algorithm

The quantity:

1/k * sqrt(1 + f'(a + (i-1)/k)^2)

is the approximate length of the curve between a + (i-1)/k and a + i/k .

The idea of the algorithm is to sum the lengths of these small curve segments trying to find which ones are close enough to D , 2D , 3D , etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM