math - Bezier curve arc lengths -


i have code calculates length of bezier curves. i'm trying write unit tests it. other trivial cases (straight line beziers) don't know actual correct values lengths. i've looked online , been unable find any.

does have info? i'm looking link table few rows containing 4 bezier control points , length, or possibly create couple of beziers in drawing program calculates length (i've tried using blender , inkscape info , they're quite complicated).

solution. download pomax's bezier javascript code here , open html in web browser:

<html> <head> <script src="bezier.js"></script> </head> <body> <script> curve = new bezier([4.0, 0.0,  4.0,                      4.0, 0.0,  12.0,                    16.0, 0.0,  12.0,                    16.0, 0.0,  4.0]);  document.write(curve.length()); </script> </body> </html> 

if want actual arc lengths test against, implement https://github.com/pomax/bezierjs/blob/gh-pages/lib/bezier.js#l602-604 - arbitrarily accurate numbers based on legendre-gauss quadrature evalutation (you don't have understand how works, although video link shows it's ridiculously simple. consequently, implementing easy).

another option rely on wolframalpha.com or mathematica (which free if own raspberri pi): set random curve, , make them compute length "properly", use result reference value in unit tests.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -